function validateFormOnSubmit(theForm) {
var reason = "";
	reason += validateEmail(theForm.email);
      
  if (reason != "") {
	  
	  
    $('#errorli').show('fast');
	$('#errorul').html("").html(reason);
   // alert("Some fields need correction:\n" + reason);
    return false;
  }
  //alert("All fields are filled correctly");
 // return false;
}



function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with #474748space trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = '#a4c3d7';
        error = "<li>Please Enter your Email Address.</li>";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#a4c3d7';
        error = "<li>Please check that the email address is correctly formed.</li>";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#a4c3d7';
        error = "<li>The email address contains illegal characters.</li>";
    } else {
        fld.style.background = '#a4c3d7';
    }
    return error;
}


