// Javascript by Alexander Nietzen M... alex@webeditors.com
// Open Source

// validate the form area to make sure that they fill out all fields.
function VALIDATE_FORM_FIELDS() {
// Check for Required Fields

//make sure first name is more then just a space
if (document.validate.name.value.replace(/ /g,"") == "") {
        alert("Required Information is Missing \n Please enter your Name");
        document.validate.name.focus();
        return false;
}


//make sure that the person picked a subject
else if (document.validate.subject.value.replace(/ /g,"") == "") {
        alert("Required Information is Missing \n   Please select a Subject");
        document.validate.subject.focus();
        return false;
}


//make sure day phone is more then just a space
else if (document.validate.phone.value.replace(/ /g,"") == "") {
        alert("Required Information is Missing \n Please enter your Phone Number");
        document.validate.phone.focus();
        return false;
}

//lets make sure the required email address field is even filled out first
else if (document.validate.email.value.replace(/ /g,"") == "") {
        alert("Required Information is Missing \n Please enter your Email Address");
        document.validate.email.focus();
        return false;
}


//check to make sure they selected a radio
//else if (document.validate.payment[0].checked == false && document.validate.payment[1].checked == false && document.validate.payment[2].checked == false && document.validate.payment[3].checked == false) {
//    alert(" Error: \n You didn't select a Payment Type\n Please select one");
//    document.validate.payment[0].focus();
//	if (window.scrollBy) window.scrollBy(0,-30);
//    return false;
//}

// lets define the valid e-mail address
    var email_pattern = /^[\w\-_\.]+@[\w\-\.]+\.[a-z]{2,7}$/i;
// checks for a word charachter or '-' one or more times followed by an '@' followed by [a-z] [A-Z] or [0-9] or '-' one or more times followed by a "." followed by a word character or "." one for more times.
    var email_result;
    email_result = email_pattern.exec(document.validate.email.value);
if (email_result) {
         // good to go!
         }
         else  {
         alert("Bad E-mail address! \n   Please try again.");
            document.validate.email.focus();
            return false;
      }
	  
	  
	return true;

}//close function
// WWW: http://www.mattkruse.com/
// Function to auto-tab phone field
// -------------------------------------------------------------------
//alert(document.validate.);

//-->


