// JavaScript Document
// Perform form validation

// function to process the form
function checkInput(form){
    var n, e, dumb;
    n=document.forms[0].Name.value;
    if (n==''){
        alert("Name is mandatory");
        return false;
    }
    e=document.forms[0].Email.value;
    if (e==''){
        alert("Email address is mandatory");
        return false;
    } 
    if (! isValidEmail(e)) {
        alert("Email address is invalid");
	    return false;
	}
    dumb=document.forms[0].airbedname.value;
    if (dumb=='') {
        // nothing here, which is good.
    } else {
        alert("You've triggered a spam detection rule. Please ensure you have followed ALL onscreen instructions.");
        return false;
    }
    return true;
}

// function to check valid email address
function isValidEmail(strEmail){
    validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
      return false;
    }
    return true;
}

