

function checkForm(form) {
var theFocus = "";
var error = "0";
var warning = "The following required field(s) are empty or have errors:\n";
var emailFlag = "0";
// btw moved indexes down by one for upgrade to 40
// put form fields into variables
//var email = "" + form.elements[17].value;
//var Subject = "" + form.elements[19].value;
// corrected form field index values
// adolfo 06/29/00
//var email = "" + form.elements[18].value;
//var Subject = "" + form.elements[20].value;
// jwong 07/17/00  - index changed for email and subject.
var findLocation = "" + form.findlocation.value;
var email = "" + form.email.value;
var Subject = "" + form.subject.value;
var thefname = "" + form.fname.value;
var thelname = "" + form.lname.value;
var Message = "" + form.message.value;
if (findLocation == "false")
{
	var topic = "" + form.topic.value;
}


	if (form.emailTo){
		if((form.elements[0].checked == false) && (form.elements[1].checked == false) && (form.elements[2].checked == false)){
			warning += "     -Department you would like to contact\n";
			error = "1";
			if (theFocus == "") {
				theFocus = "0";
				}
		}
}

//Check for Empty Email Field
    if (email == ""){
        emailFlag = "1";
    }
    else {
//Check for @
        if (email.indexOf("@") == -1) {
            emailFlag = "1";
        }
//Check for .
        else if (email.indexOf(".") == -1) {
            emailFlag = "1";
        }
//Check for only valid charachters a-z A-Z @ . 0-9 - _
        else {
            for(var i = 0; i < email.length; i++){
                ch = email.substring(i, i + 1)
                if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == "@") || (ch == ".") || (ch == "_") || (ch == "-") || (ch >= "0" && ch <= "9")) {
                    error = error;
                }
                else{
                    emailFlag = "1";
                }
            }
        }
    }

	//Check for empty subject field
    if (thefname == ""){		
        warning += "     -First Name\n";
        error = "1";
        if (theFocus == "") {
            theFocus = "0";
        }
    }

	//Check for empty subject field
    if (thelname == ""){
        warning += "     -Last Name\n";
        error = "1";
        if (theFocus == "") {
            theFocus = "1";
        }
    }

//Check for Email Error
    if (emailFlag == "1"){
        warning += "     -E-mail Address\n";
        error ="1";
        if (theFocus == ""){
            theFocus = "2";
        }
    }

//Check for empty subject field
    if (Subject == ""){
        warning += "     -Subject\n";
        error = "1";
        if (theFocus == "") {
            theFocus = "3";
        }
    }

if (findLocation == "false")
{
//Check for empty subject field
    if (topic == ""){
        warning += "     -Topic\n";
        error = "1";
        if (theFocus == "") {
            theFocus = "4";
        }
    }
}


 //Check for empty message field
    if (Message == ""){
        warning += "     -Message\n";
        error = "1";
        if (theFocus == "") {
            theFocus = "5";
        }
    }

    warning += "\n\nPlease correct these error(s).\n\n"
// Alert If a Form Field is empty and set the focus to the first empty form field
    if (error == "1"){
        form[theFocus].focus();
        alert(warning);
        return false;
        }
     else {
        return true;
        }
}