
// Estimating Form

function estform() {
pge=document.estimate;

    // make sure they enter their name
  if (pge.cust.value.length == 0)
    {
    alert("Please enter your business/customer name.");
    pge.cust.focus();
    return false;
    }

  // make sure they enter their surname
  if (pge.cont.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.cont.focus();
    return false;
    }

  //check telephone
  if (pge.tel.value == "") {
    alert("Please enter a contact telephone number");
    pge.tel.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;
    }

    //check ref no
  if (pge.ref.value == "") {
    alert("Please enter a job reference number");
    pge.ref.focus();
    return false;
     }

   //check qoute quantity
  if (pge.quant1.value == "") {
    alert("You haven't entered a quantity for us to quote on.");
    pge.quant1.focus();
    return false;
     }


  // If we made it to here, everything's valid, so return true
  disableButton("pge.button");
  pge.submit();
  }




  // Enquiy Form





function checkMail() {
pge=document.enquiry;



  // make sure they enter their name
  if (pge.client.value.length == 0)
    {
    alert("Please enter a contact / business name.");
    pge.client.focus();
    return false;
    }

  // make sure they enter their telephone no
  if (pge.tel.value.length == 0)
    {
    alert("Please enter a contact number.");
    pge.tel.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 a message
  if (pge.msg.value == "")
    {
    alert("Please enter a message.");
    pge.msg.focus();
    return false;
    }


  // If we made it to here, everything's valid, so return true
  disableButton("pge.button");
  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
}

// Button Disabler


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';
  }
}