/* Switzerland Old World Gifts JavaScript Form Validation Document  
*******************************************
*  Created by Parker of Aniglyphics Media *
*  mparker@aniglyphics.com 				  *
*  06/27/2006							  *
*******************************************
*/

//--> Start Contact Form //
function validateContact()
{
	if (!document.contact_form.Name.value)
	{
		alert("Please Enter Your Name!");
		document.contact_form.Name.focus();
		return false;
	}
	if (!document.contact_form.Address_1.value)
	{
		alert("Please Enter Your Address!");
		document.contact_form.Address_1.focus();
		return false;
	}
	if (!document.contact_form.Telephone_Number.value)
	{
		alert("Please Enter Your Telephone Number!");
		document.contact_form.Telephone_Number.focus();
		return false;
	}
	if ((document.contact_form.Email_Address.value.indexOf('@') == -1) || (document.contact_form.Email_Address.value.indexOf('.') == -1))
	{
		alert("Please Enter a Valid Email Address!");
		document.contact_form.Email_Address.focus();
		return false;
	}
	if (!document.contact_form.Questions_or_Comments.value)
	{
		alert("Please Provide Us With Some Information About Your Inquiry!");
		document.contact_form.details.focus();
		return false;
	}
	return true;		
}
// END Contact Form <--//

//--> Start Login Form //
function validateLogin()
{
	if (!document.login_form.username.value)
	{
		alert("Please Enter A Valid Username!");
		document.login_form.username.focus();
		return false;
	}
	if (!document.login_form.password.value)
	{
		alert("Please Enter A Valid Password!");
		document.login_form.password.focus();
		return false;
	}
	return true;		
}
// END Login Form <--//

//--> START Shopping Cart Advance //
function validateCartAdvance(){	
	if (!document.cart.ship_method_rates)
	{
		alert("You Must Have Products in Your Shopping Cart and Select A Shipping Method to Check Out!");
	}
	if (document.cart.ship_method_rates.value == '')
	{
		alert("Please Select A Shipping Method!");
		document.cart.ship_method_rates.focus();
	} else 
		if (document.cart.ship_method_rates.value == 'Change')
	{
		alert("Please Select A Shipping Method!");
		document.cart.ship_method_rates.focus();
	} else {
		window.location.href = "checkout-login.php";
	}
}
// END Shopping Cart Advance <--//


//--> START Checkout /
function validateCheckout(newUser){

	var email_input_one = document.checkout.emailAdd.value;
	var email_input_two = document.checkout.emailAdd_two.value;
	var email_one = (email_input_one.replace(/^\W+/,'')).replace(/\W+$/,'');
	var email_two = (email_input_two.replace(/^\W+/,'')).replace(/\W+$/,'');
	
	if (document.checkout.bill_f_name.value == '')
	{
		alert("Please Enter Your Billing First Name!");
		document.checkout.bill_f_name.focus();
		return false;
	}
	if (document.checkout.bill_l_name.value == '')
	{
		alert("Please Enter Your Billing Last Name!");
		document.checkout.bill_l_name.focus();
		return false;
	}
	if (document.checkout.bill_address1.value == '')
	{
		alert("Please Enter Your Billing Address!");
		document.checkout.bill_address1.focus();
		return false;
	}
	if (document.checkout.bill_city.value == '')
	{
		alert("Please Enter Billing Your City!");
		document.checkout.bill_city.focus();
		return false;
	}
	if (document.checkout.bill_state.value == '')
	{
		alert("Please Enter Billing Your State!");
		document.checkout.bill_state.focus();
		return false;
	}
	if (document.checkout.bill_zip.value == '')
	{
		alert("Please Enter Your Billing Zip / Postal Code!");
		document.checkout.bill_zip.focus();
		return false;
	}
	if (document.checkout.bill_tphone.value == '')
	{
		alert("Please Completely Fill Out Your Billing Telephone Number!");
		document.checkout.bill_tphone1.focus();
		return false;
	}	
	if ((document.checkout.emailAdd.value.indexOf('@') == -1) || (document.checkout.emailAdd.value.indexOf('.') == -1))
	{
		alert("Please Enter A Valid Email Address!");
		document.checkout.emailAdd_two.value = '';
		document.checkout.emailAdd.focus();
		return false;
	}
	if (email_one != email_two)
	{
		alert("The Email Addresses Entered do not match! Please enter them again!");
		document.checkout.emailAdd_two.value = '';
		document.checkout.emailAdd.select;
		return false;		
	}	
	
	<!-- START NEW USER -->
	
	if (newUser == 1) {
		if (document.checkout.username.value.length < 4 || document.checkout.username.value.length > 12) 
		{
			alert("Please Select a Username between 4 and 12 Characters in Length!");
			document.checkout.username.focus();
			return false;
		}
		if (document.checkout.password.value.length < 4 ||  document.checkout.username.value.length > 12) 
		{
			alert("Please Select a Password between 4 and 12 Characters in Length!");
			document.checkout.password.focus();
			return false;
		}
		if (document.checkout.password.value !=  document.checkout.cpassword.value) 
		{
			alert("Passwords Do Not Match, Please Enter Them Again!");
			document.checkout.password.value = '';
			document.checkout.cpassword.value = '';
			document.checkout.password.focus();
			return false;
		}
	
	}
	
	<!-- END NEW USER -->
	
	if (!document.checkout.ship_f_name.value)
	{
		alert("Please Enter Your Shipping First Name!");
		document.checkout.ship_f_name.focus();
		return false;
	}
	if (!document.checkout.ship_l_name.value)
	{
		alert("Please Enter Your Shipping Last Name!");
		document.checkout.ship_l_name.focus();
		return false;
	}
	if (!document.checkout.ship_address1.value)
	{
		alert("Please Enter Your Shipping Address!");
		document.checkout.ship_address1.focus();
		return false;
	}
	if (!document.checkout.ship_city.value)
	{
		alert("Please Enter Your Shipping City!");
		document.checkout.ship_city.focus();
		return false;
	}
	if (!document.checkout.ship_state.value)
	{
		alert("Please Enter Your Shipping State!");
		document.checkout.ship_state.focus();
		return false;
	}
	if (!document.checkout.ship_zip.value)
	{
		alert("Please Enter Your Shipping Zip / Postal Code!");
		document.checkout.ship_zip.focus();
		return false;
	}
	if (document.checkout.ship_tphone.value == '')
	{
		alert("Please Completely Fill Out Your Shipping Telephone Number!");
		document.checkout.ship_tphone.focus();
		return false;
	}	
	if (document.checkout.cardType.value == '')
	{
		alert("Please Select A Credit Card Type!");
		document.checkout.cardType.focus();
		return false;
	}
	if (document.checkout.cardNumber.value == '') {
		alert("Please Enter A Credit Card Number!");
		document.checkout.cardNumber.focus();
		return false;
	}
	if (document.checkout.cardCode.value == '') {
		alert("Please Enter The 3 - 4 Digit Credit Card Security Code Number!");
		document.checkout.cardCode.focus();
		return false;
	}
	if (document.checkout.cardExpMonth.value == '') {
		alert("Please Enter The Credit Card Expiration Month!");
		document.checkout.cardExpMonth.focus();
		return false;
	}
	if (document.checkout.cardExpYear.value == '') {
		alert("Please Enter The Credit Card Expiration Year!");
		document.checkout.cardExpYear.focus();
		return false;
	}
	return true;
}
// END Checkout <--//

	