// JavaScript Document
var xmlHttpState;

// Code for merchant account creation
function loadState(){ 
	xmlHttpState=GetXmlHttpObjectState();
	if (xmlHttpState==null){
		alert ("Browser does not support HTTP Request");
		return;
 	}
		
	var url="loadstatesearch.php";
	url=url+"?countryname="+document.wolbiea.wcountry.value;
	url=url+"&sid="+Math.random();
	xmlHttpState.onreadystatechange=stateChangedState;
	setStateWaitStatus();
	xmlHttpState.open("GET",url,true);
	xmlHttpState.send(null);
}

function setStateWaitStatus(){
	//document.getElementById("wolbieastatestatus").innerHTML='<img border="0" src="http://www.market24x7.com/images/animated_loading.gif" width="16" height="16">';
	document.getElementById("wolbieastatestatus").innerHTML='<select size="1" name="wstate"><option selected value="Loading States.....">Loading......&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option></select>';	
}

function setStateStatustoNormal(){
	document.getElementById("wolbieastatestatus").innerHTML='<select size="1" name="wstate"><option selected value="Any">Any</option></select>';
	
}



function stateChangedState(){ 
	if (xmlHttpState.readyState==4 || xmlHttpState.readyState=="complete")
 	{ 
		var resValue = xmlHttpState.responseText;
		//alert(resValue);
		if(resValue==1)
		{
			setStateStatustoNormal();
		}
		else if(resValue==3)
		{
			alert("Error loading state details!");
			setStateStatustoNormal();
		}
		else{
			document.getElementById("wolbieastatestatus").innerHTML=resValue;
		}
		
 	} 
}

function GetXmlHttpObjectState(){
	var xmlHttpState=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttpState=new XMLHttpRequest();
 	}
	catch (e){
 		//Internet Explorer
		try{
  		xmlHttpState=new ActiveXObject("Msxml2.XMLHTTP");
  		}
 		catch (e){
  			xmlHttpState=new ActiveXObject("Microsoft.XMLHTTP");
  		}
	}
	return xmlHttpState;
}
// End of merchant login code
