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 checkForm(theForm)
{
if (trim(theForm.frmName.value) == "")
{
alert("You must enter a contact name.");
theForm.frmName.focus();
return false;
}
else if (trim(theForm.frmEnquiry.value) == "")
{
alert("You must enter a query.");
theForm.frmEnquiry.focus();
return false;
}
else if (trim(theForm.frmEmail.value) == "")
{
alert("You must enter your email address.");
theForm.frmEmail.focus();
return false;
}
else if (echeck(theForm.frmEmail.value)==false)
{
theForm.frmEmail.value="";
theForm.frmEmail.focus();
return false;
}
else if (document.frm1.contactMethod[1].checked && trim(document.frm1.frmPhone.value) == "")
{
alert("You chose phone as you preferred contact method but didn't supply a telephone number for us to contact you on.");
document.frm1.frmPhone.focus();
return false;
}
return true;
}
function updateChars()
{
document.frm1.charsLeft.value = 1024 - document.frm1.frmEnquiry.value.length + " chars left."
if (1024 - document.frm1.frmEnquiry.value.length < 0)
{
document.frm1.frmEnquiry.value = document.frm1.frmEnquiry.value.substr(0,1024);
document.frm1.charsLeft.value = "0 chars left."
}
}
function getOut()
{
document.frm1.frmEnquiry.focus();
}
function rollOver(theButton)
{
theButton.src='images/sendOver.jpg';
}
function rollOut(theButton)
{
theButton.src='images/send.jpg';
}