// JavaScript Document
function emailchk() {
	if (document.Order_Form.firstname.value =="") {
	alert('A first name is needed to complete the form');
	document.Order_Form.firstname.focus();
	return false
	}

	if (document.Order_Form.family_name.value =="") {
	alert('A family name is needed to complete the form');
	document.Order_Form.family_name.focus();
	return false
	}
	var x=document.Order_Form.email.value ;
	if (document.Order_Form.email.value =="") {
	alert('An email address is required to complete the form');
	document.Order_Form.email.focus();
	return false
	}
	if (x.indexOf("@")==-1) {
	alert("It seems you entered an invalid email address.  Please try again.")
	document.Order_Form.email.focus()
	return false
	}
	if (document.Order_Form.Product.value =="Undeclared") {
	alert('A product must be ordered.');
	document.Order_Form.Product.focus();
	return false
	}

	if (document.Order_Form.checkOrCredit.value == "Undeclared") {
	alert('You must choose a payment type of check or credit card.');
	document.Order_Form.checkOrCredit.focus();
	return false
	}
//If a check, then stop checking and call up the php file for a different message than the credit card message
	if (document.Order_Form.checkOrCredit.value =="check") {
	return
	}
//If we reach here, it must be a credit card sale
	if (document.Order_Form.creditCardType.value == "Undeclared")  {
	alert('You must choose a credit card type.');
	document.Order_Form.creditCardType.focus();
	return false
	}
	if (document.Order_Form.ExpirationDate.value == "Undeclared") {
	alert('You must give an expiration date on the credit card');
	document.Order_Form.ExpirationDate.focus();
	return false
	}
	if (document.Order_Form.NameOnCreditCard.value == "") {
	alert("You must have a name on the credit card.  Please give the name, exactly as it appears on the credit card.");
	document.Order_Form.NameOnCreditCard.focus();
	return false
	}
	if (document.Order_Form.BillingAddress1.value == "") {
	alert('What is the address to which the statement of the credit card is sent?');
	document.Order_Form.BillingAddress1.focus();
	return false
	}
	if (document.Order_Form.BillingAddressCity.value == "") {
	alert('What is the city to which the statement of the credit card is sent?');
	document.Order_Form.BillingAddressCity.focus();
	return false
	}

	if (document.Order_Form.BillingAddressState.value == "") {
	alert('What is the state to which the statement of the credit card is sent?');
	document.Order_Form.BillingAddressState.focus();
	return false
	}

	if (document.Order_Form.BillingAddressZipcode.value == "") {
	alert('What is the zipcode to which the statement of the credit card is sent?') 
	document.Order_Form.BillingAddressZipcode.focus();
	return false
	}
	if (document.Order_Form.DaytimeTelephone.value == "") {
	alert('You need to provide a telephone number in case there are any problems with this form.');
	document.Order_Form.DaytimeTelephone.focus();
	return false
	}
	if (document.Order_Form.creditCardType.value == "AE") {
		if(document.Order_Form.CreditCardNumber.value.length == "15") {return}
		if(document.Order_Form.CreditCardNumber.value.length == "17") {return}
		alert('You have the wrong number of digits in the credit card number.  For an American Express Card, please put your number in the form xxxx yyyyyy zzzzz.');
		document.Order_Form.CreditCardNumber.focus();
		return false
	}
	if (document.Order_Form.creditCardType.value == "Discover") {
		if(document.Order_Form.CreditCardNumber.value.length == "16") {return}
		if(document.Order_Form.CreditCardNumber.value.length == "19") {return}
		alert('You have the wrong number of digits in the credit card number.  For a Discover Card, please put your number in the form xxxx yyyy zzzz wwww.');
		document.Order_Form.CreditCardNumber.focus();
		return false
	}
		if (document.Order_Form.creditCardType.value == "Mastercard") {
		if(document.Order_Form.CreditCardNumber.value.length == "16") {return}
		if(document.Order_Form.CreditCardNumber.value.length == "19") {return}
		alert('You have the wrong number of digits in the credit card number.  For a Mastercard, please put your number in the form xxxx yyyy zzzz wwww.');
		document.Order_Form.CreditCardNumber.focus();
		return false
	}
		if (document.Order_Form.creditCardType.value == "Visa") {
		if(document.Order_Form.CreditCardNumber.value.length == "16") {return}
		if(document.Order_Form.CreditCardNumber.value.length == "19") {return}
		alert('You have the wrong number of digits in the credit card number.  For a Visa Card, please put your number in the form xxxx yyyy zzzz wwww.');
		document.Order_Form.CreditCardNumber.focus();
		return false
	}
}