// JavaScript Document


function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("Name", "FName", "LName", "Address", "City", "State", "Zip", "ContactPhoneNum", "YourComments", "TheApproxHour", "TheApproxMin", "AMPM", "TheMonth", "TheDate", "TheYear", "LanscapingDescription", "TheLocation", "CertificateNo", "EmailAddress", "Wasted", "ViolationNature");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Please enter your NAME", "Your FIRST NAME", "Your LAST NAME", "The STREET ADDRESS", "The CITY", "The STATE", "The ZIP", "Your contact Phone Number", "Your Comments", "The approximate violation HOUR", "The aproximate MINUTE", "Was it AM or PM", "The MONTH", "The DATE", "The year", "Landscape-location description", "Was it a RESIDENCE or BUSINESS location", "Your Certificate No", "Your email address", "Type of Water Wasted", "Please briefly describe the nature of the violation");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}




//* ================email validation===================================== *//
	

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}

//* ================email validation===================================== *//
