var locationArray = new Array();
var regionArray = new Array();
var selState;

var counter = 0;
var http = createObject();
countyCheck = '';

function stateUPD(theCounty) {

	var nocache = Math.random();
	countyCheck = theCounty;
	
	//remove the _ma suffix from MA counties with duplicate names
	countyCheck = countyCheck.replace(/_ma/, "")
	countyCheck = countyCheck.replace(/_me/, "")
	
	//if initial page load, default to NH otherwise use selected state
	if (document.getElementById('theState').value=='') {
		selState='NH';
	} else {
		selState = document.getElementById('theState').value;
		//document.getElementById('theState').disabled = true;
	}
	
	http.open('get', '/js/buildString.cfm?state='+selState+'&nocache='+nocache);
	http.onreadystatechange = stateReply;
	http.send(null);
}	

function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
	return request_type;
}

function stateReply() {
	if(http.readyState == 4){
		var response = http.responseText;
		if(response == 0){
			// if failed
			
		// else ok 
		} else {
			locationArray = response.split(",");
			buildTestSelect();
		}
	}
}

