/* email protection (uid and domain fields are required) */
function mailTo(uid, domain, subject) {
if(!subject){
   window.location="mailto:"+uid+"@"+domain;
   } else {
   window.location="mailto:"+uid+"@"+domain+"?subject="+subject;
   }
}
/* if we need show the email on mouseover, also add (all fields are required): */
function showemail(id, uid, domain) {
   document.getElementById(id).title= uid+"@"+domain;
}
/* form validation */
function validate() {
   var message = "Please fill in following information:\n";
   var validation = true;
   var InsertRecordFirstName = document.getElementById('InsertRecordFirstName').value;
   var InsertRecordLastName = document.getElementById('InsertRecordLastName').value;

   var InsertRecordStreet = document.getElementById('InsertRecordStreet').value;
   var InsertRecordCity = document.getElementById('InsertRecordCity').value;
   var InsertRecordState = document.getElementById('InsertRecordState').value;
   var InsertRecordZip = document.getElementById('InsertRecordZip').value;
   var InsertRecordPhone = document.getElementById('InsertRecordPhone').value;
   var InsertRecordEmail = document.getElementById('InsertRecordEmail').value;
   var InsertRecordDegree = document.getElementById('InsertRecordDegree').value;
   var InsertRecordOther = document.getElementById('InsertRecordOther').value;
   var InsertRecordLetter = document.getElementById('InsertRecordLetter').value;
   var InsertRecordCV = document.getElementById('InsertRecordCV').value;
   var InsertRecordTranscript = document.getElementById('InsertRecordTranscript').value;
   var InsertRecordReference = document.getElementById('InsertRecordReference').value;
   var InsertRecordHeardFrom = document.getElementById('InsertRecordHeardFrom').value;


   if(InsertRecordFirstName == "" || InsertRecordLastName == ""){
      message += " Your first name and last name\n";
      validation = false;
   }
   if(InsertRecordStreet == "" || InsertRecordCity == "" || InsertRecordState == "" || InsertRecordZip == ""){
      message += " Your address, including Street, City, State and Zip Code\n";
      validation = false;
   }
   if(InsertRecordPhone == "" || InsertRecordEmail == ""){
      message += " Your contact phone number and email\n";
      validation = false;
   }
   if(InsertRecordDegree == "" && InsertRecordOther == ""){
      message += " Select or specify the degree you received\n";
      validation = false;
   }
   if(InsertRecordLetter == "" || InsertRecordCV == ""){
      message += " Both Letter of Interest and Curriculum Vitae are required\n";
      validation = false;
   }
    if(InsertRecordTranscript == ""){
      message += " List the institutions that will send your transcripts to us\n";
      validation = false;
   }
    if(InsertRecordReference == ""){
      message += " List the names and affiliations of the references you will have sent to us\n";
      validation = false;
   }
    if(InsertRecordHeardFrom == ""){
      message += " Please tell us where you first heard about this program\n";
      validation = false;
   }
   if(validation == false){
   		alert(message);
   }else{
   document.formSubmit.submit();
   }
}