function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
function echeck(str)
{
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1)
{
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
if (str.indexOf(at,(lat+1))!=-1){
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
if (str.indexOf(dot,(lat+2))==-1){
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
if (str.indexOf(" ")!=-1){
alert("The email address you supplied appears to be invalid, please enter a valid email address to continue.")
return false
}
 return true					
}
function checkEntry(theForm)
{
if (trim(theForm.contactName.value) == "")
{
alert("You must supply your name.");
theForm.contactName.focus();
return false;
}
else if (trim(theForm.contactEmail.value) == "")
{
alert("You must enter your email address for us to reply to.");
theForm.contactEmail.focus();
return false;
}
else if (echeck(theForm.contactEmail.value)==false)
{
theForm.contactEmail.value="";
theForm.contactEmail.focus();
return false;
}
else if (trim(theForm.enquiry.value) == "")
{
alert("You cannot submit a blank enquiry.");
theForm.enquiry.focus();
return false;
}
return true;
}
