//This file contains JavaScript code for validating the order form data

var name =document.getElementById('name');
var email =document.getElementById('email');
var emailconf =document.getElementById('emailconf');
var phone =document.getElementById('phone');
var billcity =document.getElementById('billcity');
var billstate =document.getElementById('billstate');
var billzip =document.getElementById('billzip');
var shipping1 =document.getElementById('shipping1');
var shipping2 =document.getElementById('shipping2');
var shipcity =document.getElementById('shipcity');
var shipstate =document.getElementById('shipstate');
var shipzip =document.getElementById('shipzip');
var cb1 =document.getElementById('cb1');
var cb2 =document.getElementById('cb2');
var cb3 =document.getElementById('cb3');
var cb4 =document.getElementById('cb4');
var cb5 =document.getElementById('cb5');
var cb6 =document.getElementById('cb6');
var other =document.getElementById('other');
var comments =document.getElementById('comments');

var q4 =document.getElementById('q4');
var q6 =document.getElementById('q6');
var q8 =document.getElementById('q8');
var q10 =document.getElementById('q10');
var matn4 =document.getElementById('matn4');
var matn6 =document.getElementById('matn6');
var matn8 =document.getElementById('matn8');
var matn10 =document.getElementById('matn10');
var matt4 =document.getElementById('matt4');
var matt6 =document.getElementById('matt6');
var matt8 =document.getElementById('matt8');
var matt10 =document.getElementById('matt10');
var mat4 =document.getElementById('mat4');

var fm = document.getElementById('form');
var msg = "";
//validateAll();

function validateAll(){
	var eMsg="";

	eMsg+=valEmail();
	eMsg+=valAddrs();
	eMsg+=valSources();
	eMsg+=valMdse();

	if (eMsg!=""){
		alert(eMsg);
		return false;
	}
	return true;
}
var t="1234";

function valEmail(){
	var msg="";

	if (name.value=="") msg+="* You must provide your name so we can contact you.\n";
	if (phone.value=="") msg+="* You must provide your phone number so we can contact you.\n";
	if (email.value=="") msg+="* Email address is required\n";
	if (email.value!=emailconf.value) msg+="* Email addresses don't agree\n";
	if (email.value.indexOf('@')<0 || email.value.indexOf('.')<0) msg+="* Invalid email address\n";
	return msg;
}

function valAddrs(){
	var msg="";

//	if (billzip.value=="") msg+="* Postal code for billing is required\n";
//	else if (billzip.value.length<5) msg+="* Postal Code for billing is incomplete\n";
	if (shipping1.value=="") msg+="* You must provide your complete shipping address so we can calculate the shipping charges.\n";
	else if (shipcity.value=="") msg+="* You must provide your complete shipping address so we can calculate the shipping charges.\n";
	else if (shipstate.value=="") msg+="* You must provide your complete shipping address so we can calculate the shipping charges.\n";
	else if (shipzip.value=="") msg+="* Postal code for shipping is required\n";
	else if (shipzip.value.length < 5) msg+="* Postal Code for shipping is incomplete\n";
	return msg;
}

function valSources(){
	var msg="";
	if (!(cb1.checked || cb2.checked || cb3.checked || cb4.checked || cb5.checked || cb6.checked)) msg+="* You must check one box for where you saw our ad or type into the 'Other' box\n";
	return msg;
}

function valMdse(){
	var msg="";
	if (!(q4.value>0 || q6.value>0 || q8.value>0 || q10.value>0))
	{
		msg+="* You must select a quantity for at least one size product.\n";
	}
	return msg;
}


