// LOAD 'GENERALVALIDATE.JS' BEFORE
// THIS FILE IN YOUR HTML PAGE

// ERROR CHECK HOLDER FOR FIELD CHECKING FUNCTIONS BELOW
var isOkay = true;

aFieldList = new Array();
aFieldList[0] = "isLetter(document.forms[\"f1\"].name, \"your last name\");"
aFieldList[1] = "isLetter(document.forms[\"f1\"].firstname, \"your first name\");"
aFieldList[2] = "isAlpha(document.forms[\"f1\"].address, \"your address\");"
aFieldList[3] = "isLetter(document.forms[\"f1\"].city, \"your city\");"
aFieldList[4] = "isAlpha(document.forms[\"f1\"].state, \"your state\");"
aFieldList[5] = "isAlpha(document.forms[\"f1\"].zip, \"a valid ZIP code\");"
aFieldList[6] = "isAlpha(document.forms[\"f1\"].country, \"your country\");"
aFieldList[7] = "isAlpha(document.forms[\"f1\"].daytimephone, \"your daytime phone\");"
aFieldList[8] = "isAlpha(document.forms[\"f1\"].email, \"a valid email address\");"
//aFieldList[9] = "isChecked(document.forms[\"f1\"].billing, \"0\", \"a billing method\");"
//aFieldList[9] = "isAlpha(document.forms[\"f1\"].ccname, \"the payment card holder name\");"
//aFieldList[11] = "isDigit(document.forms[\"f1\"].ccnumber, \"a valid payment card number\");"
//aFieldList[12] = "isAlpha(document.forms[\"f1\"].ccexpiration, \"the payment card expiration date\");"


function CheckForm(){

	calc_total();

	if ((qty_sails == 0) && (qty_acc == 0)) {
		alert ("No item has been selected.");
		document.f1.main1.focus();
		return false;
		}
	else
		{
    	iLength = aFieldList.length;
   		 for(i = 0; i < iLength; i++){
      		  if(isOkay){
           	 //alert("i = " + i);
			 
           	 isOkay = eval(aFieldList[i]);
			
        	}
    	}
	}
	
//---------------------------------
// For Sail number order form only

  if(isOkay){
  
	  if (document.f1.boat.value == "Sail Number") {
		  chosen = "";
		  for (i = 0; i <3; i++) {
			if (document.f1.size[i].checked) {
				chosen = document.f1.size[i].value
			}
		  }
	
	
		if (chosen == "") {
			alert("Select sail number size")
			document.f1.size[0].focus();
			return false;
			} 
			
	  }
  }
  
  //---------------------------------
// Block all orders from Australia

  if(isOkay){
  
	  if ((document.f1.country.value == "Australia") || (document.f1.country.value == "australia") || (document.f1.country.value == "AUSTRALIA")) {
		  alert("You must contact North Sails Australia to order your sails.");
		  document.f1.country.focus();
		  return false;
		  }
	
	
	if (document.f1.caller.value != "consig") {
		if ((document.f1.shippingcountry.value == "Australia") || (document.f1.shippingcountry.value == "australia") || (document.f1.shippingcountry.value == "AUSTRALIA")) {
		  alert("You must contact North Sails Australia to order your sails.");
		  document.f1.country.focus();
		  return false;
			}
	}
			
	  
  }
 //---------------------------------
	
   if(isOkay){
	 
		if (document.f1.caller.value == "client") {
	
	 	 CheckCCInformation();
		}
  	 	}
		

   
   if(isOkay){
//        alert("Congratulations!\n\nYou successfully completed the form");
      
        document.forms["f1"].submit();
    } else {
        fax_errors = false;
        isOkay = true;
    }

}
