function formValidator()
{
//CustCompany
//CustAddr
//CustAddr2 (US only)
//CustCity (US only)
//CustState (US only)
//CustZip (US only)
//CustName
//CustPhone
//CustEmail
//PurchaseDate
//SerNums

var errMsgs = new Array;
errFld = null;
//DBG
//alert("Begin Validation with errs " + errMsgs.length);

// for testing error, entering "ERROR" in Contact name immediately causes submission
// which should generate an error (if other fields are missing)
if (frm.CustName.value == "ERROR") return true;

CkMinMaxStr(errMsgs,"Serial Number",frm.SerNums,6,250);
if (errMsgs.length == 0) {
	var norm = frm.SerNums.value.replace(/(^\s+)|(\s+$)/g,''); // trim leading and trailing space
	norm = norm.replace(/\s+/g,'/'); // replace internal space with delimiter
//alert('normalized=' + norm);
	if (norm.match(/^\d{6,8}(\/\d{6,8}){0,29}$/)) {
		frm.NormSerNums.value = norm;
		}
	else {
		SetValidErr(errMsgs,frm.SerNums,"Serial Number field must contain exclusively digits as used in valid serial numbers.");
		}
	}
if (frm.PurchaseMon.value.length == 0 ) 
	SetValidErr(errMsgs,frm.PurchaseMon,"Missing Purchase Date.");
else {
	if (frm.PurchaseDay.value.length == 0 ) SetValidErr(errMsgs,frm.PurchaseDay,"Missing Purchase Date.");
	}

CkMinMaxStr(errMsgs,"End-User Company",frm.CustCompany,3,50);
CkMinMaxStr(errMsgs,"End-User Name",frm.CustName,4,50);
CkPhone(errMsgs,true,frm.CustPhone);
CkEmail(errMsgs,true,frm.CustEmail);
if (frm.CustEmail.value != frm.ConfirmCustEmail.value)
{
	SetValidErr(errMsgs,frm.ConfirmCustEmail,"Confirm Email does not match Email.");
}

CkMinStr(errMsgs,"End-User Address",frm.CustAddr,8);
CkMinStr(errMsgs,"End-User City",frm.CustCity,4);
CkMinStr(errMsgs,"End-User State",frm.CustState,2);
CkMinStr(errMsgs,"End-User Zip Code",frm.CustZip,5);

if (frm.OtherIndCk.checked)
{
	CkMinMaxStr(errMsgs,"Other Industry",frm.OtherInd,2,50);
}
else
	CkRadio(errMsgs,"Industry","Industry"); // at least one checked if other not checked

if (frm.OtherAppCk.checked)
{
	CkMinMaxStr(errMsgs,"Other Application",frm.OtherApp,2,50);
}
else
	CkRadio(errMsgs,"Application","Application"); // at least one checked if other not checked


return ProcessErrors(errMsgs);

//DBG
//ProcessErrors(errMsgs);
//alert("Not yet implemented. Page would be submitted at this point.");
//return false;
} // END formValidator

// ************************************************************************
function CkAtLeast(errArr,name,fldname)
{
} // END CkAtLeast

// ************************************************************************
function handlePurchYear() // for onchange
{
SetMonOpt(0,formElem["PurchaseYr"],formElem["PurchaseMon"],formElem["PurchaseDay"]);
} // END handleOrdYear

// ************************************************************************
function handlePurchMon() // for onchange
{
SetDayOpt(0,formElem["PurchaseYr"],formElem["PurchaseMon"],formElem["PurchaseDay"]);
} // END handleOrdMon

function init()
{
// called from window.onload
formInit();
frm.action = "appSubmit.asp";
reqDateInit();
SetYearOpt(0,formElem["PurchaseYr"],formElem["PurchaseMon"],formElem["PurchaseDay"]);

InitStates(formElem["CustState"]);
} // END init

window.onload = init;

