function validate_contact_form(){
	// From
	if ( isempty( document.contact_form.name)) {
		document.contact_form.name.focus();
		alert("Please enter a value in the NAME field before submiting your inquiry.");
		return false;
	}
	
	if ( isempty( document.contact_form.email)) {
		document.contact_form.email.focus();
		alert("Please enter a value in the EMAIL field before submiting your inquiry.");
		return false;
	}
	if ( !checkemail( document.contact_form.email )) {
		document.contact_form.email.focus();
		return false;
	} 
}

function validate_send_page_form(){
	if ( isempty( document.send_page_form.to_name)) {
		document.send_page_form.to_name.focus();
		alert("Please enter a To Name before sending your message.");
		return false;
	}
	if ( isempty( document.send_page_form.to_email)) {
		document.send_page_form.to_email.focus();
		alert("Please enter a To Email before sending your message.");
		return false;
	}
	if ( !checkemail( document.send_page_form.to_email )) {
		document.send_page_form.to_email.focus();
		return false;
	} 
	
	if ( isempty( document.send_page_form.from_name)) {
		document.send_page_form.from_name.focus();
		alert("Please enter a Your Name before sending your message.");
		return false;
	}
	if ( isempty( document.send_page_form.from_email)) {
		document.send_page_form.from_email.focus();
		alert("Please enter a Your Email before sending your message.");
		return false;
	}
	if ( !checkemail( document.send_page_form.from_email )) {
		document.send_page_form.from_email.focus();
		return false;
	} 
}
//Order Form Validation accessory_detail.html--------------------------------------------------------------------
function validate_add_to_cart_form(){
	// From
	if ( isempty( document.add_to_cart_form.quantity)) {
		document.add_to_cart_form.quantity.focus();
		alert("Please enter an integer value in the quantity field (i.e 1,2,3,etc ) before adding item to cart.");
		return false;
	}
	
}

//Order Form Validation checkout.html----------------------------------------------------------------------------

function validate_get_customer_info_form(){
	// From
	if ( isempty( document.get_customer_info_form.username)) {
		document.get_customer_info_form.username.focus();
		alert("Please enter an integer value in the Username field before retrieveing customer info.");
		return false;
	}
	
	if ( isempty( document.get_customer_info_form.password)) {
		document.get_customer_info_form.password.focus();
		alert("Please enter an integer value in the Password field before retrieveing customer info.");
		return false;
	}
	
}

function validate_order_form(){
 
   //contact first name 
   if ( isempty( document.order_form.first_name )) {
		document.order_form.first_name.focus();
		alert("Please enter a value in the \"Contact Information First Name\" field.");
		return false;} 	
   //contact last name 
   if ( isempty( document.order_form.last_name )) {
		document.order_form.last_name.focus();
		alert("Please enter a value in the \"Contact Information Last Name\" field.");
		return false;} 
   //contact address 
   if ( isempty( document.order_form.address )) {
		document.order_form.address.focus();
		alert("Please enter a value in the \"Contact Information Address\" field.");
		return false;} 
   //contact city 
   if ( isempty( document.order_form.city )) {
		document.order_form.city.focus();
		alert("Please enter a value in the \"Contact Information City\" field.");
		return false;}
   //contact state 
   if ( isempty( document.order_form.state )) {
		document.order_form.state.focus();
		alert("Please enter a value in the \"Contact Information State\" field.");
		return false;}
	 //contact state 
   if ( isempty( document.order_form.country )) {
		document.order_form.country.focus();
		alert("Please enter a value in the \"Contact Information Country\" field.");
		return false;}
   //contact zip 
   if ( isempty( document.order_form.zip )) {
		document.order_form.zip.focus();
		alert("Please enter a value in the \"Contact Information Postal Code\" field.");
		return false;} 
   //contact phone
   //if ( isphonenumber( document.order_form.phone )) {
	//	document.order_form.phone.focus();
	//	alert("Please enter a valid Phone Number of the form 406-327-9925 in the \"Contact Information Phone Number\" field.");
	//	return false;} 
  
  //contact email not empty 
   if ( isempty( document.order_form.email )) {
		document.order_form.email.focus();
		alert("Please enter a value in the \"Contact Information Email\" field.");
		return false;}
   //contact email
   if ( !checkemail( document.order_form.email )) {
		document.order_form.email.focus();
		return false;} 
   
   //-------------------------------------------shipping----------------------------------------------------
   //shipping name 
   if ( isempty( document.order_form.ship_first_name )) {
		document.order_form.ship_first_name.focus();
		alert("Please enter a value in the \"Ship To First Name\" field.");
		return false;}
   //shipping name 
   if ( isempty( document.order_form.ship_last_name )) {
		document.order_form.ship_last_name.focus();
		alert("Please enter a value in the \"Ship To Last Name\" field.");
		return false;} 
   //Shipping address 
   if ( isempty( document.order_form.ship_address )) {
		document.order_form.ship_address.focus();
		alert("Please enter a value in the \"Ship To Address\" field.");
		return false;} 
   //contact city 
   if ( isempty( document.order_form.ship_city )) {
		document.order_form.ship_city.focus();
		alert("Please enter a value in the \"Ship To City\" field.");
		return false;}
   //contact state 
   if ( isempty( document.order_form.ship_state )) {
		document.order_form.ship_state.focus();
		alert("Please enter a value in the \"Ship To State\" field.");
		return false;}
	 //contact state 
   if ( isempty( document.order_form.ship_country)) {
		document.order_form.ship_country.focus();
		alert("Please enter a value in the \"Ship To Country\" field.");
		return false;}
   //contact zip 
   if ( isempty( document.order_form.ship_zip )) {
		document.order_form.ship_zip.focus();
		alert("Please enter a value in the \"Ship To Postal Cod\" field.");
		return false;} 
		
   //-------------------------------------------------Credit Card----------------------------------------------------
   
   
   if (document.order_form.cc_type.value != 'check' || document.order_form.cc_type.value != 'moneyorder' ){
	 //Credit Card Name 
     if ( isempty( document.order_form.cc_name)) {
		document.order_form.cc_name.focus();
		alert("Please enter a value in the \"Credit Card Information Name\" field.");
		return false;
	 }
	 //Credit Card number and cvv cant be submited empty 
	 if ( isempty( document.order_form.cc_number)) {
		document.order_form.cc_number.focus();
		alert("Please enter a value in the \"Credit Card Number\" field.");
		return false;
	 }
	 //Credit Card CVV 
     //if ( isempty( document.order_form.cc_cvv_code)) {
	 //	document.order_form.cc_cvv_code.focus();
	 //	alert("Please enter a value in the \"Credit Card CVV Code\" field.");
	 //	return false;}
   }
  
 
   
	//-------------------------------------------------User Information---------------------------------------------
 	//Username 
    /*
	if ( isempty( document.order_form.user_name)) {
		document.order_form.user_name.focus();
		alert("Please enter a value in the \"User Information USERNAME\" field.");
		return false;}
	//Password	
	if ( ispassword( document.order_form.password)) {
		document.order_form.password.focus();
		alert("Please enter a password that is at least 6 digits long  and includes numbers and letters in the \"PASSWORD\" field before proceeding.");
		return false;
	}
	
	if ( isequal( document.order_form.password,document.order_form.confirm_password)) {
		document.order_form.password.focus();
		alert("Your PASSWORD and CONFIRM PASSWORD do not match please renter before proceeding to checkout.");
		return false;
	}
	//Answer
    if ( isempty( document.order_form.answer)) {
		document.order_form.answer.focus();
		alert("Please enter a value in the \"User Information ANSWER\" field.");
		return false;}
	*/
}

function payment_type(){
 //if its not a check
 if (document.order_form.cc_type.value == 'check' || document.order_form.cc_type.value == 'moneyorder' ){
		document.order_form.cc_name.value = 'not applicable';
		document.order_form.cc_name.disabled = true;
		document.order_form.cc_number.value = 'not applicable';
		document.order_form.cc_number.disabled = true;
		document.order_form.cc_cvv_code.value = 'not applicable';
		document.order_form.cc_cvv_code.disabled = true;
 }	
 else{
	 document.order_form.cc_name.disabled = false;
	 document.order_form.cc_name.value = '';

	 document.order_form.cc_number.disabled = false;
	 document.order_form.cc_number.value = '';

	 document.order_form.cc_cvv_code.disabled = false;
	 document.order_form.cc_cvv_code.value = '';

 }
}// end payment type

//Order Form Validation retrieve_customer_info.html----------------------------------------------------------------------------
function validate_retrieve_customer_info_form(){
	//contact email not empty 
   if ( isempty( document.retrieve_customer_info_form.email )) {
		document.retrieve_customer_info_form.email.focus();
		alert("Please enter a value in the \"Contact Information Email\" field.");
		return false;}
   //contact email
   if ( !checkemail( document.retrieve_customer_info_form.email )) {
		document.retrieve_customer_info_form.email.focus();
		return false;} 
}


function autoFillForm( theForm ){
	if( confirm("Do You Want to AutoFill the " + theForm.id + "?")){	
    	var debug = new Array();
		debug['first_name']="Rick";
		debug['last_name']="Davenger";
		debug['address']= "319 University";
		debug['city']= "Missoula";
		debug['address_2']= "apt1";
		debug['state']= "Montana";
		debug['country']= "USA";
		debug['zip']= "59801";
		debug['phone']= "1-406-222-2221";
		debug['email']= "bobo@bob.com";
		debug['cc_name']= "Dustin";
		debug['cc_number']= "1234123412341234";
		debug['cc_cvv_code']= "123";
		debug['ship_first_name']= "Rick";
		debug['ship_last_name']= "Davenger";
		debug['ship_address']= "2301 ricksj";
		debug['ship_address_2']= "apt 12";
		debug['ship_city']= "Missoula";
		debug['ship_state']= "Montana";
		debug['ship_country']= "USA";
		debug['ship_zip']= "59801";
		var inputElements = theForm.elements.length;
		for( var i = 0; i < inputElements; i++){
			if( debug[ theForm.elements[i].name ] ){
				theForm.elements[i].value = debug[ theForm.elements[i].name ];
			}
		} //end of for
	}//end of if( confirm )
}// end of function
