function country_validate() 
{
	var USIndex;
	for (var i = 0; i < document.anonymous.countryID.length; i++)
	{	
	    if(document.anonymous.countryID.options[i].value == "226")
		{
			USIndex = i;
	 		}
	}
	if (document.anonymous.countryID.value != 226)
	{
		if (document.anonymous.StateID.selectedIndex > 1)
		{
			alert("Your selected state requires United States as your country!");
			document.anonymous.countryID.options[USIndex].selected = true;
		}
		else
		{
			document.anonymous.StateID.options[0].selected = true;
			document.anonymous.PostalCode.value = "";
			document.anonymous.Province.value = "";
			document.anonymous.IntPhone.value = "";
		}
 	}
}

function state_validate() 
{
	var USIndex;
	for (var i = 0; i < document.anonymous.countryID.length; i++)
	{	
	    if(document.anonymous.countryID.options[i].value == "226")
		{
			USIndex = i;
	 		}
	}	
	
	if (document.anonymous.countryID.selectedIndex > 1) 
	{		
		document.anonymous.countryID.options[USIndex].selected = true;
		document.anonymous.PostalCode.value = "Not Applicable";
		document.anonymous.Province.value = "Not Applicable";
		document.anonymous.IntPhone.value = "Not Applicable";
	}
}
function chooseCity(bs, no)
{
	if (bs=="1")
		for (var i=0; i < document.anonymous.CorrectBillToCity.length; i++)
		{
			if (document.anonymous.CorrectBillToCity[i].checked)
			{
				document.anonymous.BillToCity.value = document.anonymous.CorrectBillToCity[i].value;
				if (no == 'x')			
				 document.anonymous.dnvbc.value = 1;
				else			
				document.anonymous.dnvbc.value = 0;
			}
	   }
	else
		{
			for (var i=0; i < document.anonymous.CorrectShipToCity.length; i++)
			{
				if (document.anonymous.CorrectShipToCity[i].checked)
				{
					document.anonymous.ShipTocity.value = document.anonymous.CorrectShipToCity[i].value;
					if (no == 'x')		
						document.anonymous.dnvsc.value = 1;
					else	
						document.anonymous.dnvsc.value = 0;
				}
			}
	   }
}

function chooseProvince(bs, no)
{ 
	if (bs=="1")
	{
		for (var i=0; i < document.BillingForm.CorrectBillToProvince.length; i++)
		{
			if (document.BillingForm.CorrectBillToProvince[i].checked)
			{
						document.BillingForm.BillToProvinceCanadaID.value = document.BillingForm.CorrectBillToProvince[i].value ;
						if (no == 'x')			
							 document.BillingForm.dnvbc.value = 1;
						else			
							document.BillingForm.dnvbc.value = 0;
			}
	   }

	}	
	else
	{
		for (var i=0; i < document.ShippingForm.CorrectShipToProvince.length; i++)
		{
			if (document.ShippingForm.CorrectShipToProvince[i].checked)
			{
						document.ShippingForm.ShipToProvinceCanadaID.value = document.ShippingForm.CorrectShipToProvince[i].value ;
						if (no == 'x')		
							document.ShippingForm.dnvsc.value = 1;
						else	
							document.ShippingForm.dnvsc.value = 0;
			}
	   }
	}
}

