var xmlHttp=createXmlHttpRequest();

function createXmlHttpRequest(){
        var xmlHttp;
        try{
                xmlHttp=new XMLHttpRequest();
        }
        catch(e){
                var xmlHttpVersions=new Array("Msxml2.XMLHTTP.6.0",
                                              "Msxml2.XMLHTTP.5.0",
                                              "Msxml2.XMLHTTP.4.0",
                                              "Msxml2.XMLHTTP.3.0",
                                              "Microsoft.XMLHTTP");
                for(var i=0; i<xmlHttpVersions.length && !xmlHttp; i++){
                        try{
                                xmlHttp=new ActiveXObject(xmlHttpVersions[i]);
                        }
                        catch(e){}
                }
        }
        if(!xmlHttp)
         alert("Error Create Object");
        else
         return xmlHttp;
}

function processRequest(param){	
        if(xmlHttp){
                try{
                        var url;
                        var param = (param == null) ? "" : "?iso="+param;
                        url="xmlresponse.php";
                        if(param!='') url=url+param;
						
                        xmlHttp.open("GET", url, true);
                        xmlHttp.onreadystatechange=handleResquestChange;
                        xmlHttp.send(null);
         }
                catch(e){
                        alert("can't connect to server\n"+e.toString());
                }
        }
}
function handleResquestChange(){
        if(xmlHttp.readyState==4){
         if(xmlHttp.status==200){
          try{

                  handleServerResponse();
          }
          catch(e){
                  alert("Error Reading Response"+e.toString());
          }
         }
         else{
                 alert("there is Problem in Retrieving Data");
         }
 }
}

function handleServerResponse()
{
	/* Initialize State Box */
	var stateBox = document.getElementById("cboState");
	stateBox.options.length = 0;
	//stateBox.options[stateBox.options.length] = new Option('Select State','')

	var xmlResponse = xmlHttp.responseXML;	
	xmlDocumentElement = xmlResponse.documentElement;
	
	if(xmlDocumentElement.getElementsByTagName("state"))
	{
		stateList = xmlDocumentElement.getElementsByTagName("state");
		for(var i=0; i<stateList.length; i++)
		{
			stateName = unescape(stateList.item(i).firstChild.data);
			stateBox.options[stateBox.options.length] = new Option(stateName, stateName);
		}
	}
}