// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function check_form()  {
  if($('contact_name').value == "")  {
    alert("Please enter your name...");
    $('contact_name').focus();
    return;
  }
  
  if($('contact_phone').value == "")  {
    alert("Please enter your phone...");
    $('contact_phone').focus();
    return;
  }
  
  if($('contact_email').value == '')  {
    alert("Please enter your email...");
      $('contact_email').focus();
      return;
  }
  else  {
    if(!test( $('contact_email').value ) )  {
      alert("Please enter a valid email...");
      $('contact_email').focus();
      return;
    }
  }
  
  if($('contact_institution').value == "")  {
    alert("Please enter your institution...");
    $('contact_institution').focus();
    return;
  }
  document.forms[0].submit();
}

function test(src) {
   var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
   var regex = new RegExp(emailReg);
   return regex.test(src);
}
