// If the user selects the states, js will determine if a proper state code has been added
// If the state is not recognised, the user will be forced to select a state from the list.
 
function statesSelect(addr_country, addr_county, addr_state, countyRow, stateRow)
{
	//Check to see if US has been selected and if dropdown already block, ignore the following tes
	if (document.getElementById(addr_country).value == 'US' && document.getElementById(stateRow).style.display == 'none')
	{
		//Get the full options list 
		var americanOptionsList = document.getElementById(addr_state);
		for(var i = 0; i < americanOptionsList.options.length; ++i)
		{
			var countyInput = document.getElementById(addr_county).value;
			//See if the county value equates to any of the states listed in the options list
			if (americanOptionsList.options[i].value == countyInput.toUpperCase())
			{
				//alert("US State found in original input");
				americanOptionsList.options[i].selected = true;
			}
		}

		//Ensure County/State section is displayed properly
	 	document.getElementById(countyRow).style.display = 'none';
		document.getElementById(stateRow).style.display = 'table-row';
	}
	else
	{
		//Ensure County/State section is displayed properly
	 	document.getElementById(countyRow).style.display = 'table-row';
		document.getElementById(stateRow).style.display = 'none';
		
		//Remove 2 char value from (now) county box to save on confusion
		document.getElementById(addr_county).value = '';
	}
}

function setInitialCountyOptionDisplay(addr_country, countyRow, stateRow)
{
		if (document.getElementById(addr_country).value == 'US')
		{
			document.getElementById(stateRow).style.display = 'table-row';
			document.getElementById(countyRow).style.display = 'none';
		}
		else
		{
			document.getElementById(stateRow).style.display = 'none';
			document.getElementById(countyRow).style.display = 'table-row';
		}
}

