/**********************************************************************
 *                                                                    *
 *  © 2010 First Baptist Church of Morrisville, all rights reserved.  *
 *                                                                    *
 *      Common javascript functions for www.fbcmorrisville.com        *
 *                                                                    *
 *     Created by Rollin Hippler - last updated on August 31, 2010    *
 *                                                                    *
 **********************************************************************/

// This function is used to verify that I was here.
function test()
{
  alert("This is a test!");
}

// Generate the navigation menu common to every page
// Each menu item definition consists of three parts:
//   1. The title text
//   2. The href string
//   3. A unique id number, 0 means open the target in  a new window
function genMenu(root)
{
 var mTitle = new Array(15);
 var mRef   = new Array(15);
 var mId    = new Array(15);
 var i = 0;

 mId[i] = 1;
 mTitle[i] = "Home";
 mRef[i] = "index.htm";

 i++;
 mId[i] = 1;
 mTitle[i] = "About Us";
 mRef[i] = "home/About_Us.htm";

 i++;
 mId[i] = 0;
 mTitle[i] = "Directions";
 mRef[i] = "http://www.mapquest.com/maps/map.adp?searchtype=address&amp;country=US&amp;addtohistory=&amp;searchtab=home&amp;formtype=address&amp;popflag=0&amp;latitude=&amp;longitude=&amp;name=&amp;phone=&amp;level=&amp;cat=&amp;address=209+Church+St.&amp;city=Morrisville&amp;state=NC&amp;zipcode=";

 i++;
 mId[i] = 1;
 mTitle[i] = "Service Times";
 mRef[i] = "home/service_times.htm";

 i++;
 mId[i] = 1;
 mTitle[i] = "Contact Us";
 mRef[i] = "home/contact.htm";

 i++;
 mId[i] = 1;
 mTitle[i] = "Bulletins and Sermons";
 mRef[i] = "bulletin/index.htm";

 i++;
 mId[i] = 1;
 mTitle[i] = "Calendar";
 mRef[i] = "calendar/index.htm";

 i++;
 mId[i] = 1;
 mTitle[i] = "Children's Ministry";
 mRef[i] = "children/index.htm";

 i++;
 mId[i] = 1;
 mTitle[i] = "Youth Ministry";
 mRef[i] = "youth/index.htm";

 i++;
 mId[i] = -1;
 mTitle[i] = "Group Discussions";
 mRef[i] = "bbs/logon.asp";

 i++;
 mId[i] = 1;
 mTitle[i] = "Member Pages";
 mRef[i] = "member_area/index.htm";

 i++;
 mId[i] = 0;
 mTitle[i] = "Member E-Mail";
 mRef[i] = "https://webmailcluster.perfora.net/xml/webmail/Login;jsessionid=A9955CF45513091A9EAB02EDC0A0D398.TC137b?__reuse=1196346149726";

 i++;
 mId[i] = 0;
 mTitle[i] = "DMin project";
 mRef[i] = "http://dmin.fbcmorrisville.com/";

 i++;
 mId[i] = 1;
 mTitle[i] = "Related Links";
 mRef[i] = "home/links.htm";

 i++;
 mId[i] = 0;
 mTitle[i] = "How to become a Christian";
 mRef[i] = "http://www.sbc.net/knowjesus/default.asp";

 for(i=0; i<mTitle.length; i++)
   switch(mId[i])
    {
     case 0:
       document.write('<li><a href="' + mRef[i] +'" target="_blank">' + mTitle[i] + '</a></li>');
       break;
     case 1:
       document.write('<li><a href="' + root + mRef[i] +'">' + mTitle[i] + '</a></li>');
       break;
     default: ;
    }
}

// Make email address harvesting more difficult
//   To add an entry:
//     * Add another to<xxxx> constant
//     * Add the corresponding case to the switch block
//
var toPastor     = 0;
var toOffice     = 1;
var toSecretary  = 2;
var toWebMaster  = 3;
var toChildDir   = 4;
var toYouthDir   = 5;
var toSSchoolDir = 6;
var toChoirDir   = 7;
function sendMail(toId, title)
{
 var atSign = "@";
 var user = "";
 var domain = "";

 switch(toId)
  {
   case toPastor:
     user = "\"Rev. Myron Yandle\"<myrony";
     domain = atSign + "fbcmorrisville.com>";
     break;
   case toOffice:
     user = "\"FBCM Office\"<office";
     domain = atSign + "fbcmorrisville.com>";
     break;
   case toSecretary:
     user = "\"Debra Hippler\"<debsw";
     domain = atSign + "bellsouth.net>";
     break;
   case toWebMaster:
     user = "\"Rollin Hippler\"<hipp2";
     domain = atSign + "bellsouth.net>";
     break;
   case toChildDir:
     user = "\"Karen Parker\"<karenp";
     domain = atSign + "fbcmorrisville>";
     break;
   case toYouthDir:
     user = "\"Maury Turner\"<mauryt";
     domain = atSign + "fbcmorrisville.com>";
     break;
   case toSSchoolDir:
     user = "\"Rollin Hippler\"<rollinh";
     domain = atSign + "fbcmorrisville.com>";
     break;
   case toChoirDir:
     user = "\"Nelda Haines\"<neldah";
     domain = atSign + "fbcmorrisville.com>";
     break;
   default:
     alert("ERROR: email id " + toId + " is not defined!");
     return;
  }
 document.write("<a href='mailto:" + user + domain + "'>" + title + "</a>");
}
