// JavaScript Document

function orderValidate()
{
	var email = document.forms.f1.confirmE_mail.value;
	var confirmEmail = document.forms.f1.e_mail.value;
	var password = document.forms.f1.password.value;
	var confirmPassword = document.forms.f1.confirmPassword.value;
	var firstName = document.forms.f1.firstName.value;
	var lastName = document.forms.f1.lastName.value;
	var address = document.forms.f1.address.value;
	var city = document.forms.f1.city.value;
	var state = document.forms.f1.state.value;
	var zip = document.forms.f1.zip.value;
	var cardNo = document.forms.f1.cardNo.value;
	var month = document.forms.f1.month.value;
	var year = document.forms.f1.year.value;
	var tc = document.forms.f1.tc.value;
	var coachCorner = document.forms.f1.coachCorner.value;
	
	//alert("coachCorner: " + coachCorner);
	
	if(document.forms.f1.tc.checked	== false)
	{
		alert("You must agree to the terms & conditions by selelcting the checkbox before the order can be submitted.");
		return false;
	}
	else if(email == "" || email == null)
	{
		alert("You must enter an e-mail address before the order can be submitted.");
		document.forms.f1.e_mail.focus();
		document.forms.f1.e_mail.style.backgroundColor = "yellow";
		return false;
	}
	else if(email != confirmEmail)
	{
		alert("The E-mail and Confirm E-mail fields must match before the order can be submitted.");
		document.forms.f1.e_mail.focus();
		document.forms.f1.e_mail.style.backgroundColor = "yellow";
		document.forms.f1.confirmE_mail.style.backgroundColor = "yellow";
		return false;
	}
	else if(firstName == "" || firstName == null)
	{
		alert("You must enter your first name before the order can be submitted.");
		document.forms.f1.firstName.focus();
		document.forms.f1.firstName.style.backgroundColor = "yellow";
		return false;
	}
	else if(lastName == "" || lastName == null)
	{
		alert("You must enter your last name before the order can be submitted.");
		document.forms.f1.lastName.focus();
		document.forms.f1.lastName.style.backgroundColor = "yellow";
		return false;
	}
	else if(address == "" || address == null)
	{
		alert("You must enter your address before the order can be submitted.");
		document.forms.f1.address.focus();
		document.forms.f1.address.style.backgroundColor = "yellow";
		return false;
	}
	else if(city == "" || city == null)
	{
		alert("You must enter your city before the order can be submitted.");
		document.forms.f1.city.focus();
		document.forms.f1.city.style.backgroundColor = "yellow";
		return false;
	}
	else if(state == "" || state == null)
	{
		alert("You must enter your state before the order can be submitted.");
		document.forms.f1.state.focus();
		document.forms.f1.state.style.backgroundColor = "yellow";
		return false;
	}
	else if(zip == "" || zip == null)
	{
		alert("You must enter your zip code before the order can be submitted.");
		document.forms.f1.zip.focus();
		document.forms.f1.zip.style.backgroundColor = "yellow";
		return false;
	}
	else if(cardNo == "" || cardNo == null)
	{
		alert("You must enter a credit card number before the order can be submitted.");
		document.forms.f1.cardNo.focus();
		document.forms.f1.cardNo.style.backgroundColor = "yellow";
		return false;
	}
	else if(month == "" || month == null)
	{
		alert("You must enter the expiration month of your credit card before the order can be submitted.");
		document.forms.f1.month.focus();
		document.forms.f1.month.style.backgroundColor = "yellow";
		return false;
	}
	else if(year == "" || year == null)
	{
		alert("You must enter the expiration year of your credit card before the order can be submitted.");
		document.forms.f1.year.focus();
		document.forms.f1.year.style.backgroundColor = "yellow";
		return false;
	}
	else if(coachCorner != "0")
	{
		if(password == "" || password == null)
		{
			alert("You must enter a password before the order can be submitted.");
			document.forms.f1.password.focus();
			document.forms.f1.password.style.backgroundColor = "yellow";
			return false;
		}
		else if(password != confirmPassword)
		{
			alert("The Password and Confirm Password fields must match before the order can be submitted.");
			document.forms.f1.password.focus();
			document.forms.f1.password.style.backgroundColor = "yellow";
			document.forms.f1.confirmPassword.style.backgroundColor = "yellow";
			return false;
		}
		else
		{
			emailCheck(email);
		}
	}
	else
	{
		return true;
	}
}

function copyBilling()
{
	var firstName = document.forms.f1.firstName.value;
	var lastName = document.forms.f1.lastName.value;
	var address = document.forms.f1.address.value;
	var city = document.forms.f1.city.value;
	var state = document.forms.f1.state.value;
	var zip = document.forms.f1.zip.value;
	var country = document.forms.f1.country.value;
	var shipContact = firstName + " " + lastName;
	var phone = document.forms.f1.phone.value;	
	
	if(document.forms.f1.copyBillingChk.checked)
	{
		with(document)
			{
				forms.f1.shipName.value = shipContact;
				forms.f1.shipAddress.value = address;
				forms.f1.shipCity.value = city;
				forms.f1.shipState.value = state;
				forms.f1.shipZip.value = zip;
				forms.f1.shipCountry.value = country;
				forms.f1.shipPhone.value = phone;
			}
	}
	else
	{
		with(document)
			{
				forms.f1.shipName.value = "";
				forms.f1.shipAddress.value = "";
				forms.f1.shipCity.value = "";
				forms.f1.shipState.value = "";
				forms.f1.shipZip.value = "";
				forms.f1.shipCountry.value = "";
				forms.f1.shipPhone.value = "";
			}		
	}
		
}

