function mail() {
pge=document.mailer;

  // check to see if the email's valid
  if (!validEmail(pge.email.value)) {
    alert("We require a valid email address.");
    pge.email.focus();
    return false;
    }
  // If we made it to here, everything's valid, so return true
  pge.submit();
  return true;
  }


function validate() {
pge=document.contact;

  // check to see if the email's valid
  if (!validEmail(pge.email2.value)) {
    alert("We require a valid email address.");
    document.mailer.email.focus();
    return false;
    }

    // make sure they enter their name
  if (pge.fname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.fname.focus();
    return false;
    }

  // make sure they enter their surname
  if (pge.surname.value.length == 0)
    {
    alert("Please enter your surname.");
    pge.surname.focus();
    return false;
    }
    
   // make sure they enter a telephone no
   if (pge.tel.value.length < 10)
     {
     alert("We require a contact number with an area code.");
     pge.tel.focus();
     return false;
    }

    //check model
  if (pge.model.value == "") {
    alert("Please tell us the model \nTo help us answer any question");
    pge.model.focus();
    return false;
     }

    //check year
  if (pge.year.value == "") {
    alert("Please tell us the year \nTo help us answer any question");
    pge.year.focus();
    return false;
     }

   //check message
  if (pge.msg.value == "") {
    alert("You haven't written a message.");
    pge.msg.focus();
    return false;
     }



  // If we made it to here, everything's valid, so return true
  disableButton("document.contact.button");
  pge.submit();
  return true;
  }

function check() {
pge=document.client;

  // check to see if the email's valid
  if (!validEmail(pge.email2.value)) {
    alert("We require a valid email address.");
    document.mailer.email.focus();
    return false;
    }

  // make sure they enter their name
  if (pge.fname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.fname.focus();
    return false;
    }

  // make sure they enter their surname
  if (pge.surname.value.length == 0)
    {
    alert("Please enter your surname.");
    pge.surname.focus();
    return false;
    }

   // make sure they enter a telephone no
   if (pge.tel.value.length < 10)
     {
     alert("We require a contact number with an area code.");
     pge.tel.focus();
     return false;
    }


  // make sure they enter their address
  if (pge.add1.value.length == 0)
    {
    alert("Please enter a delivery address.");
    pge.add1.focus();
    return false;
    }

  // make sure they enter their town
  if (pge.town.value.length == 0)
    {
    alert("Please enter a town or city.");
    pge.town.focus();
    return false;
    }

  // make sure they enter their country
  if (pge.country.value.length == 0)
    {
    alert("Please enter a country.");
    pge.country.focus();
    return false;
    }

  // make sure they enter their postcode
  if (pge.pc.value.length == 0)
    {
    alert("Please enter a postcode / zip.");
    pge.pc.focus();
    return false;
    }


    //check model
  if (pge.model.value == "") {
    alert("Please choose the model \nTo help us select the right part");
    pge.model.focus();
    return false;
     }

    //check year
  if (pge.year.value == "") {
    alert("Please choose the year \nTo help us select the right part");
    pge.year.focus();
    return false;
     }

  // If we made it to here, everything's valid, so return true
  pge.submit();
  return true;
  }


// EMail Checker

function validEmail(email) {
  invalidChars = " /:,;"

  if (email == "") {// cannot be empty
    return false;
  }
  for (i=0; i<invalidChars.length; i++) {  // does it contain any invalid characters?
    badChar = invalidChars.charAt(i)
    if (email.indexOf(badChar,0) > -1) {
      return false;
    }
  }
  atPos = email.indexOf("@",1)// there must be one "@" symbol
  if (atPos == -1) {
    return false;
  }
  if (email.indexOf("@",atPos+1) != -1) {  // and only one "@" symbol
    return false;
  }
  periodPos = email.indexOf(".",atPos)
  if (periodPos == -1) {// and at least one "." after the "@"
    return false;
  }
  if (periodPos+3 > email.length) {// must be at least 2 characters after the "."
    return false;
  }
  return true;
}

function disableButton (button) {
  if (document.all || document.getElementById)
    button.disabled = true;
  else if (button) {
    button.oldOnClick = button.onclick;
    button.onclick = null;
    button.oldValue = button.value;
    button.value = 'DISABLED';
  }
}