function ltrim ( s )
{
	return s.replace( /^\s*/, "" );
}
function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}
function trim ( s )
{
	return rtrim(ltrim(s));
}
function checkForm() {
    var formErrors = "These empty fields prevented your submission.  Please supply:\r\n";
    var failFields = 0;
    var docRef = document.advertiseForm;

    if (trim(docRef.name.value) == "") {
        formErrors += "*Your Name\n";
        failFields = 1;
    }
    if (trim(docRef.coy.value) == "") {
        formErrors += "*Your Company name\n";
        failFields = 1;
    }
    if (trim(docRef.contact.value) == "") {
        formErrors += "*Your Contact number\n";
        failFields = 1;
    }
    if (trim(docRef.enquiry.value) == "") {
        formErrors += "*Your Enquiry\n";
        failFields = 1;
    }

    if (trim(docRef.email_addr.value) == "") {
        formErrors += "* Your e-mail address\n";
        failFields = 1;
    }
    else {       
     ATTR_RE= /^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*[.][a-zA-Z]{2,3}$/gi;
     if (!ATTR_RE.test(docRef.email_addr.value)) {
          formErrors += "* A valid e-mail address\n";
          failFields = 1;   
     }
    }

    if (failFields == 1) {
        alert(formErrors);
        return false;
    } else {
        //var browserversion = navigator.appVersion;
        //var browsername = navigator.appName;
        //document.helpForm.browser.value = browsername + " " + browserversion;
        //docRef.submit();
        return true;
    }
}