function getState(dropbox, country ) {
	getStateForCountry('/includes/staterefresh.jsp?country=' + country, dropbox);
}

// gets the XML request object.
function getXMLHttpObj(){
	
	if(typeof(XMLHttpRequest)!='undefined')
		return new XMLHttpRequest();

	// for all the microsoft browsers
	var axO=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], i;
	for(i=0;i<axO.length;i++)
		try{
			return new ActiveXObject(axO[i]);
		}catch(e){}
	return null;
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

// getting the XMLrequest object
var oXML = getXMLHttpObj();   

function getStateForCountry(jsppath, dropbox)
{


   // synchronous request.
   oXML.open('GET',jsppath, false);
   oXML.send(null);
   updateStateCombobox(dropbox);
}


function updateStateCombobox(dropbox){
    var dropbxidx = 1;
    dropbox.options.length = 0;
    dropbox.options[0]=new Option("Select One");
    var responsearray = oXML.responseText.split('\n');
    for ( i = 0; i < responsearray.length; i++)  {
    	responsearray[i] = trim(responsearray[i]);
    	if (responsearray[i] != "") {
    		var idx = responsearray[i].lastIndexOf("-");
    		dropbox.options[dropbxidx] = new Option(trim(responsearray[i].substring(0, idx - 1)), trim(responsearray[i].substring(idx + 1)));
    		dropbxidx ++;
    	}    
    }
}

function getStateAll(dropbox, country)
{
	getState(dropbox, country);
	var selALL = dropbox
	selALL.options[selALL.options.length] = new Option('All Locations', '*');
}