/*
* changes to topics/email addresses must be made on all campus sites since the user can pick
* campus after selecting which campus they attend on this page
*/
var campus = "Browns Bridge";
var topic = "--";
var recipients = new Array(3);




function init() {
recipients["North Point"] = new Array(5);
recipients["Buckhead"] = new Array(5);
recipients["Browns Bridge"] = new Array(5);
recipients["Watermarke"] = new Array(5);
recipients["Gwinnett"] = new Array(5); 

recipients["North Point"]["Submit a Testimony"] = "pastorsoffice@northpoint.org";
recipients["North Point"]["Baptism"] = "baptism@northpoint.org";
recipients["North Point"]["Bookstore/Resources"] = "resources@northpoint.org";
recipients["North Point"]["Church Administration"] = "admin@northpoint.org";
recipients["North Point"]["Care and Prayer"] = "care@northpoint.org";
recipients["North Point"]["Campus questions"] = "pastorsoffice@northpoint.org";
recipients["North Point"]["Children (K-5)"] = "upstreet@northpoint.org";
recipients["North Point"]["Giving"] = "giving@northpoint.org";
recipients["North Point"]["High School"] = "insideout@northpoint.org";
recipients["North Point"]["Human Resources/Hiring"] = "humanresources@northpoint.org";
recipients["North Point"]["KidStuf"] = "kidstuf@northpoint.org";
recipients["North Point"]["Married small groups"] = "marriedgrouplife@northpoint.org";
recipients["North Point"]["Membership"] = "baptism@northpoint.org";
recipients["North Point"]["Men's Prayer Ministry"] = "care@northpoint.org";
recipients["North Point"]["Middle School"] = "middleschool@northpoint.org";
recipients["North Point"]["Missions"] = "globalxinfo@northpoint.org";
recipients["North Point"]["Music"] = "music@northpoint.org";
recipients["North Point"]["North Point Online"] = "nponline@northpoint.org";
recipients["North Point"]["Parking/Host Team"] = "contacthostteam@northpoint.org";
recipients["North Point"]["Podcasts/North Point TV"] = "info@northpoint.org";
recipients["North Point"]["Premarital/Weddings"] = "premarital@northpoint.org";
recipients["North Point"]["Preschool (NB-4Y)"] = "family.ministry@northpoint.org";
recipients["North Point"]["Production"] = "production@northpoint.org";
recipients["North Point"]["Single Adults"] = "fusion@northpoint.org";
recipients["North Point"]["Single small groups"] = "singlesmallgroups@northpoint.org";
recipients["North Point"]["Starting Point"] = "startingpoint@northpoint.org";
recipients["North Point"]["Tours"] = "tours@northpoint.org";
recipients["North Point"]["Women's small groups"] = "ladieslink@northpoint.org";
recipients["North Point"]["General"] = "info@northpoint.org";

recipients["Buckhead"]["Submit a Testimony"] = "info@buckheadchurch.org";
recipients["Buckhead"]["General"] = "info@buckheadchurch.org";
recipients["Buckhead"]["Baptism"] = "baptism@buckheadchurch.org";
recipients["Buckhead"]["Bookstore/Resources"] = "bcresources@northpointministries.net";
recipients["Buckhead"]["Church Administration"] = "admin@buckheadchurch.org";
recipients["Buckhead"]["Care and Prayer"] = "care@buckheadchurch.org";
recipients["Buckhead"]["Campus questions"] = "info@buckheadchurch.org";
recipients["Buckhead"]["Children"] = "upstreet@buckheadchurch.org";
recipients["Buckhead"]["College"] = "collegeministry@buckheadchurch.org";
recipients["Buckhead"]["Community Groups"] = "communitygroups@buckheadchurch.org";
recipients["Buckhead"]["Giving"] = "giving@buckheadchurch.org";
recipients["Buckhead"]["High School"] = "insideout@buckheadchurch.org";
recipients["Buckhead"]["Human Resources  "] = "humanresources@northpoint.org";
recipients["Buckhead"]["Intersect Project/Community Service"] = "intersect@buckheadchurch.org";
recipients["Buckhead"]["KidStuf"] = "kidstuf@buckheadchurch.org";
recipients["Buckhead"]["Membership"] = "membership@buckheadchurch.org";
recipients["Buckhead"]["Men's Prayer Ministry"] = "care@buckheadchurch.org";
recipients["Buckhead"]["Middle School"] = "xtreme@buckheadchurch.org";
recipients["Buckhead"]["Missions"] = "globalxinfo@northpoint.org";
recipients["Buckhead"]["Music"] = "music@buckheadchurch.org";
recipients["Buckhead"]["North Point Online"] = "nponline@northpoint.org";
recipients["Buckhead"]["Parking/Host Team"] = "hostteam@buckheadchurch.org";
recipients["Buckhead"]["Podcasts/North Point TV"] = "info@northpoint.org";
recipients["Buckhead"]["Premarital/Weddings"] = "care@buckheadchurch.org";
recipients["Buckhead"]["Preschool"] = "waumbaland@buckheadchurch.org";
recipients["Buckhead"]["Production"] = "production@buckheadchurch.org";
recipients["Buckhead"]["7|22"] = "722@buckheadchurch.org";
recipients["Buckhead"]["Single Adults"] = "fusion@buckheadchurch.org";
recipients["Buckhead"]["Starting Point"] = "startingpoint@buckheadchurch.org";
recipients["Buckhead"]["Tours"] = "tours@buckheadchurch.org";

recipients["Browns Bridge"]["Submit a Testimony"] = "pastorsoffice@brownsbridge.org";
recipients["Browns Bridge"]["Baptism"] = "baptism@brownsbridge.org";
recipients["Browns Bridge"]["Bookstore/Resources"] = "resources@brownsbridge.org";
recipients["Browns Bridge"]["Church Administration"] = "admin@brownsbridge.org";
recipients["Browns Bridge"]["Care and Prayer"] = "care@brownsbridge.org";
recipients["Browns Bridge"]["Campus questions"] = "pastorsoffice@brownsbridge.org";
recipients["Browns Bridge"]["Children (K-5th)"] = "upstreet@brownsbridge.org";
recipients["Browns Bridge"]["Giving"] = "giving@brownsbridge.org";
recipients["Browns Bridge"]["High School"] = "insideout@brownsbridge.org";
recipients["Browns Bridge"]["Human Resources  "] = "humanresources@northpoint.org";
recipients["Browns Bridge"]["KidStuf"] = "kidstuf@brownsbridge.org";
recipients["Browns Bridge"]["Ladies small groups"] = "ladieslink@brownsbridge.org";
recipients["Browns Bridge"]["Married small groups"] = "marriedgrouplife@brownsbridge.org";
recipients["Browns Bridge"]["Membership"] = "baptism@brownsbridge.org";
recipients["Browns Bridge"]["Men's Prayer Ministry"] = "care@brownsbridge.org";
recipients["Browns Bridge"]["Middle School"] = "xtreme@brownsbridge.org";
recipients["Browns Bridge"]["Missions"] = "globalxinfo@northpoint.org";
recipients["Browns Bridge"]["Music"] = "music@brownsbridge.org";
recipients["Browns Bridge"]["North Point Online"] = "nponline@northpoint.org";
recipients["Browns Bridge"]["Parking"] = "host.team@brownsbridge.org";
recipients["Browns Bridge"]["Podcasts/North Point TV"] = "info@northpoint.org";
recipients["Browns Bridge"]["Premarital/IE"] = "care@brownsbridge.org";
recipients["Browns Bridge"]["Preschool"] = "waumbaland@brownsbridge.org";
recipients["Browns Bridge"]["Production"] = "production@brownsbridge.org";
recipients["Browns Bridge"]["Single Adults"] = "fusion@brownsbridge.org";
recipients["Browns Bridge"]["Single small groups"] = "singlesgroups@brownsbridge.org";
recipients["Browns Bridge"]["Starting Point"] = "startingpoint@brownsbridge.org";
recipients["Browns Bridge"]["Tours"] = "tours@brownsbridge.org";
recipients["Browns Bridge"]["General"] = "info@brownsbridge.org";

recipients["Watermarke"]["Submit a Testimony"] = "mystory@watermarkechurch.com";
recipients["Watermarke"]["Access Groups"] = "accessgroups@watermarkechurch.com";
recipients["Watermarke"]["Baptism"] = "baptism@watermarkechurch.com";
recipients["Watermarke"]["Bookstore/Resources"] = "info@watermarkechurch.com";
recipients["Watermarke"]["Church Administration"] = "info@watermarkechurch.com";
recipients["Watermarke"]["Care and Prayer"] = "care@watermarkechurch.com";
recipients["Watermarke"]["Campus questions"] = "info@watermarkechurch.com";
recipients["Watermarke"]["Children (K-5th)"] = "upstreet@watermarkechurch.com";
recipients["Watermarke"]["Giving"] = "info@watermarkechurch.com";
recipients["Watermarke"]["High School"] = "insideout@watermarkechurch.com";
recipients["Watermarke"]["Human Resources"] = "info@watermarkechurch.com";
recipients["Watermarke"]["Married small groups"] = "groups@watermarkechurch.com";
recipients["Watermarke"]["Membership"] = "membership@watermarkechurch.com";
recipients["Watermarke"]["Men's small groups"] = "groups@watermarkechurch.com";
recipients["Watermarke"]["Middle School"] = "middleschool@watermarkechurch.com";
recipients["Watermarke"]["Missions"] = "globalx@watermarkechurch.com";
recipients["Watermarke"]["Music"] = "music@watermarkechurch.com";
recipients["Watermarke"]["Premarital/Weddings"] = "care@watermarkechurch.com";
recipients["Watermarke"]["Preschool"] = "waumbaland@watermarkechurch.com";
recipients["Watermarke"]["Production"] = "production@watermarkechurch.com";
recipients["Watermarke"]["Single Adults"] = "singles@watermarkechurch.com";
recipients["Watermarke"]["Single small groups"] = "groups@watermarkechurch.com";
recipients["Watermarke"]["Starting Point"] = "startingpoint@watermarkechurch.com";
recipients["Watermarke"]["Women's small groups"] = "groups@watermarkechurch.com";
recipients["Watermarke"]["General"] = "info@watermarkechurch.com";

recipients["Gwinnett"]["Submit a Testimony"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Baptism"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Church Administration"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Care and Prayer"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Campus questions"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Children (K-5th)"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["High School"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Membership"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Middle School"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Preschool"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["Small Groups"] = "info@gwinnettchurch.org";
recipients["Gwinnett"]["General"] = "info@gwinnettchurch.org";


setCampus(document["theForm"]["fhscol_Campus"].value);
setTopic(document["theForm"]["fhscol_Topic"].value);
} // end init

function setTopicList() {
  topicSelect = document["theForm"]["fhscol_Topic"];
  topicSelect.options.length = 0;
  topicSelect.options[0] = new Option("--Select One--","--");
  for (var i in recipients[campus]) {
   //if ("--" == i)
      //topicSelect.options[0] = new Option("--Select One--","--");
   //else
      topicSelect.options[topicSelect.options.length] = new Option(i,i);
  }
  setRecipient();
}

function checkFields(form) {
   var errorMsg = "Please enter a valid";
   var isError = false;
   
   // these are the required fields
   firstName = form["fhscol_FirstName"].value;
   lastName = form["fhscol_LastName"].value;
   email = form["fhscol_Email"].value;
   t = form["fhscol_Topic"].value;
   message = form["message"].value;
   attendsChecked = radioChecked(form["fhscol_Attend"]);

   isError = (firstName == "" || lastName == "" || email == "" || t == "--" || message == "");
   if (isError) {
     // find out which one and set the error message
     if (firstName == "") errorMsg += " First Name,";
     if (lastName == "") errorMsg += " Last Name,";
     if (email == "") errorMsg += " Email Address,";
     if (t == "--") errorMsg += " Topic,";
     if (message == "") errorMsg += " Message";
     
     // remove the , if it's the last char
     if (errorMsg.charAt(errorMsg.length-1) == ',') errorMsg = errorMsg.substring(0,errorMsg.length-1);
     alert(errorMsg);
     return false;
   }
   if (!validEmail(email)) {
      errorMsg += " Email Address";
      form["fhscol_Email"].focus();
      alert(errorMsg);
      return false;
   }
   if (!attendsChecked) {
      alert("Please indicate if you are a member or regular attendee.");
      return false;
   }


   form["fhs_sender"].value = firstName +" "+lastName+"<"+email+">";
   form["fhs_subject"].value = "Brownsbridge.org Contact Us Message - "+topic;
   form["fhscol_Message"].value = message.replace(/\n/g,"<br clear=\"all\"/>");
   return true;
}
function validEmail(email) {
  var validaddress= /^((\w+).?(\w+))+@\w+/i;
  var emailFilter=/^.+@.+\..{2,3,4,6}$/;
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  return (filter.test(email));
}
// return true if one of the radio buttons is checked
function radioChecked(radioElement) {
  for( var i = 0; i < radioElement.length; i++ ) {
    if( radioElement[i].checked )
      return true;
  }
  return false;
}
function setCampus(theCampus) {
   campus = theCampus;
   setTopicList();
   setRecipient();
}
function setTopic(theTopic) {
   topic = theTopic;
   setRecipient();
}
function setRecipient() {
   recipientField = document.theForm["fhs_recipients"];
   recipientField.value = recipients[campus][topic];

   //alert("set email address to "+recipientField.value);
}
function showHideCampus(showIt) {
   labelSpan = document.getElementById("campusLabel");
   if (labelSpan) labelSpan.style.display = (showIt?"inline":"none");
   document.theForm["fhscol_Campus"].style.display = (showIt?"inline":"none");
}
