// JavaScript Document

function validate(){
var why = "";
var show = false;
var feildfocus = false;
boxone=false; boxtwo=false;  boxthree=false; boxfour=false; boxfive=false;
if(document.contactUsForm.name.value == ""){
 why+="Please enter your name\n";
 show = true;
 boxone=true;
}
 if(document.contactUsForm.company.value == ""){
 why+="Please enter the name of your Company\n";
 show = true;
 boxtwo=true;
 }
  if(isEmail(document.contactUsForm.email.value)==false){
 why+="Please enter a valid email address \n";
 show = true;
 boxthree=true;
}
 if(document.contactUsForm.phone.value.length<1 || (CheckPhoneNumber(document.contactUsForm.phone.value)==false)){
 why+=" Please enter a valid phone number\n";
 show = true;
 boxfour=true;
}
 if(document.contactUsForm.enquiry.value == ""){
 why+="Please enter enquiry\n";
 show = true;
 boxfive=true;
}
 if(show){
   alert(why);
   if(boxfive){
   document.contactUsForm.enquiry.focus();}
   if(boxfour){
   document.contactUsForm.phone.focus();}
   if(boxthree){
   document.contactUsForm.email.focus();}
   if(boxtwo){
   document.contactUsForm.company.focus();}
   if(boxone){
   document.contactUsForm.name.focus();}
  return false;
 }
}
function validatecontact(){
var why = "";
var show = false;
var feildfocus = false;
boxone=false; boxthree=false; boxfive=false;
if(document.inquiry_form.name.value == ""){
 why+="Please enter your name\n";
 show = true;
 boxone=true;
}
  if(isEmail(document.inquiry_form.email.value)==false){
 why+="Please enter a valid email address \n";
 show = true;
 boxthree=true;
}
 if(document.inquiry_form.comments.value == ""){
 why+="Please enter comments\n";
 show = true;
 boxfive=true;
}
 if(show){
   alert(why);
   if(boxfive){
   document.inquiry_form.comments.focus();}
   if(boxthree){
   document.inquiry_form.email.focus();}
   if(boxone){
   document.inquiry_form.name.focus();}
  return false;
 }
}

function isEmail( strValue) {
 var objRegExp = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,3}$/i;
 return objRegExp.test(strValue);
}
function CheckPhoneNumber(TheNumber) {
 var valid = 1
 var GoodChars = "0123456789()-+ "
 var i = 0
 if (TheNumber=="") {
 // Return false if number is empty
 valid = 0
 }
 for (i =0; i <= TheNumber.length -1; i++) {
 if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
// Note: Remove the comments from the following line to see this
// for loop in action.
// alert(TheNumber.charAt(i) + " is no good.")
 valid = 0
 } // End if statement
 } // End for loop
 return valid
}