

function validate_contactUs(thisform)
{

   with (thisform){

     if(whoto.selectedIndex == 0){
        whoto.focus();
        giveFeedback("Please choose a recipient.");
        return false;
     }
     else if (!name.value){
        name.focus();
        giveFeedback("Please type in your name.");
        return false;
     }
     else if (!validate_email(email)){
        email.focus();
        giveFeedback("Your email doesn't seem to be valid.");
        return false;
     }
     else if (!subject.value){
        subject.focus();
        giveFeedback("Please tell us what your message is about in the 'Subject' field. ");
        return false;
     }
     else if (!comments.value){
        comments.focus();
        giveFeedback("Please write your message in the textbox.");
        return false;
     }
     else{
        return true;
        //giveFeedback("Sorry this form isn't ready yet");
     }
  }

  return true;


}


function validate_email(field)
{
  //alert("validate_email");
  reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

  //alert("field: "+field.value);
  if (!reg.test(field.value)){
    // Basic check
    //alert(' failed against reg expression');
    return false;
  }
  else{
    return true;
  }
}


function giveFeedback(feedbackString){
   //alert("failed validation");
   var feedback = document.getElementById('contactUsFeedback');
   feedback.innerHTML = feedbackString;
   feedback.style.display="block";
}
