// JavaScript Document

function CA_Country_OnChange(){ 
	oStateID.options.length = 0;
	oLocationID.options.length = 0;
	oCounty.options.length = 0;
	document.getElementById("OhioCounties").style.display = "none";  
	ObjToFill = oStateID;
	OptText = "Please Select A State";
	sVal = oCountryID.options[oCountryID.selectedIndex].value;
	if (sVal.length > 0){
		url = "LocationHandler.asp?action=GetStates&id=" + sVal;
		CallAJAXWebService(url, CA_PopulateStates);
	}
}

function CA_PopulateStates(responseText, responseStatus){
	if (responseStatus == 200) 
		FillStateMetroCounty(responseText,"locrow1",true);    
	else
		alert('We apologize but an error occurred with your location information.  Please try again later.');
	SetStateValue(oStateID, oLocationID, "locrow1", "Please Select A State First","");
}

function CA_State_OnChange(){
	oLocationID.options.length = 0;
	oCounty.options.length = 0;
	document.getElementById("OhioCounties").style.display = "none";
	ObjToFill = oLocationID;
	OptText = "Please Select A Metro";
	CreateNewOption("Please Select A State First", "", oLocationID, true); 
	sVal = oStateID.options[oStateID.selectedIndex].value
	if (sVal.length > 0){
		url = "LocationHandler.asp?action=GetMetros&id=" + oStateID.options[oStateID.selectedIndex].value;
		CallAJAXWebService(url, CA_PopulateMetros);
	}	
}

function CA_PopulateMetros(responseText, responseStatus){
	if (responseStatus == 200) 
		FillStateMetroCounty(responseText,"locrow1",true);    
	else
		alert('We apologize but an error occurred with your location information.  Please try again later.');
	 
	if (oLocationID.options.length == 0){
		var sLocId = oCountryID.options[oCountryID.selectedIndex].value
		CreateNewOption(sLocId, sLocId, oLocationID, true); 
	}

	if (oStateID.options[oStateID.selectedIndex].value == "222FOH"){
			ObjToFill = oCounty;
			OptText = "Please Select A County";
			CallAJAXWebService("LocationHandler.asp?action=GetCounties&id=OH", CA_LoadOhioCounties);  
	}
	else {
			oCounty.value="";
			document.getElementById("OhioCounties").style.display = "none";
	}
}


function CA_LoadOhioCounties(responseText, responseStatus){
	if (responseStatus == 200) 
		FillStateMetroCounty(responseText,"locrow1",true);    
	else
		alert('We apologize but an error occurred with your location information.  Please try again later.');
	if (oCounty.options.length > 0)
		document.getElementById("OhioCounties").style.display = "";   
}


function CA_ValidateOhioCompany(){
	if (oStateID.options[oStateID.selectedIndex].value == '222FOH'){
		if (oCounty.selectedIndex == 0)
			return false;
		else
			return true;
	}else
		return true;
}