//get Counties for the selected state using ajax
function funcionCallback(){
	if( ajax.readyState == 4 ){
		if( ajax.status == 200 ){
			counties = ajax.responseText;
			opts = counties.split(",");
			document.getElementById('depcounty').options.length = 0;
			for (i=0;i<(opts.length-1);i++){
				document.getElementById('depcounty').options[i] = new Option(opts[i],opts[i]);
			}
		}
	}
}

function getcounties(state){
	if( window.XMLHttpRequest )
		ajax = new XMLHttpRequest();
	else
		ajax = new ActiveXObject("Microsoft.XMLHTTP");

	ajax.onreadystatechange = funcionCallback;

	ajax.open( "GET", "counties.php?state="+state, true );
	ajax.send( "" );
}

//get Counties for the selected state using ajax
function funcionCallback2(){
	if( ajax2.readyState == 4 ){
		if( ajax2.status == 200 ){
			counties2 = ajax2.responseText;
			opts2 = counties2.split(",");
			document.getElementById('arrcounty').options.length = 0;
			for (i=0;i<(opts2.length-1);i++){
				document.getElementById('arrcounty').options[i] = new Option(opts2[i],opts2[i]);
			}
		}
	}
}

function getcounties2(state2){
	if( window.XMLHttpRequest )
		ajax2 = new XMLHttpRequest();
	else
		ajax2 = new ActiveXObject("Microsoft.XMLHTTP");

	ajax2.onreadystatechange = funcionCallback2;

	ajax2.open( "GET", "counties.php?state="+state2, true );
	ajax2.send( "" );
}
