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();
  }


function validate() {
pge=document.addform;

    // make sure they enter their name
  if (pge.surname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.surname.focus();
    return false;
    }

  // make sure they enter their address(1)
  if (pge.add1.value.length == 0)
    {
    alert("Please enter your address.");
    pge.add1.focus();
    return false;
    }

  // make sure they enter their address(2)
  //if (pge.add2.value.length == 0)
  //  {
  //  alert("Please complete your address.");
  //  pge.add2.focus();
  //  return false;
  //  }

    //check town
  if (pge.town.value == "") {
    alert("Please enter your Town / City");
    pge.town.focus();
    return false;
     }

    //check postcode
  if (pge.pc.value == "") {
    alert("Please enter a Zip / Postcode \n Enter 'None' if you do not one");
    pge.pc.focus();
    return false;
     }

   //check message
  if (pge.tel.value == "") {
    alert("A telephone number is useful.");
    pge.tel.focus();
    return false;
     }

  // check to see if the email's valid
  if (!validEmail(pge.eml.value)) {
    alert("We require a valid email address.");
    pge.eml.focus();
    return false;
    }

  // If we made it to here, everything's valid, so return true
  disableButton("document.addform.button");
  pge.submit();
  }

function validcontact(cde) {
var pge = document.contactus;  

// make sure they enter the secure code
  if (pge.secure.value != cde)
    {
    alert(" Invalid Code.\n Enter the characters as shown in red.");
    pge.secure.focus();
    return false;
    }

  // make sure they enter their name
  if (pge.surname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.surname.focus();
    return false;
    }

  // check to see if the email is valid
  if (!validEmail(pge.email.value)) {
    alert("We require a valid email address.");
    pge.email.focus();
    return false;
    }

  // make sure they enter their telephone
  if (pge.tel.value.length == 0)
    {
    alert("Please enter your telephone no.");
    pge.tel.focus();
    return false;
    }
    
  

  // If we made it to here, everything's valid, so return true
  disableButton("pge.button");
  pge.submit();
  }

function validlink() {
var pge = document.newlink;

  // make sure they enter their name
  if (pge.contact.value.length == 0)  {
    alert("Please enter a contact name.");
    pge.contact.focus();
    return false;
    }

  // check to see if the email is valid
  if (!validEmail(pge.email.value)) {
    alert("We require a valid email address.");
    pge.email.focus();
    return false;
    }

  // make sure they enter their url
  if (pge.url.value.length == 0)  {
    alert("Please enter your URL.");
    pge.url.focus();
    return false;
    }

  // If we made it to here, everything's valid, so return true
  disableButton("pge.button");
  pge.submit();
  }


function checkReg() {
pge=document.register;

  // make sure they enter their name
  if (pge.fname.value.length == 0)
    {
    alert("Please enter a first name.");
    pge.fname.focus();
    return false;
    }
  if (pge.sname.value.length == 0)
      {
      alert("Please enter a last name.");
      pge.sname.focus();
      return false;
    }

  // Address
  if (pge.add1.value.length == 0)
      {
      alert("Please enter an address.");
      pge.add1.focus();
      return false;
    }

  if (pge.town.value.length == 0)
      {
      alert("Please enter a town or city.");
      pge.town.focus();
      return false;
    }

  if (pge.pc.value.length == 0)
      {
      alert("Please enter a zip or postcode.");
      pge.pc.focus();
      return false;
    }

  if (pge.country.value.length == 0)
      {
      alert("Please enter a country.");
      pge.country.focus();
      return false;
    }

  // 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;
    }

  // make sure they enter their telephone
  if ((pge.telH.value.length == 0) && (pge.telM.value.length == 0) && (pge.telW.value.length == 0))
    {
    alert("Please enter at least one telephone no.");
    pge.telH.focus();
    return false;
    }

  // Accomplishments
   if (pge.accomp.value.length == 0)
    {
    alert("Please list your services.");
    pge.accomp.focus();
     return false;
    }

  //Password
   if (pge.pwd.value.length == 0)
	{
	alert("You will need a password to edit your details.");
	pge.pwd.focus();
     return false;
    }

  // If we made it to here, everything's valid, so return true

  pge.submit();
  }




// 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;
    button.value = 'DISABLED';
  } else if (button) {
    button.oldOnClick = button.onclick;
    button.onclick = null;
    button.oldValue = button.value;
    button.value = 'DISABLED';
  }
}