// CHECKS VALIDITY OF NEW MEMBER LOGIN ENTRIES
// REQUIRES LOADING 'GENERALVALIDATE.JS' BEFORE
// THIS FILE IN YOUR CALLING PAGE

var isOkay = true;

aFieldList = new Array();
aFieldList[0] = "isAlpha(document.forms[\"f1\"].Name, \"a Name\");"
aFieldList[1] = "isAny(document.forms[\"f1\"].Phone, \"a Phone Number\");"
aFieldList[2] = "isAlpha(document.forms[\"f1\"].Covered_Location_Address, \"a Covered Location Address\");"
aFieldList[3] = "isDigit(document.forms[\"f1\"].Age_of_Buildings, \"the Building's Age\");"
aFieldList[4] = "isDigit(document.forms[\"f1\"].Building_Square_Feet, \"the Building's Square Feet\");"
aFieldList[5] = "isDigit(document.forms[\"f1\"].Acreage, \"the Acreage\");"
aFieldList[6] = "isDigit(document.forms[\"f1\"].Years_Occupied, \"the years occupied\");"
aFieldList[7] = "isAny(document.forms[\"f1\"].Current_Occupants_and_Operations, \"the Current Occupant's Operations\");"

function CheckForm(){
    iLength = aFieldList.length;
    for(i = 0; i < iLength; i++){
        if(isOkay){
            //alert("i = " + i);
            isOkay = eval(aFieldList[i]);
        }
    }
    if(isOkay){
		CheckPropertyUse();
		if(isOkay){
		    if(document.forms["f1"].Hazardous_Waste[0].checked){
		    	if(document.forms["f1"].Hazardous_Waste_Explaination.value.length < 1){
			    	alert("Please explain the Hazardous Waste");
			    	isOkay = true;
			    	document.forms["f1"].Hazardous_Waste_Explaination.focus();
			    	return false;
		    	}
		    }
	    	if(document.forms["f1"].Previous_Uses.value.length < 1){
		    	alert("Please explain the Previous Uses");
		    	isOkay = true;
		    	document.forms["f1"].Previous_Uses.focus();
		    	return false;
	    	}
		    if(document.forms["f1"].Environmental_Studies[0].checked){
		    	if(document.forms["f1"].Environmental_Studies_Information.value.length < 1){
			    	alert("Please explain the Environmental Studies");
			    	isOkay = true;
			    	document.forms["f1"].Environmental_Studies_Information.focus();
			    	return false;
		    	}
		    }
	    } else {
	        isOkay = true;
	        return false;
	    }
	    document.forms["f1"].submit();
    } else {
        isOkay = true;
        return false;
    }
}

function CheckPropertyUse(){
	if(isOkay){
		isOkay = false;
		var piChecked = "";
		var pilen = document.forms["f1"].Property_Use_Count.value;
		for(pi = 1; pi <= pilen; pi++){
			var pif = "Property_Use_" + pi;
			var pifld = eval("document.forms[\"f1\"]." + pif + ".checked");
			if(pifld){
				isOkay = true;
				//alert(pif + " checked!");
			}
		}	
		if(!isOkay){
			if(document.forms["f1"].Property_Use_5.value.length > 0){
				isOkay = true;
			} else {
				alert("Please select a Property Use [ Office, Industrial, etc. ]");
				isOkay = false;
				document.forms["f1"].Property_Use_1.focus();
				return false;
			}
		}
	}
}



