//<!--//CHECK EMPTY FIELDS 7/30/2009

function myAlert(mytitle, mytext){
   alert(mytext);
}



function checkEmail(Form){
  if (Form.email.value == "") {
     myAlert("Missing Field","Please enter a valid email address." );
     Form.email.focus();
     return false;
  }
  var email=Form.email.value;
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  if(reg.test(email) == false) {
      myAlert("Invalid Field","Invalid Email Address");
      Form.email.focus();
      return false;
  }
  return true;  
}

function checkName(Form){
  if (Form.realname.value == "") {
     myAlert("Missing Field","Please enter a valid name." );
     Form.realname.focus();
     return false;
  }
  return true;  
}

function checkPhone(Form){
  if (Form.ContactPhone.value == "") {
     myAlert("Missing Field","Please enter a valid phone number." );
     Form.ContactPhone.focus();
     return false;
  }
  return true;  
}

function checkJobLocation(Form){
  if (Form.txtJobLocation.value == "") {
     myAlert("Missing Field","Please specify a Job Location." );
     Form.txtJobLocation.focus();
     return false;
  }
  return true;  
}
function checkJobDescription(Form){
  if (Form.txtJobDescription.value == "") {
     myAlert("Missing Field","Please enter a Job Description." );
     Form.txtJobDescription.focus();
     return false;
  }
  return true;  
}



function populatePhone(key, Form){
var phone = Form.txtPhone.value;
var character = String.fromCharCode(key);
//alert(character);


//var ValidCharskey = "0123456789";
   
   //test the key pressed      
      if (key < 48 || key > 57) 
         {//alert("rejected");
         }else{
		    
		    //test the entire field
		    var ValidChars = "0123456789()-";
		    var IsNumber=true;
            var Char;
		    
            for (i = 0; i < phone.length && IsNumber == true; i++) 
            { 
            Char = phone.charAt(i); 
              if (ValidChars.indexOf(Char) == -1) 
              {
               IsNumber = false;
              }
            }

            if (phone.length ==1 && IsNumber && phone != "(" && character != "1"){
            Form.txtPhone.value = "(" + phone;
            }else if (phone.length ==4 && IsNumber && phone.charAt(0) == "("){
            Form.txtPhone.value = phone + ")-";
            }else if (phone.length ==9 && IsNumber && phone.charAt(4) == ")"){
            Form.txtPhone.value = phone + "-";
            }
		 
		 
		}
       
}



function checkFields(){
  var Form = document.frmContactUs;


    // check name field
    if (checkName(Form) == false){
      return false;
    }
	
    // check email field
    if (checkEmail(Form) == false){
      return false;
    }
	
	  // check phone field
	//if (checkPhone(Form) == false){
      //return false;
	//}
	
    // check job location field
    if (checkJobLocation(Form) == false){
      return false;
    }
	
	// check job description field
    if (checkJobDescription(Form) == false){
      return false;
    }
}



// -->

