function syncCountryWithState(stateElement, countryElement)
{
   var strCountry = "";
   if(stateElement.value.length != 0 && stateElement.value != "--")
   {
      strCountry = determineCountryFromState(stateElement.value);
      if(strCountry.length != 0)
      {
         countryElement.value = strCountry;
      }
   }
   return
}

function syncStateWithCountry(stateElement, countryElement)
{
   //reset the state if the country is not a country with state/province
   if(countryElement.value != "US" && countryElement.value != "CA" && countryElement.value != "PR")
   {
      stateElement.value = "";
   }
   else
   {
      //verify that the state is still valid for the country selected
      var strCountry = "";
      strCountry = determineCountryFromState(stateElement.value);
      if (strCountry.length != 0 && strCountry != countryElement.value)
      {
         //reset the state
         stateElement.value = "";
      }
   }
   return
}

function determineCountryFromState (state) 
{
	var strCountry = "";

	switch (state) 
	{
		case "AB": 
			strCountry = "CA";
			break;	
		case "BC": 
			strCountry = "CA";
			break;	
		case "MB": 
			strCountry = "CA";
			break;	
		case "NB": 
			strCountry = "CA";
			break;	
		case "NL": 
			strCountry = "CA";
			break;	
		case "NT": 
			strCountry = "CA";
			break;	
		case "NS": 
			strCountry = "CA";
			break;	
		case "NU":
			strCountry = "CA";
			break;	
		case "ON": 
			strCountry = "CA";
			break;	
		case "PE": 
			strCountry = "CA";
			break;	
		case "QC": 
			strCountry = "CA";
			break;	
		case "SK": 
			strCountry = "CA";
			break;	
		case "YT": 
			strCountry = "CA";
			break;	
		case "AA":
			strCountry = "US";
			break;	
		case "AE":
			strCountry = "US";
			break;
		case "AL":
			strCountry = "US";
			break;
		case "AK":
			strCountry = "US";
			break;
		case "AP":
			strCountry = "US";
			break;	
		case "AZ":
			strCountry = "US";
			break;
		case "AR":
			strCountry = "US";
			break;
		case "CA":
			strCountry = "US";
			break;
		case "CO":
			strCountry = "US";
			break;
		case "CT":
			strCountry = "US";
			break;
		case "DE":
			strCountry = "US";
			break;
		case "D.C.":
			strCountry = "US";
			break;
		case "FL":
			strCountry = "US";
			break;
		case "GA":
			strCountry = "US";
			break;
		case "HI":
			strCountry = "US";
			break;
		case "IA":
			strCountry = "US";
			break;
		case "ID":
			strCountry = "US";
			break;
		case "IL":
			strCountry = "US";
			break;
		case "IN":
			strCountry = "US";
			break;
		case "KS":
			strCountry = "US";
			break;
		case "KY":
			strCountry = "US";
			break;
		case "LA":
			strCountry = "US";
			break;
		case "MA":
			strCountry = "US";
			break;
		case "MD":
			strCountry = "US";
			break;
		case "ME":
			strCountry = "US";
			break;
		case "MI":
			strCountry = "US";
			break;
		case "MN":
			strCountry = "US";
			break;
		case "MO":
			strCountry = "US";
			break;
		case "MS":
			strCountry = "US";
			break;
		case "MT":
			strCountry = "US";
			break;
		case "NC":
			strCountry = "US";
			break;
		case "ND":
			strCountry = "US";
			break;
		case "NE":
			strCountry = "US";
			break;
		case "NH":
			strCountry = "US";
			break;
		case "NJ":
			strCountry = "US";
			break;
		case "NM":
			strCountry = "US";
			break;
		case "NV":
			strCountry = "US";
			break;
		case "NY":
			strCountry = "US";
			break;
		case "OH":
			strCountry = "US";
			break;
		case "OK":
			strCountry = "US";
			break;
		case "OR":
			strCountry = "US";
			break;
		case "PA":
			strCountry = "US";
			break;
		case "PR":
			strCountry = "US";
			break;
		case "RI":
			strCountry = "US";
			break;
		case "SC":
			strCountry = "US";
			break;
		case "SD":
			strCountry = "US";
			break;
		case "TN":
			strCountry = "US";
			break;
		case "TX":
			strCountry = "US";
			break;
		case "UT":
			strCountry = "US";
			break;
		case "VA":
			strCountry = "US";
			break;
		case "VI":
			strCountry = "US";
			break;
		case "VT":
			strCountry = "US";
			break;
		case "WA":
			strCountry = "US";
			break;
		case "WV":
			strCountry = "US";
			break;
		case "WI":
			strCountry = "US";
			break;
		case "WY":
			strCountry = "US";
			break;
	}

   return strCountry;
}