// JavaScript Document
function ValidateForm(theForm) 
		{
				var reason = "";
				
				reason += validateField(theForm.name, "SHIP TO NAME");
				reason += validateField(theForm.add1, "ADDRESS");
				reason += validateField(theForm.city, "CITY");
				reason += validateField(theForm.st, "STATE");
				reason += validateField(theForm.zip, "ZIP CODE");
				
				
				if (theForm.shipvia.selectedIndex == 0) {
					//reason += "SELECT A SHIPPING METHOD" + "\n";
					//theForm.shipvia.style.background = 'Yellow';
				} else {
					//theForm.shipvia.style.background = 'White';
				}
				
					if (reason != "") {
    					alert("These fields need values:\n" + reason);
    					return false;
  					}
			document.getElementById('submit').style.visibility='hidden';
			document.getElementById('pricelist_loading').style.visibility='visible';
  			return true;
		}
		
function ValidateFormCC(theForm) 
		{
				var reason = "";
				reason += validateField(theForm.name, "SHIP TO NAME");
				reason += validateField(theForm.add1, "ADDRESS");
				reason += validateField(theForm.city, "CITY");
				reason += validateField(theForm.st, "STATE");
				reason += validateField(theForm.zip, "ZIP CODE");
				reason += validateField(theForm.ccname, "NAME ON CREDIT CARD");
				reason += validateField(theForm.ccnum, "CREDIT CARD NUMBER");
				reason += validateField(theForm.ccexp, "CREDIT CARD EXPIRATION");
				reason += validateField(theForm.cccode, "CREDIT CARD CVV2");
				
				
				if (theForm.shipvia.selectedIndex == 0) {
					//reason += "SELECT A SHIPPING METHOD" + "\n";
					//theForm.shipvia.style.background = 'Yellow';
				} else {
					//theForm.shipvia.style.background = 'White';
				}
				
					if (reason != "") {
    					alert("These fields need values:\n" + reason);
    					return false;
  					}
			document.getElementById('submit').style.visibility='hidden';
			document.getElementById('pricelist_loading').style.visibility='visible';
  			return true;
		}
		
function ValidateRegForm(theForm) 
		{
				var reason = "";
				
				reason += validateField(theForm.name, "YOUR NAME");
				reason += validateField(theForm.email, "YOUR EMAIL");
				reason += validateField(theForm.pass1, "PASSWORD");
				/* reason += checkPass(theForm.pass1, theForm.pass2); */
				reason += validateField(theForm.company, "YOUR COMPANY");
				reason += validateField(theForm.st, "STATE");
				reason += validateField(theForm.zip, "ZIP CODE");
				reason += validateField(theForm.phone1, "PHONE");
				reason += validateField(theForm.phone2, "PHONE");
				reason += validateField(theForm.phone3, "PHONE");
				
				
				if (theForm.bus_type.selectedIndex == 0) {
					reason += "AREA OF BUSINESS" + "\n";
					theForm.bus_type.style.background = 'Yellow';
				} else {
					theForm.bus_type.style.background = 'White';
				}
				
					if (reason != "") {
    					alert("These fields need values:\n" + reason);
    					return false;
  					}

  			return true;
		}
		
function checkPass(fld, fld2) 
{
    var error = "";
 
    if (fld != fld2) {
        fld.style.background = 'Yellow';
		fld2.style.background = 'Yellow';
        error = 'PASSWORDS DO NOT MATCH' + "\n";
    } else {
        fld.style.background = 'White';
    }
    return error;  
}
		
function formatNumber(formField) {
			var num = formField.value;
			var fnum = num.replace(/ /g, "");
			fnum = fnum.replace(/-/g, "");
			fnum = fnum.replace(/\//g, "");
			

			formField.value = fnum;
		}

		
function validateField(fld, fieldName) 
{
    var error = "";
	var name = fieldName;
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = name + "\n";
    } else {
        fld.style.background = 'White';
    }
    return error;  
}


