// JavaScript Document

function BillingShippingValidateForm()
{
	var todoStatus = trim(document.getElementById('todo').value);
	
	var Name = document.getElementById("Name").value;
	if(Name=='')
	{
		alert('Please Enter Your Name');
		document.getElementById("Name").focus();
		return false;
	}
	
	var Country = document.getElementById("Country").options[document.getElementById("Country").selectedIndex].value;
	if(Country=='')
	{
		alert('Please Select A Country');
		document.getElementById("Country").focus();
		return false;
	}
	
/*	var Address = document.getElementById("Address").value;
	if(Address=='')
	{
		alert('Please Enter Address');
		document.getElementById("Address").focus();
		return false;
	}
*/	
	var ContactInfo = document.getElementById("ContactInfo").value;
	if(ContactInfo=='')
	{
		alert('Please Enter Street and Apartment Info');
		document.getElementById("ContactInfo").focus();
		return false;
	}
	
	
	
	var State = document.getElementById("State").options[document.getElementById("State").selectedIndex].value;
//	if(State=='')
//	{
//		alert('Please Select A State');
//		document.getElementById("State").focus();
//		return false;
//	}
//
//	var City = document.getElementById("City").options[document.getElementById("City").selectedIndex].value;
	var City = document.getElementById("City").value;
//	if(City=='')
//	{
//		alert('Please Select A City');
//		document.getElementById("City").focus();
//		return false;
//	}

	document.getElementById("CountryID").value = Country;
	document.getElementById("StateID").value = State;
	document.getElementById("CityID").value = City;
	
	
	

	
	var ShippingCountry = document.getElementById("ShippingCountry").options[document.getElementById("ShippingCountry").selectedIndex].value;
	if(ShippingCountry=='')
	{
		alert('Please Select A Country');
		document.getElementById("ShippingCountry").focus();
		return false;
	}
	
	var ShippingState = document.getElementById("ShippingState").options[document.getElementById("ShippingState").selectedIndex].value;
	if(ShippingState=='')
	{
		alert('Please Select A State');
		document.getElementById("ShippingState").focus();
		return false;
	}

	//var ShippingCity = document.getElementById("ShippingCity").options[document.getElementById("ShippingCity").selectedIndex].value;
	var ShippingCity = document.getElementById("ShippingCity").value;
	if(ShippingCity=='')
	{
		alert('Please Select A City');
		document.getElementById("ShippingCity").focus();
		return false;
	}

	document.getElementById("ShippingCountryID").value = ShippingCountry;
	document.getElementById("ShippingStateID").value = ShippingState;
	document.getElementById("ShippingCityID").value = ShippingCity;
	
	var ShippingContactInfo = document.getElementById("ShippingContactInfo").value;
	if(AllTrim(ShippingContactInfo)=='')
	{
		alert('Please Enter Street and Apartment Info');
		document.getElementById("ShippingContactInfo").focus();
		return false;
	}
	
	var ShippingName = document.getElementById("ShippingName").value;
	if(AllTrim(ShippingName)=='')
	{
		alert('Please Enter Shipping Name');
		document.getElementById("ShippingName").focus();
		return false;
	}
	
//	var ShippingAddress = document.getElementById("ShippingAddress").value;
//	if(AllTrim(ShippingAddress)=='')
//	{
//		alert('Please Enter Address');
//		document.getElementById("ShippingAddress").focus();
//		return false;
//	}
}

function SameAsBilling(Obj)
{
	var Country = document.getElementById("Country").options[document.getElementById("Country").selectedIndex].value;
	
	var CountryIndexNo = document.getElementById("Country").options[document.getElementById("Country").selectedIndex].index;
//		document.getElementById('ShippingCountry').options[CountryIndexNo].selected = true;
//	alert(CountryIndexNo);
//	return false;
	
	var State = document.getElementById("State").options[document.getElementById("State").selectedIndex].value;
	//var City = document.getElementById("City").options[document.getElementById("City").selectedIndex].value;

	document.getElementById("CountryID").value = Country;
	document.getElementById("StateID").value = State;
	//document.getElementById("CityID").value = City;
	
	var ContactInfo = document.getElementById("ContactInfo").value;
	//var Address = document.getElementById("Address").value;
	var Name = document.getElementById("Name").value;
	var Zip = document.getElementById("Zip").value;
	var City = document.getElementById("City").value;
	
	if(Obj.checked)
	{
		//alert('ChkOK');
		document.getElementById("ShippingContactInfo").value = ContactInfo;
		//document.getElementById("ShippingAddress").value = Address;
		document.getElementById("ShippingName").value = Name;
		document.getElementById("ShippingZip").value = Zip;
		document.getElementById("ShippingCity").value = City;
		
		document.getElementById('ShippingCountry').options[CountryIndexNo].selected = true;
		OnChangeCountryCopy(Country,'ShippingCountry','DivShippingState','UserSection',State);
		OnChangeCountryCopy(State,'ShippingState','DivShippingCity','UserSection',City);
	}
	else
	{
		//alert('No');
		document.getElementById("ShippingContactInfo").value = '';
		//document.getElementById("ShippingAddress").value = '';
		document.getElementById("ShippingName").value = '';

		document.getElementById('ShippingCountry').options[0].selected = true;
		OnChangeCountryCopy(0,'ShippingCountry','DivShippingState','UserSection',0);
		OnChangeCountryCopy(0,'ShippingState','DivShippingCity','UserSection',0);
	}
}



