<!--
//global variable for error flag
var errfound = false;

//function to validate by length
function ValidLength(item, len) {
   return (item.length >= len);
}

//function to validate an email address
function ValidEmail(item) {
   if (!ValidLength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   return true;
}

// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}

// main validation function
function Validate() {
   errfound = false;
   if (!ValidLength(document.order.name.value,6))
      error(document.order.name,"Invalid Name, at least 6 characters");
   if (!ValidLength(document.order.phone.value,6))
      error(document.order.phone,"Invalid Phone");
   if (!ValidLength(document.order.address.value,4))
      error(document.order.address,"Invalid Address");
   if (!ValidEmail(document.order.email.value))
      error(document.order.email, "Invalid Email Address");
   if (!errfound)
          document.order.submit();
}


//-->
