// COPYRIGHT NOTICE
// Copyright (c) Design Matrix, 2004, all rights reserved.
// http://www.designmatrix.com
// This file is provided without any warranty or liability whatsoever.
// Permission is granted to copy and modify this file provided that
// this COPYRIGHT NOTICE is included and modifications are noted.
// Download it here:
// 	http://www.designmatrix.com/services/javascript_email.html

// VERSION 1.3, 08/23/2006

// DESCRIPTION
// This Javascript illustrates methods to maintain a "database" of
// email addresses in one location, so that they only need to be
// maintained in one file rather than in many separate HTML files.

// THE DATABASE
// Define a database for the email addresses as a string array object.
// The form of each line is "First_Name Last_Name Email_Handle Domain".
// The number inside "[ ]" is the numerical index used in makeAddr().
// Change these examples for your own web site.  Use "//" for comments.
var addr = new Array();
//addr[0] = "Tom Fizzlebottom fizzle whistle.con";
//addr[1] = "Dick Dinglewitz wizard oz.con";
//addr[2] = "Mary Contrary silverbell gardengrow.con";
//addr[3] = "Your Name you yourdomain.con";
//addr[4] = "Contact Us info yourdomain.con";
// Note the backslash "\" for a "null" last name here.
//addr[5] = "Webmaster \ webmaster yourdomain.con";
// To use an image instead of text for the link:
//addr[6] = "<IMG SRC='image.gif'> contact your_domain.con";
//
// You can also define the email addresses in an array with named
// indices, similar to an associative array in Perl.  The advantage of
// arrays with numerical indices is that they would be easier to use in
// loops.  The advantage of the named indices is that they might be
// easier to remember for the makeAddr() function (i.e., so you don't
// have to look up the numerical index for a particular persons' email
// address).  It appears that numerical and named indices may be mixed
// in one array but we recommend you use one or the other consistently.
//addr["Tom"]  = "Tom Fizzlebottom fizzle whistle.con";
//addr["Dick"] = "Dick Dinglewitz wizard oz.con";
//addr["Mary Contrary"] = "Mary Contrary silverbell gardengrow.con";
//addr["Your Name"] = "Your Name you yourdomain.con";
// Note the backslash for a 'null' last name here.
//addr["Info"] = "info&#064;yourdomain.con \ info yourdomain.con";
//addr["Webmaster"] = "webmaster&#064;yourdomain.con \ webmaster yourdomain.con";
addr["Jo_Ann_Angelo"] = "Pastor&nbsp;Jo&nbsp;Ann Angelo angeloj TheTab.org 1707 Pastoral&nbsp;Staff";
addr["Lorri_Atkins"] = "Lorri Atkins atkinsl TheTab.org 1716 Accounting";
addr["Al_Baun"] = "Pastor&nbsp;Al Baun bauna TheTab.org 1708 Pastoral&nbsp;Staff";
addr["Dee_Bernardoni"] = "Pastor&nbsp;Dee Bernardoni operationdignity msn.com 1735 Operation&nbsp;Dignity";
addr["Carol_Biegalski"] = "Carol Biegalski biegalskic TheTab.org 1700 Receptionist";
addr["Cindy_Cafarella"] = "Cindy Cafarella cafarellac TheTab.org 1713 Pastoral&nbsp;Care";
addr["Allison_Collins"] = "Allison Collins collinsa TheTab.org 1721 Communications&nbsp;and&nbsp;Contributions";
addr["Mary_Collins"] = "Mary Collins collinsm TheTab.org 1715 Human&nbsp;Resouces&nbsp;and&nbsp;Accounting";
addr["Jim_Delmont"] = "Jim Delmont delmontj TheTab.org 1731 Food&nbsp;Pantry&nbsp;Director";
addr["Claire_Fridey"] = "Claire Fridey frideyc TheTab.org 1718 Children's&nbsp;Pastor&nbsp;&amp;&nbsp;Action&nbsp;Nights";
addr["Pam_Kellner"] = "Pam Kellner kellnerp TheTab.org 1711 Director&nbsp;of&nbsp;Educational&nbsp;Ministries";
addr["Anthony_Kosobucki"] = "Anthony Kosobucki anthonyk TheTab.org 1723 Audio&nbsp;Engineer";
addr["Jim_McGinnis"] = "Jim McGinnis jmcginnis TheTab.org 1709 Chief&nbsp;of&nbsp;Staff";
addr["Sue_Morino"] = "Sue Morino morinos TheTab.org 1710 Administrative&nbsp;Assistant";
addr["Jamie_Procknal"] = "Jamie Procknal procknalj TheTab.org 1719 Christian&nbsp;Education&nbsp;Assistant";
addr["Mike_Pelechaty"] = "Mike Pelechaty mjpmd7 gmail.com 1705 Pastoral&nbsp;Staff&nbsp;(Marriage&nbsp;&amp;&nbsp;Family)";
addr["Tommy_Reid"] = "Pastor&nbsp;Tommy Reid treid TheTab.org 1710 Lead&nbsp;Pastor";
addr["Wanda_Reid"] = "Wanda Reid reidw TheTab.org 1702 Pastoral&nbsp;Staff";
addr["Tom_Rinn"] = "Tom Rinn trinn TheTab.org 1704 Pastoral&nbsp;Staff";
addr["Mike_Shreve"] = "Mike Shreve shrevem TheTab.org 1724 Communications&nbsp;Director";
addr["Aimee_Sych"] = "Pastor&nbsp;Aimee Sych worship TheTab.org 1706 Worship&nbsp;&&nbsp;Arts&nbsp;Pastor";
addr["Jay_Sych"] = "Jay Sych sychj TheTab.org 1725 Maintenance&nbsp;Supervisor";
addr["George_Walsh"] = "Pastor&nbsp;George Walsh \ \ (no&nbsp;ext) Pastoral&nbsp;Staff";
addr["Jeremy_Ziegler"] = "Pastor&nbsp;Jeremy Ziegler jziegler TheTab.org 1717 Youth&nbsp;Pastor";
//addr[""] = " TheTab.org";
//addr[""] = " TheTab.org";
//addr[""] = " TheTab.org";
//addr[""] = " TheTab.org";



// THE PROGRAM SCRIPT
// Define some makeAddr() variables for the email HTML links.
var cmd = "mail" + "to:";
// Any of these work.
//var at = '@';
var at = '&#064;';
// at sign is hex %40
//var at = escape('@');
//
// You can add any amount of extra HTML code to use in makeAddr().
// For example this variable writes an HTML break before the links:
//	var preextra = "<BR>";
// If your extra variables contain double quotes, you must escape them:
//	var preextra = "<TD WIDTH=\"50%\">";
// The mailextra variable puts email headers inside the mailto links,
// such as a Subject, Cc or Bcc.  For example this adds a Subject:
//	var mailextra ="?Subject=Howdy";
// This variable adds code to terminate a TABLE cell after the links:
//	var postextra = "</TD>";
// Note that if you leave extras in the makeAddr() function they must
// be defined, but you can define them as null string (nothing):
var preextra = "";
var mailextra = "";
var postextra = "";
//
// Here is the function definition.  We split the string referenced
// by the index into a subarray, then assemble it for the HTML code.
// The "\n" prints a newline.
function makeAddr(index) {
    var subarr = addr[index].split(" ");
    var name = subarr[0] +" " +subarr[1];
    var mail = name.link(cmd +subarr[2] +at +subarr[3] +mailextra);
	document.write(preextra +"\n" +mail +"\n" +postextra);
}

function makeExtTitle(index) {
    var subarr = addr[index].split(" ");
    var ext_title = "<td>" +subarr[4] +"</td><td>" +subarr[5] +"</td>";
    document.write(ext_title +"\n");
}

// USAGE
// To use this Javascript save it in a file.  Next put the following
// (uncommented) inside the <HEAD> (or <BODY>) of your HTML file.
// Change the SCRIPT SRC argument to match the script's file name.
// The filename suffix ".js" is required to identify it as Javascript.
//
//	<SCRIPT SRC="addr.js" TYPE="text/javascript"> < /SCRIPT>
//
// Then call makeAddr() where you want an email link in the HTML file.
// Make each index match the person's address line index in the array.
// For named indices put the makeAddr() index argument in quotes.
// Write several email links as follows.  Note that you can redefine
// the extra variables before you call the makeAddr() functions, e.g.:
//
//	<SCRIPT TYPE="text/javascript">
//	<!--
//	    var preextra = "<TD WIDTH=\"50%\">";
//	    // Tom is index 0.
//	    makeAddr(0);
//	    var preextra = "<BR>";
//	    // Dick is index 1.
//	    makeAddr(1);
//	    var mailextra = "?Subject=Hi Mary!";
//	    var postextra = "</TD>";
//	    // Mary's index is self-explanatory.
//	    makeAddr("Mary Contrary");
//	// -->
//	< /SCRIPT>