//Validate data and submit
function doValidate(){
  var sErr = '';
  if (!validateRequiredField("name")) sErr += 'Please give your first name.  \n';
  if (!validateRequiredField("msg")) sErr += 'Message field is blank.  \n';  
  if (!validateEmail("external_to")) sErr += 'Please enter a valid email address.  \n';  
  if (sErr == ''){
    setEmailAddressForTopic(document.getElementById("topic").value);
    setTopicDescription(document.getElementById("topic").value);
    setConfirmationEmail(document.getElementById("topic").value);
    document.getElementById("internal_subject").value = "Web Site Contact Form: " + document.getElementById("topic_description").value;
    frm.submit();
  }else{
    alert(sErr);
    return false;
  }
}

//Set the email address based on what topic was selected for the contact form
function setEmailAddressForTopic(topicID){
  var topicOwners = new Array();
   topicOwners[0] = "webmaster@duanemorris.com ";
   topicOwners[1] = "lawstudent@duanemorris.com";
   topicOwners[2] = "recruiting@duanemorris.com";
   topicOwners[3] = "jobs@duanemorris.com";
   topicOwners[4] = "jpeck@duanemorris.com";            

   document.getElementById("internal_to").value = topicOwners[topicID];
}


function setConfirmationEmail(topicID){
//This enables a different confirmation email for each topic.
  var topicEmails = new Array();
  topicEmails[0] = "contactUs_ConfirmationEmail.vm";
  topicEmails[1] = "contactUs_ConfirmationEmail.vm";
  topicEmails[2] = "contactUs_ConfirmationEmail.vm";    
  topicEmails[3] = "contactUs_ConfirmationEmail.vm";
  topicEmails[4] = "contactUs_ConfirmationEmail.vm";    
  
  document.getElementById("confirmation_template").value = topicEmails[topicID];

}

//Set the full topic description based on topic ID
function setTopicDescription(topicID){
  var topics = new Array();
  topics[0] = "Web Site";
  topics[1] = "Recruiting - Law Students";
  topics[2] = "Recruiting - Lateral Associates";
  topics[3] = "Recruiting - Staff Positions";
  topics[4] = "Media Relations";        
  
  document.getElementById("topic_description").value = topics[topicID];
}




