// JavaScript Document
function createRequestObject() 
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer")
	{
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }
	else
	{
        ro = new XMLHttpRequest();
    }
    return ro;
}
var http = createRequestObject();
//function to call the php page to display the states based on the sountry selected
function displayState(country)
{
	http.open('get','php/Source/getstate.php?country='+country);
	http.onreadystatechange = handleResponse;
	http.send(null);
}
function handleResponse() 
{
    if(http.readyState == 4)
	{
		var response = http.responseText;
		optlength = document.ParentRegn['State'].options.length;
		for(i=(optlength-1);i >= 0; i--)
		{	
			document.getElementById('State').options[i]=null;	
		}
		var result = response.split("_");
		for(i=0;i<result.length;i++)
		{
			var state=result[i].split(",");
			//assigning the values to the drop down box
			document.getElementById('State').options[i]=new Option(state[1],state[0]);
		}
	}
}
