var CurrentTab = 1;		//1 = "About You", 2 = "Address", 3 = "Billing"


function GoBack(ServiceType)
{
	switch(CurrentTab)
	{
		case 1:
			if (ServiceType == "Full Service")
				location.href = "full_select_loading_options.php";
			else
				location.href = "self_select_loading_options.php";
			break;
		case 2:
			SelectTab(1, ServiceType);
			break;
		case 3:
			SelectTab(2, ServiceType);
			break;
		default:
			//Unknown tab (somehow)
			SelectTab(1, ServiceType);
			break;
	}
	return false;
}


function CustomerInfoContinue()
{
	// 1. If they are on the "About You" tab and all the mandatory fields are filled in, go to the "Address" tab
	// 2. If they are on the "Address" tab and all the mandatory fields are filled in
	//	if they are doing full service, go to confirm
	//	if they are doing self service, go to the "Billing" tab
	// 3. If they are on the "Billing" tab and all mandatory fields are filled in, go to the "Confirm" screen
	
	var ErrorMessage = "";
	var Parameters = "";

	switch(CurrentTab)
	{
		case 1:
			ErrorMessage = AboutYouFieldsAreValid();
			if (ErrorMessage.length <= 0)
			{
				Parameters = 
				"&Title="+document.CustomerInfo.Title.value+
				"&FirstName="+document.CustomerInfo.FirstName.value+
				"&LastName="+document.CustomerInfo.LastName.value+
				"&Company="+document.CustomerInfo.Company.value+
				"&ContactPerson="+document.CustomerInfo.ContactPerson.value+
				"&AlternateContact="+document.CustomerInfo.AlternateContact.value+
				"&HomePhone="+document.CustomerInfo.HomePhone.value+
				"&BusinessPhone="+document.CustomerInfo.BusinessPhone.value+
				"&MobilePhone="+document.CustomerInfo.MobilePhone.value+
				"&Pager="+document.CustomerInfo.Pager.value+
				"&OtherPhone="+document.CustomerInfo.OtherPhone.value+
				"&Fax="+document.CustomerInfo.Fax.value+
				"&EmailAddress="+document.CustomerInfo.EmailAddress.value+
				"&Password="+document.CustomerInfo.Password.value+
				"&EmailPromotions="+document.CustomerInfo.EmailPromotions.value+
				"&HowFindUs="+document.CustomerInfo.HowFindUs.value+
				"&HowFindUsText="+document.CustomerInfo.HowFindUsText.value+
				"&CouponCode="+document.CustomerInfo.CouponCode.value;

				AjaxCall("POST","customer_info.php","SetAboutYouInfo=1" + Parameters, "AfterSetAboutYouInfo", true);
			}
			else
				ShowPopup(true, "ERROR", ErrorMessage);	
			break;
		case 2:
			ErrorMessage = AddressFieldsAreValid();
			if (ErrorMessage.length <= 0)
			{
				Parameters =
				"&StreetNumber="+document.CustomerInfo.StreetNumber.value+
				"&StreetName="+document.CustomerInfo.StreetName.value+
				"&StreetType="+document.CustomerInfo.StreetType.value+
				"&Unit="+document.CustomerInfo.Unit.value+
				"&City="+document.CustomerInfo.City.value;
				
				if (document.CustomerInfo.Intersection)
					Parameters += "&Intersection="+escape(document.CustomerInfo.Intersection.value);

				if (document.CustomerInfo.PostalCode)
					Parameters += "&PostalCode="+document.CustomerInfo.PostalCode.value;

				if (document.getElementById('BillingSameAsDelivery'))
				{
					if (document.getElementById('BillingSameAsDelivery').checked)
					{
						Parameters += "&BillingSameAsDelivery=1"+
							      "&BillingStreetNumber="+document.CustomerInfo.StreetNumber.value+
							      "&BillingStreetName="+document.CustomerInfo.StreetName.value+
							      "&BillingStreetType="+document.CustomerInfo.StreetType.value+
							      "&BillingUnit="+document.CustomerInfo.Unit.value+
							      "&BillingCity="+document.CustomerInfo.City.value+
							      "&BillingPostalCode="+document.getElementById("PostalCode").innerHTML;
					}	
					else
					{
						Parameters += "&BillingSameAsDelivery=0"+
							      "&BillingStreetNumber="+document.CustomerInfo.BillingStreetNumber.value+
							      "&BillingStreetName="+document.CustomerInfo.BillingStreetName.value+
							      "&BillingStreetType="+document.CustomerInfo.BillingStreetType.value+
							      "&BillingUnit="+document.CustomerInfo.BillingUnit.value+
							      "&BillingCity="+document.CustomerInfo.BillingCity.value+
							      "&BillingPostalCode="+document.CustomerInfo.BillingPostalCode.value;
					}
				}
				else
				{
					//this happens when registering
					Parameters += "&BillingSameAsDelivery=0"+
						      "&BillingStreetNumber="+document.CustomerInfo.StreetNumber.value+
						      "&BillingStreetName="+document.CustomerInfo.StreetName.value+
						      "&BillingStreetType="+document.CustomerInfo.StreetType.value+
						      "&BillingUnit="+document.CustomerInfo.Unit.value+
						      "&BillingCity="+document.CustomerInfo.City.value+
						      "&BillingPostalCode="+document.CustomerInfo.PostalCode.value;
				}
				
				AjaxCall("POST","customer_info.php","SetAddressInfo=1" + Parameters, "AfterSetAddressInfo", true);
			}
			else
				ShowPopup(true, "ERROR", ErrorMessage);	
			break;
		case 3:
			ErrorMessage = BillingFieldsAreValid();
			if (ErrorMessage.length <= 0)
			{
				Parameters =
				"&CCName="+document.CustomerInfo.CCName.value+
				"&CCType="+document.CustomerInfo.CCType.value+
				"&CCNumber="+document.CustomerInfo.CCNumber.value+
				"&CCExpiry="+document.CustomerInfo.CCExpiryMonth.value + document.CustomerInfo.CCExpiryYear.value.substr(2) +
				"&CCCVS="+document.CustomerInfo.CCCVS.value;

				AjaxCall("POST","customer_info.php","SetBillingInfo=1" + Parameters, "AfterSetBillingInfo", true);
			}
			else
				ShowPopup(true, "ERROR", ErrorMessage);	
			break;
		default:
			//Unknown tab (somehow)
			SelectTab(1, "");
			break;
	}
}


function AfterSetAboutYouInfo(xml, text)
{
	//if the current page is 'register.php', change the text
	//just set the session variables.  Go to the next tab

	var URLParts = window.location.href.split('/');
	var Page = URLParts[URLParts.length-1];

	if (Page == "register.php")
		SelectTab(2, "Register");
	else
		SelectTab(2, text);
}


function AfterSetAddressInfo(xml, text)
{
	// 1. if the current page is 'register.php', do something different
	// 2. just set the session variables.  Go to the next tab

	var URLParts = window.location.href.split('/');
	var Page = URLParts[URLParts.length-1];

	if (Page == "register.php")
		AjaxCall("POST","register.php","CreateUser=1122", "AfterCreateUser", true);
	else
	{
		//No billing for full service
		if (text == "Full Service")
			location.href="review_order.php";
		else
			SelectTab(3, text);
	}
}


function AfterSetBillingInfo(xml, text)
{
	//just set the session variables.  Go to the next step
	location.href="review_order.php";
}


function AfterCreateUser(xml, text)
{
	if (text == "")
		document.getElementById('Content').innerHTML = '<div class="IndentedTitle"><h3>Success!</h3><p>An e-mail has been sent to the address you provided.  You must click on the link in the e-mail to complete your registration.  Once you do this you will be able to log in.</p></div>';
	else
		document.getElementById('ErrorMessageWrapper').innerHTML = '<div class="IndentedTitle"><h3>Error!</h3><p>'+text+'</p></div>';
}



function AddAboutYouLink(ServiceType)
{
	//Add a link back to the "about you" tab, so they can go back.
	var MyImage = document.createElement('img');
	MyImage.id = "AboutYouTabImage";
	MyImage.src = "images/CustomerInfoAboutYouOff.jpg";
	MyImage.border = 0;
	MyImage.alt = "About you";

	var MyLink = document.createElement('a');
	MyLink.href = "#";
	SetOnClick(MyLink, "SelectTab(1, '"+ServiceType+"'); return false;");

	document.getElementById('AboutYouTab').innerHTML = "";
	MyLink.appendChild(MyImage);
	document.getElementById('AboutYouTab').appendChild(MyLink);

	document.getElementById('AboutYouTabImage').src = "images/CustomerInfoAboutYouOff.jpg";
}


function AddAddressLink(ServiceType)
{
	//Add a link back to the "Address" tab, so they can go back.
	var MyImage = document.createElement('img');
	MyImage.id = "AddressTabImage";
	MyImage.src = "images/CustomerInfoAddressOff.jpg";
	MyImage.border = 0;
	MyImage.alt = "Address";

	var MyLink = document.createElement('a');
	MyLink.href = "#";
	SetOnClick(MyLink, "SelectTab(2, '"+ServiceType+"'); return false;");

	document.getElementById('AddressTab').innerHTML = "";
	MyLink.appendChild(MyImage);
	document.getElementById('AddressTab').appendChild(MyLink);

	document.getElementById('AddressTabImage').src = "images/CustomerInfoAddressOff.jpg";
}


function AddBillingLink(ServiceType)
{
	//Add a link back to the "Billing" tab, so they can go back.
	var MyImage = document.createElement('img');
	MyImage.id = "BillingTabImage";
	MyImage.src = "images/CustomerInfoBillingOff.jpg";
	MyImage.border = 0;
	MyImage.alt = "Billing";

	var MyLink = document.createElement('a');
	MyLink.href = "#";
	SetOnClick(MyLink, "SelectTab(3, '"+ServiceType+"'); return false;");

	document.getElementById('BillingTab').innerHTML = "";
	MyLink.appendChild(MyImage);
	document.getElementById('BillingTab').appendChild(MyLink);

	document.getElementById('BillingTabImage').src = "images/CustomerInfoBillingOff.jpg";
}


function SelectTab(Number, ServiceType)
{

	var URLParts = window.location.href.split('/');
	var Page = URLParts[URLParts.length-1];

	CurrentTab = Number;

	// 1. Hide all content
	// 2. Show proper content
	// 3. Deselect tabs
	// 4. Select tab
	
	// 1.
	switch(Number)
	{
		case 3:
			document.getElementById('AboutYouContent').style.display = "none";
			document.getElementById('AddressContent').style.display = "none";
			document.getElementById('BillingContent').style.display = "block";

			if (ServiceType == "Self Service")
			{
				AddAboutYouLink(ServiceType);
				AddAddressLink(ServiceType);
				AddBillingLink(ServiceType);
			}
			//else if (ServiceType == "Full Service")
			else
			{
				AddAboutYouLink(ServiceType);
				AddAddressLink(ServiceType);
			}
			/*
			else
			{
				//register
				document.getElementById('AboutYouTabImage').src = "images/CustomerInfoAboutYouOff.jpg";
				document.getElementById('AddressTabImage').src = "images/CustomerInfoAddressOff.jpg";
			}
			*/
			
			document.getElementById('BillingTabImage').src = "images/CustomerInfoBillingOn.jpg";
			break;
		case 2:

			document.getElementById('AboutYouContent').style.display = "none";
			document.getElementById('BillingContent').style.display = "none";
			document.getElementById('AddressContent').style.display = "block";

			if (ServiceType == "Self Service")
			{
				AddAboutYouLink(ServiceType);
				AddAddressLink(ServiceType);
			}
			//else if (ServiceType == "Full Service")
			else
			{
				AddAboutYouLink(ServiceType);
				AddAddressLink(ServiceType);
			}
			/*
			else
			{
				document.getElementById('AboutYouTabImage').src = "images/CustomerInfoAboutYouOff.jpg";
			}
			*/
			document.getElementById('AddressTabImage').src = "images/CustomerInfoAddressOn.jpg";

			//No billing for full service
			if (ServiceType == "Self Service")
				document.getElementById('BillingTabImage').src = "images/CustomerInfoBillingOff.jpg";
			
			if (Page == "register.php")
			{
				//Show the 'back' button
				//Change the source of the 'Continue' button to 'Register'

				document.getElementById('BackButton').style.display = "block";
				document.getElementById('ContinueButton').src = "images/RegisterButton3.png";
			}
			break;
		case 1:
		default:
			document.getElementById('AddressContent').style.display = "none";
			document.getElementById('BillingContent').style.display = "none";
			document.getElementById('AboutYouContent').style.display = "block";
			
			if (ServiceType == "Self Service")
			{
				AddAboutYouLink(ServiceType);
				//AddAddressLink(ServiceType);
				//AddBillingLink(ServiceType);
			}
			else if (ServiceType == "Full Service")
			{
				AddAboutYouLink(ServiceType);
			}

			//No billing for full service
			if (ServiceType == "Self Service")
				document.getElementById('BillingTabImage').src = "images/CustomerInfoBillingOff.jpg";

			document.getElementById('AboutYouTabImage').src = "images/CustomerInfoAboutYouOn.jpg";
			document.getElementById('AddressTabImage').src = "images/CustomerInfoAddressOff.jpg";
			
			if (Page == "register.php")
			{
				//Hide the 'back' button
				//Change the source of the 'Continue' button to 'Continue'

				document.getElementById('BackButton').style.display = "none";
				document.getElementById('ContinueButton').src = "images/Continue.png";
			}

			break;
	}
}

function AboutYouFieldsAreValid()
{
	//first name, last name, home phone, email, confirm email, password, confirm pass, how find us
	//valid email, password is at least 6 chars (I say remove this check), password matches confirm password, 'if other please specify'

	if (document.CustomerInfo.FirstName.value.trim().length <= 1 || document.CustomerInfo.FirstName.value.trim().length > 50)
	{
		FocusOnField(document.CustomerInfo.FirstName);
		return "Please enter your first name (up to 50 characters).";
	}
	else if (document.CustomerInfo.LastName.value.trim().length <= 1 || document.CustomerInfo.LastName.value.trim().length > 50)
	{
		FocusOnField(document.CustomerInfo.LastName);
		return "Please enter your last name (up to 50 characters).";
	}
	else if (!IsValidPhoneNumber(document.CustomerInfo.HomePhone.value))
	{
		FocusOnField(document.CustomerInfo.HomePhone);
		return "Please enter your primary phone number in the format '123-123-1234' or '123-123-1234 xxxx' (where xxxx is your extension).";
	}
	else if (!IsValidEmail(document.CustomerInfo.EmailAddress.value) || document.CustomerInfo.EmailAddress.value.length > 250)
	{
		FocusOnField(document.CustomerInfo.EmailAddress);
		return "Please enter a valid e-mail address.";
	}
	else if (document.CustomerInfo.EmailAddressConfirm.value.trim().length <= 0)
	{
		FocusOnField(document.CustomerInfo.EmailAddressConfirm);
		return "Please re-enter your e-mail address.";
	}
	else if (document.CustomerInfo.EmailAddress.value != document.CustomerInfo.EmailAddressConfirm.value)
	{
		FocusOnField(document.CustomerInfo.EmailAddressConfirm);
		return "The value in the 'E-mail Address' field must match the value in the 'Re-enter E-mail' field.";
	}
	else if (document.CustomerInfo.Password.value.trim().length <= 5 || document.CustomerInfo.Password.value.trim().length > 50)
	{
		FocusOnField(document.CustomerInfo.Password);
		return "Please enter your password (between 6 and 50 characters).";
	}
	else if (document.CustomerInfo.PasswordConfirm.value.trim().length <= 0)
	{
		FocusOnField(document.CustomerInfo.PasswordConfirm);
		return "Please re-enter your password.";
	}
	else if (document.CustomerInfo.Password.value != document.CustomerInfo.PasswordConfirm.value)
	{
		FocusOnField(document.CustomerInfo.PasswordConfirm);
		return "The value in the 'Password' field must match the value in the 'Re-enter Password' field.";
	}
	else if (document.CustomerInfo.HowFindUs.selectedIndex == 0)
	{
		FocusOnField(document.CustomerInfo.HowFindUs);
		return "Please let us know how you found us.";
	}
	else if (document.CustomerInfo.HowFindUs.value == "Other" && (document.CustomerInfo.HowFindUsText.value.trim() == "") || (document.CustomerInfo.HowFindUsText.value.length > 200))
	{
		FocusOnField(document.CustomerInfo.HowFindUsText);
		return "Please specify how you found us (up to 200 characters).";
	}
	
	return "";
}

function AddressFieldsAreValid()
{
	//Street, City

	if (document.CustomerInfo.StreetNumber.value.trim().length <= 0 || document.CustomerInfo.StreetNumber.value.trim().length  > 50)
	{
		FocusOnField(document.CustomerInfo.StreetNumber);
		return "Please enter a valid street number.";
	}
	else if (document.CustomerInfo.StreetName.value.trim().length <= 1 || document.CustomerInfo.StreetName.value.trim().length > 50)
	{
		FocusOnField(document.CustomerInfo.StreetName);
		return "Please enter your street name.";
	}
	else if (document.CustomerInfo.StreetType.value == "-")
	{
		FocusOnField(document.CustomerInfo.StreetType);
		return "Please enter choose a street type.";
	}
	else if (document.CustomerInfo.City.value.trim().length <= 1 || document.CustomerInfo.City.value.trim().length > 50)
	{
		FocusOnField(document.CustomerInfo.City);
		return "Please enter your city.";
	}
	else if (document.CustomerInfo.PostalCode && !IsValidPostalCode(document.CustomerInfo.PostalCode.value))
	{
		FocusOnField(document.CustomerInfo.PostalCode);
		return "Please enter a valid postal code.";
	}
	else if (document.CustomerInfo.Intersection && document.CustomerInfo.Intersection.value.trim().length <= 1)
	{
		FocusOnField(document.CustomerInfo.Intersection);
		return "Please enter the nearest major intersection.";
	}

	if (document.getElementById('BillingSameAsDelivery') && !document.getElementById('BillingSameAsDelivery').checked)
	{
		//Billing address fields are also mandatory
		if (document.CustomerInfo.BillingStreetNumber.value.trim().length <= 0 || document.CustomerInfo.BillingStreetNumber.value.trim().length  > 50)
		{
			FocusOnField(document.CustomerInfo.BillingStreetNumber);
			return "Please enter a valid billing street number.";
		}
		else if (document.CustomerInfo.BillingStreetName.value.trim().length <= 1 || document.CustomerInfo.BillingStreetName.value.trim().length > 50)
		{
			FocusOnField(document.CustomerInfo.BillingStreetName);
			return "Please enter your billing street name.";
		}
		else if (document.CustomerInfo.BillingStreetType.value == "-")
		{
			FocusOnField(document.CustomerInfo.BillingStreetType);
			return "Please enter choose a billing street type.";
		}
		else if (document.CustomerInfo.BillingCity.value.trim().length <= 1 || document.CustomerInfo.BillingCity.value.trim().length > 50)
		{
			FocusOnField(document.CustomerInfo.BillingCity);
			return "Please enter your billing city.";
		}
		else if (document.CustomerInfo.BillingPostalCode && !IsValidPostalCode(document.CustomerInfo.BillingPostalCode.value))
		{
			FocusOnField(document.CustomerInfo.BillingPostalCode);
			return "Please enter a valid billing postal code.";
		}
	}
	
	return "";
}

function BillingFieldsAreValid()
{
	//CCName, CCType, CCNumber, CCExpiry, CCCVS

	if (document.CustomerInfo.CCName.value.trim().length <= 0)
	{
		FocusOnField(document.CustomerInfo.CCName);
		return "Please enter the name that appears on the credit card.";
	}
	else if (document.CustomerInfo.CCType.value == "")
	{
		FocusOnField(document.CustomerInfo.CCType);
		return "Please choose a credit card type.";
	}
	else if (!IsValidCreditCardNumber(document.CustomerInfo.CCNumber.value))
	{
		FocusOnField(document.CustomerInfo.CCNumber);
		return "Please enter a valid credit card number.  Include numbers only - no spaces or dashes.";
	}
	/*
	else if (!IsValidCreditCardExpiry(document.CustomerInfo.CCExpiry.value))
	{
		FocusOnField(document.CustomerInfo.CCExpiry);
		return "Please enter a valid credit card expiry date.";
	}
	*/
	else if (document.CustomerInfo.CCExpiryMonth.value == "")
	{
		FocusOnField(document.CustomerInfo.CCExpiryMonth);
		return "Please choose the month your credit card expires.";
	}
	else if (document.CustomerInfo.CCExpiryYear.value == "")
	{
		FocusOnField(document.CustomerInfo.CCExpiryYear);
		return "Please choose the year your credit card expires.";
	}
	else if (CreditCardHasExpired(document.CustomerInfo.CCExpiryMonth.value, document.CustomerInfo.CCExpiryYear.value))
	{
		FocusOnField(document.CustomerInfo.CCExpiryYear);
		return "The credit card expiry date you have specified is in the past.";
	}
	else if (!IsValidCVS(document.CustomerInfo.CCCVS.value))
	{
		FocusOnField(document.CustomerInfo.CCCVS);
		return "Please enter a valid credit card verification number.<br /><br />Click on the 'What is a CVS link for more information.";
	}
	/*
	//Validate expiry date format
	if (document.CustomerInfo.CCExpiry.value.length != 4 || !IsNumeric(document.CustomerInfo.CCExpiry.value))
	{
		FocusOnField(document.CustomerInfo.CCExpiry);
		return "Please enter a valid credit card expiry date in the format 'mmyy'.  For example, a March 2012 expiry would be entered as '0312'.";
	}
	*/
	return "";
}


function IsValidCreditCardNumber(ccNumb)
{
	var valid 	= "0123456789"
	var len 	= ccNumb.length;
	var bNum 	= true;
	var iCCN 	= ccNumb;
	var sCCN 	= ccNumb.toString();
	var iCCN;
	var iTotal 	= 0;
	var bResult = false;
	var digit;
	var temp;
	iCCN = sCCN.replace (/^\s+|\s+$/g,'');
	
	for (var j=0; j<len; j++)
	{
		temp = "" + iCCN.substring(j, j+1);
		if (valid.indexOf(temp) == "-1")
			return false;
	}
	
	iCCN = parseInt(iCCN);
	
	if(len == 0)
		return false;
	else
	{
		if(len >= 15)
		{
			//15 or 16 for Amex or V/MC

			for(var i=len; i>0; i--)
			{
				digit = "digit" + i;

				calc = parseInt(iCCN) % 10;	//right most digit
				calc = parseInt(calc);
				iTotal += calc;
				i--;
				digit = "digit" + i;

				iCCN = iCCN / 10; 	// subtracts right most digit from ccNum
				calc = parseInt(iCCN) % 10 ;	// step 1 double every other digit
				calc2 = calc *2;

				switch(calc2)
				{
					case 10: calc2 = 1; break;	//5*2=10 & 1+0 = 1
					case 12: calc2 = 3; break;	//6*2=12 & 1+2 = 3
					case 14: calc2 = 5; break;	//7*2=14 & 1+4 = 5
					case 16: calc2 = 7; break;	//8*2=16 & 1+6 = 7
					case 18: calc2 = 9; break;	//9*2=18 & 1+8 = 9
					default: calc2 = calc2; 	//4*2= 8 &   8 = 8  -same for all lower numbers
				}
				
				iCCN = iCCN / 10; 	// subtracts right most digit from ccNum
				iTotal += calc2;
			}

			if ((iTotal%10)==0)
				return true;
			else
				return false;
		}
	}
}


/*
function IsValidCreditCardExpiry(Expiry)
{
	//Comes in the format "MMYY".

	if (Expiry.length != 4 || !IsNumeric(Expiry))
		return false;
	
	var Month = Expiry.substring(0, 2);
	var Year = "20" + Expiry.substring(2, 4);
	var MyDate = new Date();
	var CurrentMonth = MyDate.getMonth() + 1;
	
	if (CurrentMonth < 10)
		CurrentMonth = "0" + CurrentMonth;
	
	if (Year < MyDate.getFullYear())
		return false;
	else if (Year == MyDate.getFullYear() && Month < CurrentMonth)
		return false;
	
	return true;
}
*/


function CreditCardHasExpired(Month, Year)
{
	var TodaysDate = new Date();
	var CurrentMonth = TodaysDate.getMonth()+1;
	var CurrentYear = TodaysDate.getFullYear();

	if (CurrentMonth < 9)
		CurrentMonth = "0" + CurrentMonth;
		
	if (Year < CurrentYear || ((Year == CurrentYear) && (Month < CurrentMonth)))
		return true;
	
	return false;
}

function IsValidCVS(CVS)
{
	if (IsNumeric(CVS) && (CVS.length == 3 || CVS.length == 4))
		return true;
	else
		return false;
}


function UpdateContactPerson()
{
	document.getElementById('ContactPerson').value = document.getElementById('FirstName').value + " " + document.getElementById('LastName').value;
}


function ToggleBillingAddress()
{
	if (document.getElementById('BillingSameAsDelivery').checked)
		document.getElementById('BillingAddressFieldsWrapper').style.display = "none";
	else
		document.getElementById('BillingAddressFieldsWrapper').style.display = "block";
}
