function createRequestObject()
{
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var http = createRequestObject(); 

/* Function called to get the product categories list */
function getCounties()
{
	http.open('get', 'getcounty.php?state=' 
			+ document.propselect.select_state.options[document.propselect.select_state.selectedIndex].value);
	http.onreadystatechange = displayCounties; 
	http.send(null);
}

function getCities()
{
	http.open('get', 'getcity.php?state=' + document.propselect.select_state.options[document.propselect.select_state.selectedIndex].value + '&county=' + document.propselect.select_county.options[document.propselect.select_county.selectedIndex].value);
	
	http.onreadystatechange = displayCities; 
	http.send(null);
}


function displayCounties()
{
	
	
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		document.getElementById('county_cage').innerHTML = response;
		//document.getElementById('city_cage').innerHTML = " ";
		
		getCities();
	}
}

function displayCities()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		document.getElementById('city_cage').innerHTML = response;
	}
}


