//  Creates Drop Down Location Menus
//
function clearDropDownMenu(dropDownMenuName) {
	useDropDown = document.getElementById(dropDownMenuName);
	for ( i = useDropDown.options.length; i > -1; i-- )
	{
		useDropDown.remove(0); 
	}
	useDropDown.options[useDropDown.options.length] = new Option ('Any','');

}

function buildCitiesFromLocation( locationId ) {
	countryId = document.getElementById("Country").value;
	stateId = document.getElementById("State").value;
	document.getElementById("navBuilder").src = "/locationBuilder.cfm?type=city&location=" + locationId + "&state=" + stateId + "&country=" + countryId	;
}

function buildLocationsAndCities( stateId ) {
	clearDropDownMenu( "City" );
	if (document.getElementById('location')) {
		clearDropDownMenu( "location" );
		}
	countryId = document.getElementById("Country").value;
	document.getElementById("navBuilder").src = "/locationBuilder.cfm?type=locationAndCity&state=" + stateId + "&country=" + countryId	;
}

function buildStates( countryId ) {
	clearDropDownMenu( "City" );
	document.getElementById("navBuilder").src = "/locationBuilder.cfm?type=state&country=" + countryId;
}

function buildDropDownMenu(dropDownMenuName, returnData) {
	useDropDown = document.getElementById(dropDownMenuName);
	clearDropDownMenu(dropDownMenuName);
	if (dropDownMenuName != "City"  || (dropDownMenuName == "City" && document.getElementById("State").options.length > 1) )
		{
		arrData = returnData.split("::");
		for ( i = 0; i < arrData.length - 1; i++ ) 
		{
			thisData = arrData[i].split("==");
			useDropDown.options[useDropDown.options.length] = new Option (thisData[0] + ' (' + thisData[1] + ')', thisData[0]);
		}
	}
	else 
	{
		if (document.getElementById("Country").value != "")
		{
			buildStates(document.getElementById("Country").value);
		}				
		else
		{
			document.getElementById("Country").selectedIndex = 0;
			document.getElementById("State").selectedIndex = 0;
		}
	}
}