// --------------------------------------------------------------------
//
// master.js (for the Emmanuel Baptist Church web page)
//
// The primary purpose of this javascript file is to implement the
//	common navagation bar found on every web page. This navagation
//	bar simulates a microsoft file pulldown menubar. Whenever the
//	user's mouse "hovers" over a "button" on the navagation bar, a
//	"pop-up" menu will appear over the web page to provide
//	a link to related web pages.
//
// These "pop-ups" are a rather complex function to implement.
//	Briefly, each "pop-up" is an html division with an attribute
//	of "hidden" initially. Each "button" has an event handler
//	installed that will cause all other buttons' "pop-ups" to
//	hide and then force their own pop-up to become "visible".
//
// Event handlers are also installed on other portions of the web
//	page that will hide the pop-ups in case the user's mouse leaves
//	the button in a direction not leading the mouse over the pop-up.
//	When the mouse leaves the pop-up, the visibility on the
//	pop-up will also be hidden.
//
// In addition, to ease the job of changing the structure of the
//	navagation bar, the navagation bar is built dynamically from
//	an array initialized at the top of this file. To make a change
//	to the catagories, change the category array. For each category,
//	there is another array that defines the relationships between
//	the web page description and the web page file name.
//
// Every page (including the home page) has a banner image that
//	that is a link back to the home page.
//
// The main "home" page has a list of the staff in the leftmost
//	column. On the "home" pages for each of the navagation categories,
//	the leftmost column contains a reconstruction of the "pop-up"
//	list of links. To aid in generating the staff information, look
//	at the routine td_staff(). To generate the individual pop-up link
//	lists, look at the routine td_catlist().
//

//
// Another database that is referenced here is the staff database.
//	Each staff member has a name, title, small picture, large picture
//	and email address. This database is initialized below the
//	navagation bar...
//

//
// Finally, the contactus.html web page uses a javascript validator
//	to do some final sanity checks before the form is submitted.
//	Validation is done in the contactUsValidator() routine found at
//	at the very bottom of this file...
//

//
// Also see ebcrochester.css for more documentation.
//

//
// Notes:
//
//	(1) I editted this source with NoteTab Light (free) and set
//		the tab stops at 4 characters... the source may appear
//		a bit funny with tab stops every 8 characters (sorry).
//
// --------------------------------------------------------------------


// --------------------------------------------------------------------
//
// FireFox likes to cache too much junk... this causes FireFox to
//	cache less...
//

window.onunload=function(){return true;}


// --------------------------------------------------------------------
//
// Here is the navagation bar database: (also used by the site map page)
//

var navBar = new Array();

var i = 0, j = 0;			// First menu bar tab/button

navBar[i] = new Array();
navBar[i][j++] = new Array( 'welcome', 'welcome', 'Find a Warm Welcome', '/welcome.html' );
navBar[i][j++] = new Array( 'welcome from pastor kevin', '/welcome.html' );
navBar[i][j++] = new Array( 'salvation',          '/salvation.html'    );
navBar[i][j++] = new Array( 'staff',              '/staff.html'        );
navBar[i][j++] = new Array( 'vision',             '/vision.html'       );
navBar[i][j++] = new Array( 'beliefs',            '/beliefs.html'      );
navBar[i][j++] = new Array( 'values',             '/values.html'       );
navBar[i][j++] = new Array( 'history',            '/history.html'      );
navBar[i][j++] = new Array( 'partnerships',       '/partnerships.html' );
navBar[i][j++] = new Array( 'campus map',         '/images/campus.gif' );
navBar[i][j++] = new Array( 'location',           '/location.html'     );
navBar[i][j++] = new Array( 'contact us',         '/webmaster.php?verb=contactus' );
navBar[i][j++] = new Array( 'site map',           '/sitemap.html'      );
navBar[i][j++] = new Array( 'site search',        '/sitesearch.html'   );
navBar[i][j++] = null;

i++; j = 0;					// Next menu bar tab/button

navBar[i] = new Array();
navBar[i][j++] = new Array( 'worship', 'worship', 'Find Worship That\'s Alive', '/worship.html' );
navBar[i][j++] = new Array( 'service schedule',   '/services.html'     );
navBar[i][j++] = new Array( 'directions',         '/location.html'     );
navBar[i][j++] = new Array( 'campus map',         '/images/campus.gif' );
navBar[i][j++] = new Array( 'calendar',           '/calendar.html'     );
navBar[i][j++] = null;

i++; j = 0;					// Next menu bar tab/button

navBar[i] = new Array();
navBar[i][j++] = new Array( 'ministries', 'ministries', 'Meeting Needs in Christ\'s Name', '/ministries.html' );
navBar[i][j++] = new Array( 'baptist hospitality house',  'http://ebcrochester.org/baptisthospitalityhouse/' );
navBar[i][j++] = new Array( 'bible study',        '/biblestudies.html' );
navBar[i][j++] = new Array( 'chaplaincy',         'http://mwbc.org/templates/System/details.asp?id=28512&amp;PID=392744' );
navBar[i][j++] = new Array( 'disaster relief',    '/disaster.html'     );
navBar[i][j++] = new Array( 'english as a second language', '/esl.html' );
navBar[i][j++] = new Array( "men's ministries",   '/ministries/Men/MensMinistries.html' );
navBar[i][j++] = new Array( 'music',              '/music.html'        );
navBar[i][j++] = new Array( 'prayer',             '/prayer.html'       );
//navBar[i][j++] = new Array( 'royal ambassadors',  '/ras.html'          );
navBar[i][j++] = new Array( 'wednesday kids club','/kids/'             );
//navBar[i][j++] = new Array( 'seniors',            '/seniors.html'      );
//navBar[i][j++] = new Array( 'singles',            '/singles.html'      );
navBar[i][j++] = new Array( 'sports leagues',     '/sports.html'       );
//navBar[i][j++] = new Array( 'team kid',           '/teamkid.html'      );
//navBar[i][j++] = new Array( 'upward basketball',  '/upward.html'       );
//navBar[i][j++] = new Array( 'youth',              '/youth.html'        );
navBar[i][j++] = new Array( 'volunteer',          '/volunteer.html'    );
navBar[i][j++] = null;

i++; j = 0;					// Next menu bar tab/button

navBar[i] = new Array();
navBar[i][j++] = new Array( 'resources', 'resources', 'Resources to help you grow', '/resources.html' );
navBar[i][j++] = new Array( 'sermons',				'/misc/resources/sermons/' );
navBar[i][j++] = new Array( 'bible studies',		'/misc/resources/Studies/' );
navBar[i][j++] = new Array( 'book reviews',			'/misc/resources/BookReviews/' );
navBar[i][j++] = new Array( 'e-manual news', 		'http://ebcrochester.org/nl/' );
navBar[i][j++] = new Array( 'the ebcrochester blog', 'http://ebcrochester.blogspot.com/' );
navBar[i][j++] = new Array( 'spiritual gifts survey', '/misc/php/LifeWaySpiritualGiftsSurvey.php' );
navBar[i][j++] = new Array( 'slideshows',			'http://jjmmjmmm.com/ebcrochester/slideshows/' );
navBar[i][j++] = new Array( 'sunday school puzzles', '/misc/resources/SundaySchool/' );
navBar[i][j++] = new Array( 'helpful links',		'/helpful-links.html' );
navBar[i][j++] = null;

var navBarButtonCount = i + 1;

// --------------------------------------------------------------------
//
// Here is the staff database:
//

var staff = new Array();

i = 0;

staff[i++] = new Array( 	'yes',						// Show on sidebar?
							'Kevin Binkley',			// Name
							'Pastor Kevin',				// Informal name
							'Senior Pastor',			// Title
							'mailto:kevinb&#x40;ebcrochester.org',	// Email
							'/images/staff/Kevin_small.jpg',
							'/images/staff/Kevin.jpg',
							'Kevin Binkley is our Senior Pastor. Kevin grew up in the Elkton, Minnesota area and operated a farm and construction company prior to going to Seminary in 2001. He was called to Emmanuel in July of 2005 after graduating from the Southern Baptist Theological Seminary in Louisville, Kentucky. Kevin strives to teach the word of God faithfully. He longs to see people come to know God and be filled with wisdom and understanding through God\'s Word. Kevin and Heidi have been married for over 25 years and have two grown children.' );

staff[i++] = new Array( 	'yes',						// Show on sidebar?
							'Jeremy Luman',				// Name
							'Pastor Jeremy',			// Informal name
							'Worship Pastor',			// Title
							'mailto:jeremy&#x40;ebcrochester.org',	// Email
							'/images/staff/Jeremy_small.jpg',
							'/images/staff/Jeremy.jpg',
							'Jeremy Luman is our Worship Pastor.  Originally from Raleigh, NC, he answered the call to serve our church in July of 2007.  A graduate of Southeastern Baptist Theological Seminary with a degree in Worship Leadership, Jeremy desires to serve the church by challenging them to worship rightly, in all spirit and truth.  As a husband to Leigh and a father to Kristine, Jeremy finds tremendous joy in growing to know his God, his family, and his church.'

//							'The Worship Pastor Search Committee announced on Sunday, June 17th, that Jeremy Lumen was extended an invitation to visit Emmanuel in view of a call!'
//							'Emmanuel Baptist Church is in prayer searching for God\'s servant to fill our Minister of Worship position. If you have questions, suggestions or a resume, contact our search committee chairman, David Sandifer, at search&#x40;ebcrochester.org'
							);

/*
staff[i++] = new Array( 	'no',						// Show on sidebar?
							'Crystal Persons',			// Name
							'Crystal',					// Informal name
							'Staff Assistant',			// Title
							'mailto:crystal&#x40;ebcrochester.org',	// Email
							'/images/staff/Crystal_small.jpg',
							'/images/staff/Crystal.jpg',
							'Crystal Persons is our Staff Assistant. Crystal was born and raised in Apache Junction, Arizona. She attended Faith Baptist Bible College in Ankeny, Iowa, where she obtained her BA in Biblical Studies, with an emphasis in Spanish. Crystal enjoys exercising her gifts by assisting the church and its pastors with numerous administrative details. Crystal is happily married to Chris, who is a Youth Pastor at Grace Community Church in Eyota, Minnesota.' );

staff[i++] = new Array( 	'yes',						// Show on sidebar?
							'Joshua Rhoades',			// Name
							'Pastor Josh',				// Informal name
							'Youth Pastor',				// Title
							'mailto:josh&#x40;ebcrochester.org',	// Email
							'/images/staff/Josh_small.jpg',
							'/images/staff/Josh.jpg',
							'Joshua Rhoades is our Youth Pastor. Josh moved to Minnesota and became a member of Emmanuel after graduating from West Virginia University in 1998 with a BS in Medical Technology. Josh has been Emmanuel\'s Youth Pastor since graduating from Bethel Seminary in 2002 with a Masters Degree in Theology. Josh spends part of his workday in the Microbiology lab at the Mayo Clinic, and the rest of his day in his youth pastorate duties. The desire of Joshua\'s heart is to help young people come into a personal relationship with Christ and to use their lives to serve God faithfully. Josh and his wife Amy have two children. Alaina is two and in June, they welcomed the arrival of a baby boy named Alec.' );
							
*/

var staffCount = i;
var seniorPastorIndex = 0;
var worshipPastorIndex = 1;
var secretaryIndex = 2;
var youthPastorIndex = 3;

var Staff_ShowOnSideBar = 0
var Staff_Name = 1;
var Staff_NickName = 2;
var Staff_Title = 3;
var Staff_Email = 4;
var Staff_SideBarImage = 5;
var Staff_LargeImage = 6;
var Staff_Bio = 7;

// --------------------------------------------------------------------
//
// Handy timer support variables
//

var timerId = null;				// Helps drop a menu that is left up
var mouseOverSubmenu = 0;		// TRUE when the mouse is over a submenu
var mouseOverButton = 0; 		// TRUE when the mouse if over a button
var timeoutMs = 1000;

function pageContentHeader( page ) {	// Common to every primary site page

	// --------------------------------------------------------------------
	//
	// All pages start with the same page information before the page content...
	//	Well, sorta... The main page has the staff information in the left
	//	column, but all other pages have their own category navagation in the
	//	left column.
	//

	document.writeln( '<table class="main">' );

	// First row is the banner image and it spans entire table

	document.writeln( '	<tr>' );

	document.writeln( '		<td colspan="2" class="banner"  style="background-color: #907AB8;" onMouseOver="this.className=\'banner bannerHover\'; navbar();" onMouseOut="this.className=\'banner\';" onClick="window.location=\'/index.html\';">' );
	document.writeln( '			<img alt="Emmanuel Baptist Church Banner" src="/images/banner-kls.jpg" style="float: left;" /> <div class="churchname"><span class="churchname">Emmanuel Baptist Church</span><br /><span class="churchaddr">2911 18th Ave NW<br />Rochester, Minnesota<br />507-289-7244<br />ebcrochester.org</span></div>' );
	document.writeln( '		</td>' );

	document.writeln( '	</tr>' );

	// Second row is the navagation roll-over buttons

	document.writeln( '	<tr class="noprint">' );

	document.writeln( '		<td class="sideBar firstSideBar" onMouseOver="navbar();"></td>' );

							navBarButtons();

	document.writeln( '	</tr>' );

	// Third row is the content row, with staff pictures in first column

	document.writeln( '	<tr>' );

	document.writeln( '		<td class="sideBar" onMouseOver="navbar();">' );

							if ( page == 'main' ) {
//								staffSideBar();
								scheduleSideBar();
							} else {
								navSideBar( page );
							}

	document.writeln( '		</td>' );

	// This table data tag marks the start of page specific content

	document.writeln( '		<td class="content" onMouseOver="navbar();">' );

}

function pageContentFooter( page ) {	// Common to every primary site page
	
	// --------------------------------------------------------------------
	//
	// All pages have the same page information following the unique page content
	//

	// This table data end tag marks the end of the page specific content

	document.writeln( '		<br />' );
	document.writeln( '		</td>' );

	document.writeln( '	</tr>' );

	// Next row is salvation invitation

	if ( page == 'main' && 1 == 0 ) {		// Only on main page

		document.writeln( '	<tr>' );

		document.writeln( '		<td class="sideBar" onMouseOver="navbar();"></td>' );

								salvation();

		document.writeln( '	</tr>' );

	}

	// Next row is miscellaneous navagation aids

	document.writeln( '	<tr>' );

	document.writeln( '		<td class="sideBar" onMouseOver="navbar();"></td>' );

							bottomNavButtons();

	document.writeln( '	</tr>' );

	// Last row is stats and maintanence

	document.writeln( '	<tr>' );

	document.writeln( '		<td class="sideBar" onMouseOver="navbar();"></td>' );

							bottomInfoButtons( page );

	document.writeln( '	</tr>' );
	
	if ( page == 'main' || 1 ) {
		document.writeln( '		<tr><td class="sideBar" onMouseOver="navbar();"></td>' );
		document.writeln( ' 	<td><div class="copyright"> <a class="secretlink" href="http://validator.w3.org/check?uri=referer">C</a>opyright &copy; 2005-2010 Emmanuel Baptist Church </div></td></tr>' );
	}

	document.writeln( '</table>' );

	// The "pull-down" menus that appear when you "hover" over a
	//	navagation bar item are actually hidden divisions placed
	//	at absolute locations on the web page to appear to be
	//	related to the navagation bar.

	createNavBarPopUps();
	
	document.writeln( '<script type="text/javascript">' );
	document.writeln( 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");' );
	document.writeln( 'document.write(unescape("%3Cscript src=' + "'" + '" + gaJsHost + "google-analytics.com/ga.js' + "'" + ' type=' + "'" + 'text/javascript' + "'" + '%3E%3C/script%3E"));' );
	document.writeln( '</script>' );
	document.writeln( '<script type="text/javascript">' );
	document.writeln( 'try {' );
	document.writeln( 'var pageTracker = _gat._getTracker("UA-12468850-2");' );
	document.writeln( 'pageTracker._trackPageview();' );
	document.writeln( '} catch(err) {}</script>' );

}

function getLeft( obj ) {			// Used by navbar()

	var ol = obj.offsetLeft;

	if ( obj.offsetParent != null ) {
		ol += getLeft( obj.offsetParent );
	}

	return( ol );

}

function getTop( obj ) {			// Used by navbar()

	var ot = obj.offsetTop;

	if ( obj.offsetParent != null ) {
		ot += getTop( obj.offsetParent );
	}

	return( ot );

}

function navbar( navbutton ) { 		// The heart of the primay pop-up navagation bar common to all primary pages

	// --------------------------------------------------------------------
	//
	// This routine will always hide all layers, then if any argument is
	//	passed that looks like a submenu layer name, that layer will be
	//	made visible.
	//

	var submenu = null;
	if ( navbutton != null ) {
		submenu = navbutton + 'sub';
	}

	var divList = document.getElementsByTagName( 'div' );

	for ( var i = 0; i < divList.length; i++ ) {

		var div = divList.item( i );

		if ( submenu != null && div.id == submenu ) {

			var tdList = document.getElementsByTagName( 'td' );

			for ( var j = 0; j < tdList.length; j++ ) {

				var td = tdList.item( j );

				if ( td.id == navbutton ) {

					var ol = getLeft( td ) + 1;
					var ot = getTop( td ) + td.offsetHeight;

					div.style.left = ol + 'px';
					div.style.top = ot + 'px';

					div.style.visibility = 'visible';

					// Set timer to help drop menus left up
					timerId = setTimeout( 'timerPop()', timeoutMs );

				}

			}

		} else if ( div.className == 'navBarSubMenu' ) {

			div.style.visibility = 'hidden';

		}

	}

}

function timerPop() {				// Used by navbar()

	// --------------------------------------------------------------------
	//
	// This routine is called when a timer goes off... drop all submenus
	//	if it appears that a menu was left up accidentally. This can sometimes
	//	happen when the mouse leaves a navBarButton only to fly over a part
	//	of the document or window that is not part of the page.
	//

	if ( mouseOverSubmenu || mouseOverButton ) {

		// Re-establish the timer
		timerId = setTimeout( 'timerPop()', timeoutMs );

	} else {

		timerId = null;		// No timer running

		navbar();			// Drop all submenus

	}


}

function navBarButtons() {			// Emit the html to present the buttons for the navagation bar

	// --------------------------------------------------------------------
	//
	// This routine places the navagation buttons in the row below the banner
	//

	document.writeln( '<td class="navBar">' );
	document.writeln( '<table class="navBar">' );

	for ( var i = 0; i < navBarButtonCount; i++ ) {

		document.writeln( '<td id="' + navBar[i][0][0] + '" class="navBarButton" onMouseOver="this.className=\'navBarButton navBarButtonHover\'; window.status=\'' + navBar[i][0][3] + '\'; navbar(\'' + navBar[i][0][0] + '\'); mouseOverButton=1;" onMouseOut="this.className=\'navBarButton\'; mouseOverButton=0;" onClick="window.location=\'' + navBar[i][0][3] + '\';">' + navBar[i][0][1] + '&nbsp;&nbsp;<img src="/images/pulldownarrow.gif" alt="downarrow" /></td>' );

	}

	document.writeln( '</table>' );
	document.writeln( '</td>' );

}

function navSideBar( page ) { 		// This is the output on the sidebar of all secondary pages

	// --------------------------------------------------------------------
	//
	// This routine is called to fill the left sidebar on all secondary
	//	web pages (not the main index.html page).
	//

	for ( var i = 0; i < navBarButtonCount; i++ ) {

		if ( navBar[i][0][0] == page ) {

			document.writeln( "<p class='sideBarMotto'>" + navBar[i][0][2] + "<span class='sideBarMotto'>!</span></p><br />" );

			for ( var j = 1; navBar[i][j] != null; j++ ) {

				document.writeln( '<a class="sideBar" href="' + navBar[i][j][1] + '">' + navBar[i][j][0] + '</a><br /><br />' );

			}

		}

	}

}

function playWelcomeVideo() { 		// This is the output on the sidebar of the main page

	var w = window.open( "", "", "width=600,height=560" );
	
	w.document.write( 
'<?xml version="1.0" encoding="utf-8" ?>' +
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' +
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">' +
'<head>' +
'<title>Welcome to Emmanuel Baptist Church</title>' +
'<style type="text/css">' +
'	h2 { text-align: center; }' +
'	body { background-color: #F2F1F6;; margin: 15px; font-family: serif; font-size: 16px; color: #907AB8; }' +
'</style>' +
'</head>' +
'<body>' +
'<h2>Welcome to Emmanuel Baptist Church</h2>' +
'<div style="text-align: center;">' +
'	<embed src="http://godtube.com/flvplayer.swf" FlashVars="viewkey=835d6e4b033816ab0721" autostart="true" wmode="transparent" quality="high" width="555" height="454" name="godtube" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </embed>' +
'<br />' +
'	<span ' +
'		onmouseover="this.style.textDecoration=\'underline\'; this.style.color=\'#009\'; this.style.cursor=\'pointer\';"' +
'		onmouseout="this.style.textDecoration=\'none\'; this.style.color=\'#907AB8\'; this.style.cursor=\'default\';"' +
'		onclick="window.close();">' +
'		Close Window' +
'	</span>' +
'</div>' +
'</body>' +
'</html>' );
	
	w.document.close();
	
	w.focus();

}

function scheduleSideBar() { 	// This is the output on the sidebar of the main page

	// --------------------------------------------------------------------
	//
	// This routine is called to fill the left sidebar on the main
	//	index.html page. There is a welcome from the pastor, an
	//	invitation to meet the staff and a worship schedule
	//
	
	// Worship Schedule
	
	document.writeln( "<div>" );
	document.writeln( '	<p class="s_ann"><span class="s_annhdr">-- Sunday Morning --</span><br /><br /> ' );
	document.writeln( '	<span class="s_time">9:15am</span><br /> ' );
	document.writeln( '		Bible Study for All Ages<br /> ' );
	document.writeln( '		Child Care<br /><br /> ' );
	document.writeln( '	<span class="s_time">10:30am</span><br /> ' );
	document.writeln( '		Blended Worship<br /> ' );
	document.writeln( '		Child Care<br /><br /></p> ' );
//	document.writeln( '	<p class="s_ann"><span class="s_annhdr">-- Sunday Evening --</span><br /><br /> ' );
//	document.writeln( '	<span class="s_time">5:30pm</span><br /> ' );
//	document.writeln( '		Youth Choir <br /><br /> ' );
//	document.writeln( '	<span class="s_time">6:30pm</span><br /> ' );
//	document.writeln( '		Worship &amp; Bible Study<br />- Drilling Deeper -<br /> ' );
//	document.writeln( '		Child Care<br /><br /> ' );
//	document.writeln( '		</p> ' );
	document.writeln( '	<p class="s_ann"><span class="s_annhdr">-- Wednesday Evening --</span><br /><br /> ' );
	document.writeln( '	<span class="s_time">6:45pm</span><br /> ' );
	document.writeln( '		Children\'s Ministries<br /><br /> ' );
	document.writeln( '	<span class="s_time">7:00pm</span><br /> ' );
	document.writeln( '		Middle School Bible Study Groups<br /> ' );
	document.writeln( '		Adult Bible Study &amp; Corporate Prayer<br /> ' );
	document.writeln( '		Child Care<br /><br /> ' );
	document.writeln( '		</p> ' );
	document.writeln( "</div>" );

	// Pastor's Welcome
	
	document.write( "<hr />" );
	document.write( "<div> <span style='color: #FFFFFF; font-weight: bold; font-size: 24px; font-family: \"Monotype Corsiva\", serif;'>Welcome!</span> " );
	var omover = "this.style.cursor='pointer';this.src='/images/welcome.gif';";
	var omout = "this.style.cursor='default';this.src='/images/play.gif';";
	var oclick = 'playWelcomeVideo();'
	document.write( '<br /><img style="display: block; margin-left: auto; margin-right: auto;" src="/images/play.gif" alt="Play Welcome Video" title="Play Welcome Video" onmouseover="' + omover + '" onmouseout="' + omout + '" onclick="' + oclick + '" />' );
	document.write( "<span style='color: #FFFFFF; font-size: 12px; font-family: serif;'>from Pastor Kevin</span>" );
	document.writeln( "</div>" );
	
	// Meet the staff
	
	document.write( "<hr />" );
	document.write( "<div>" );
	document.write( "<a class='navBar' href='/staff.html'>" );
	document.write( "<img style='display: block;' alt='EBC Staff' title='EBC Staff' src='/images/staff/Staff_Photo_KaJ.jpg' width='170' />" );
	document.writeln( "</a></div>" );
	
	// SBC Logo
	
	document.writeln( '<hr /> <img src="/images/sbclogo.jpg" width="95" alt="SBC Logo" />' );
	
}

function staffSideBar() { 			// This is the output on the sidebar of the main page

	// --------------------------------------------------------------------
	//
	// This routine is called to fill the left sidebar on the main
	//	index.html page. Staff information is displayed based on
	//	information found in the staff database at the top of this
	//	file.
	//

//	document.writeln( "<br />" );

	for ( var i = 0; i < staffCount; i++ ) {

	    var refname = substitute( staff[i][Staff_Name], ' ', '' );
	
		if ( staff[i][Staff_ShowOnSideBar] == 'yes' ) {

			document.write( "<a class='navBar' href='/staff.html#" + refname + "'>" );
			document.write( "<img alt='" + staff[i][Staff_NickName] + "' src='" + staff[i][Staff_SideBarImage] + "' /><br />" );
			document.write( "<span class='staffname'>" + staff[i][Staff_Name] + "</span><br />" );
			document.write( "<span class='stafftitle'>" + staff[i][Staff_Title] + "</span></a>" );
			
			if ( i == seniorPastorIndex ) {
				var omover = "this.style.cursor='pointer';this.src='/images/welcome.gif';";
				var omout = "this.style.cursor='default';this.src='/images/play.gif';";
				var oclick = 'playWelcomeVideo();'
				document.write( '<br /><img src="/images/play.gif" alt="Play Welcome Video" title="Play Welcome Video" onmouseover="' + omover + '" onmouseout="' + omout + '" onclick="' + oclick + '" />' );
			}
			
			document.writeln( "<br /><br />" );

		}

	}
	
//	document.writeln( '<hr /><a href="/misc/php/VerseOfTheWeek.php"><img width="95" src="/images/MemoryVerseOfTheWeek-icon.gif" alt="Memory Verse of the Week" /></a>' );
	
//	document.writeln( '<hr /> <a href="http://www.salvationhosting.com/" target="_blank"><img src="http://www.salvationhosting.com/salvationhosting100.gif" width="100" height="100" alt="SalvationHosting.com" /></a>' );
	
	document.writeln( '<hr /> <img src="/images/sbclogo.jpg" width="95" alt="SBC Logo" />' );

}

function substitute( inputstr, searchstr, replacestr ) { // Helper class to do substitutions

	var outputstr = "";

	for ( var i = 0; i < inputstr.length; ) {
	
	    var c = inputstr.substring( i, i+searchstr.length );
	
	    if ( c == searchstr ) {
			outputstr = outputstr + replacestr;
			i += searchstr.length;
		} else {
			outputstr = outputstr + c;
			i++;
		}
	
	}

	return( outputstr );
	
}

function staffReference( staffIndex ) { // Create a reference to a staff member

	var refname = substitute( staff[staffIndex][Staff_Name], ' ', '' );

	document.write( "<a href='/staff.html#" + refname + "'>" );
	document.write( "	<img alt='" + staff[staffIndex][Staff_NickName] + "' src='" + staff[staffIndex][Staff_SideBarImage] + "' /><br />" );
	document.write( "	<span class='staffname'>" + staff[staffIndex][Staff_Name] + "</span><br />" );
	document.write( "	<span class='stafftitle'>" + staff[staffIndex][Staff_Title] + "</span>" );
	document.writeln( "</a>" );
	
	if ( staffIndex == seniorPastorIndex ) {
		var omover = "this.style.cursor='pointer';this.src='/images/welcome.gif';";
		var omout = "this.style.cursor='default';this.src='/images/play.gif';";
		var oclick = 'playWelcomeVideo();'
		document.writeln( '<br /><img src="/images/play.gif" alt="Play Welcome Video" title="Play Welcome Video" onmouseover="' + omover + '" onmouseout="' + omout + '" onclick="' + oclick + '" />' );
	}

}

function staffContent() { 			// This is the content on the staff page

	// --------------------------------------------------------------------
	//
	// Fill the staff page from the staff database. This information is
	//	almost the same info presented on the main page's left sidebar
	//	only that larger pictures are dislpayed and some staff memeber
	//	who were left off the main page sidebar are included here...
	//	See the staff database at the top of this file for reference.
	//

/*
	document.writeln( "<div>" );
	document.writeln( "<img style='float: left; display: block; border: none; margin: 10px;' src='/images/staff/Staff_Photo.jpg' width='350' />" );
	document.writeln( "<span style='font-size: 28px;'>Meet Our Staff</span><br />" );
	document.writeln( "From left to right, <a href='#JeremyLuman'>Jeremy</a>, <a href='#JoshuaRhoades'>Josh</a>, <a href='#CrystalPersons'>Crystal</a> and <a href='#KevinBinkley'>Kevin</a>" );
	document.writeln( "</div>" );
*/

	document.writeln( "<table style='margin: 8px; background-color: #F2F1F6; border-collapse: separate; clear: both;'>" );

	for ( var i = 0; i < staffCount; i++ ) {
	
	    var refname = substitute( staff[i][Staff_Name], ' ', '' );
	
	    if ( i != 0 ) {
			document.writeln( "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>" );
		}
		document.writeln( "<tr>" );
		document.writeln( "<td style='padding: 0.5mm; border: 4px outset #B6E4E2; background-color: #B6E4E2;'>" );
		document.writeln( "		<a name='" + refname + "'><img alt='" + staff[i][Staff_Name] + "' src='" + staff[i][Staff_LargeImage] + "' /></a>" );
		document.writeln( "</td>" );
		document.writeln( "<td style='padding: 2mm; border: 2px none #F0E0F0;'>" );
		document.writeln( "		<p style='color: black;'>"  + staff[i][Staff_Bio] + "</p>" );
		document.writeln( "	    <p> <a class='content' href='" + staff[i][Staff_Email] + "'> Contact " + staff[i][Staff_Name] + "</a>" );
	
		if ( i == seniorPastorIndex ) {
			var omover = "this.style.cursor='pointer';this.src='/images/welcome.gif';";
			var omout = "this.style.cursor='default';this.src='/images/play.gif';";
			var oclick = 'playWelcomeVideo();'
			document.writeln( '<br /><img src="/images/play.gif" alt="Play Welcome Video" title="Play Welcome Video" onmouseover="' + omover + '" onmouseout="' + omout + '" onclick="' + oclick + '" />' );
		}
		
		document.writeln( "</td>" );
		
		document.writeln( "</tr>" );

	}
	
	document.writeln( "</table>" );

}

function salvation() {

	// --------------------------------------------------------------------
	//
	// Display an invitation to salvation using an appealing picture linked
	//	to the plan of salvation.
	//

	document.writeln( '	<td class="content">' );
	document.writeln( '		<a href="salvation.html"><center><img alt="Am I in Christ?" src="/images/salvation/salvation_flowers.jpg"></center></a>' );
	document.writeln( '	</td>' );

}

function bottomNavButtons() {

	// --------------------------------------------------------------------
	//
	// Just above the bottom of the page is a row of icons linked to some
	// 	common resources. Build that row of buttons now. These buttons
	// 	appear on the main page and ever secondary page.
	//

	document.writeln( '<td class="content noprint" style="padding: 0px;">' );
	document.writeln( '	<table style="width: 100%;">' );

	document.writeln( '	<td class="content" style="padding: 0px; width: 33%; text-align: center;" onMouseOver="navbar();">' );
	document.writeln( '		<a class="content" href="/salvation.html"><img alt="" src="/images/navicons/invitation.jpg"></a>' );
	document.writeln( '	</td>' );

//
//
//	document.writeln( '	<td class="content" style="padding: 0px;" onMouseOver="navbar();">' );
//	document.writeln( '		<a class="content" href="/pastorsearch.html"><img alt="" src="/images/navicons/pastorsearch.jpg"></a>' );
//	document.writeln( '	</td>' );
//
//

	document.writeln( '	<td class="content" style="padding: 0px; width: 33%; text-align: center;" onMouseOver="navbar();">' );
	document.writeln( '		<a class="content" href="/location.html"><img alt="" src="/images/navicons/findus.jpg"></a>' );
	document.writeln( '	</td>' );

	document.writeln( '	<td class="content" style="padding: 0px; width: 33%; text-align: center;" onMouseOver="navbar();">' );
	document.writeln( '		<a class="content" href="/calendar.html"><img alt="" src="/images/navicons/calendar.jpg"></a>' );
	document.writeln( '	</td>' );

	document.writeln( '</table>' );
	document.writeln( '</td>' );

}

function bottomInfoButtons( page ) { // Places page info common to all pages at the bottom

	// --------------------------------------------------------------------
	//
	// At the very bottom of the page is some common information
	//	including the last date when this file was modified and
	//	how to contact the webmaster to report problems or suggestions.
	//	On the main page, a visitor counter is displayed.
	//

	document.writeln( '<td class="content" style="padding: 0px;">' );
	document.writeln( '	<table style="width: 100%">' );

	document.writeln( '		<td class="content mod" onMouseOver="navbar();">' );
//	document.writeln( '			<span style="font-size: 8pt;">' );
//								fileModificationDate();
//	document.writeln( '			</span>' );
	document.writeln( '			<span class="noprint" style="font-size: 8pt;"><br /> Suggestions? Corrections? <a style="font-size: 8pt; font-weight: normal;" href="/webmaster.php">Tell the Webmaster!</a>' );
	document.writeln( '		</td>' );

	if ( page == 'main' ) {
	document.writeln( '		<td class="content guest" style="text-align: right;">Yo<a style="font-size: 10pt; text-decoration: none; font-weight: normal;" href="http://godaddy.com">u</a> are <a style="font-size: 10pt; text-decoration: none; font-weight: normal;" href="http://email.ebcrochester.org">g</a>ues<a style="font-size: 10pt; text-decoration: none; font-weight: normal;" href="/cal">t</a>&nbsp; <img style="vertical-align: bottom;" src="/cgi/countbmp.php?counter=ebc&bg=F3F0F7&fg=907AB8" alt="2247" /></td>' );
	}

	document.writeln( '	</table>' );
	document.writeln( '</td>' );

}

function createNavBarPopUps() { 	// Each nav pop-up needs a hidden division
	
	// --------------------------------------------------------------------
	//
	//	Create the hidden navBar "pop-up" divisions
	//

	for ( var i = 0; i < navBarButtonCount; i++ ) {

		var divName = navBar[i][0][0] + 'sub';

		document.writeln( '<div id="' + divName + '" class="navBarSubMenu" onMouseOver="mouseOverSubmenu=1;" onMouseOut="mouseOverSubmenu=0;">' );

		document.writeln( '	<layer>' );

		document.writeln( '		<table class="navBarSubMenu">' );

		for ( var j = 1; navBar[i][j] != null; j++ ) {

			document.writeln( '			<tr>' );
			document.writeln( '				<td class="navBarSubMenu" onMouseOver="this.className=\'navBarSubMenu navBarSubMenuHover\';" onMouseOut="this.className=\'navBarSubMenu\';" onClick="window.location=\'' + navBar[i][j][1] + '\';">' );
			document.writeln( '					' + navBar[i][j][0] );
			document.writeln( '				</td>' );
			document.writeln( '			</tr>' );

		}

		document.writeln( '		</table>' );

		document.writeln( '	</layer>' );

		document.writeln( '</div>' );

	}

}

function fileModificationDate() { 	// Emits the file's last modification date
	
	// --------------------------------------------------------------------
	//
	// Display the file modification date
	//

	var lastmod = document.lastModified;     // get string of last modified date
	var lastmoddate = Date.parse( lastmod ); // convert modified string to date
	if ( lastmoddate != 0 ) {
		document.writeln( "LastModified: " + lastmod );
	}

}

function makeRainbow( text ) { 		// Creates an HTML stream that presents each letter in different color

	text = text.substring( 0, text.length );
	
	color_d1 = 255;
	mul = color_d1 / text.length;
	
	for ( var i = 0; i < text.length; i++ ) {

		color_d1 = 255 * Math.sin( i / ( text.length / 3 ) );
		color_d2 = mul * i;

		k = text.length;
		j = k - i;
		if ( j < 0 ) {
			j = 0;
		}
		color_d3 = mul * j;

		document.write( "<span style='color: rgb(" + color_d3 + "," + color_d1 + "," + color_d2 + ");'>" );
		document.write( text.substring( i, i + 1 ) );
		document.write( "</span>" );

	}

}

function contactUsValidator( validate ) { // Used by the email feedback forms
	
	//
	// This routine is the heart of the form validation on the
	//	contactus.html page.
	//

	// Only can validate a form named 'contactus'

	form = document.getElementById( 'contactus' );

	var valid = true;					// Assume the best

	if ( form.subject.value == 'none' ) {
		window.alert( "Please select a subject from the 'Subject:' selection list." );
		valid = false;
	}

	if ( valid && form.email.value != null ) {
		var email = form.email.value;
		email = email.replace( /^\s+|\s+$/g, '' );
		if ( email != '' ) {
			if ( email.indexOf( ' ' ) != -1 ) {
				window.alert( "Your email address appears to have a space character... this is not allowed." );
				valid = false;
			}
			if ( valid && email.indexOf( '@' ) == -1 ) {
				window.alert( "Your email address is missing an '@' character... this is not allowed." );
				valid = false;
			}
			if ( valid && email.indexOf( '@' ) == 0 ) {
				window.alert( "Your email address begins with an '@' character... this is not allowed." );
				valid = false;
			}
			if ( valid && email.indexOf( '@' ) == ( email.length - 1 ) ) {
				window.alert( "Your email address ends with an '@' character... this is not allowed." );
				valid = false;
			}
			if ( valid ) {
				var parts = email.split( '@' );
				if ( parts.length > 2 ) {
					window.alert( "Your email address has more than one '@' character... this is not allowed." );
					valid = false;
				}
			}
		}
	}

	if ( valid ) {
		var comments = form.feedback.value;
		comments = comments.replace( /^\s+|\s+$/g, '' );
		if ( comments == '' ) {
			window.alert( "You haven't yet entered a comment... we need to hear from you !" );
			valid = false;
		}
	}

	if ( ! validate ) {

		if ( valid ) {

			if ( form.subject.value == 'Web Page Correction' ||
			     form.subject.value == 'Web Site Suggestion' ) {
				form.recipient.value = form.webmaster.value;
			} else {
				form.recipient.value = form.pastor.value;
			}

		}

		if ( valid && form.realname.value == '' ) {
			form.realname.value = "Anonymous";
		}

		if ( valid && form.email.value == '' ) {
			form.email.value = "anonymous@someplace.net";
		}

	}

	/*
	window.status = 'recipient=[' + form.recipient.value + '] ' +
					'subject=[' + form.subject.value + '] ' +
					'realname=[' + form.realname.value + '] ' +
					'email=[' + form.email.value + '] ' +
					'feedback=[' + form.feedback.value + ']'
					;
	*/

	return( valid );

}

function siteMap() { 				// List all the links on the navagation pulldowns in one page
	
	//
	// Generate the HTML to display the complete site map. This is just a
	//	table that reflects the contents or the navagation bar database.
	//

	document.writeln( '<h1>Site Map</h1>' );

	document.writeln( '<table class="tab">' );

	for ( var i = 0; i < navBarButtonCount; i++ ) {

		document.writeln( '<tr>' );


		document.writeln( '<td style="width: 50%;"><span style="font-size: 150%; font-weight: bold;">' + navBar[i][0][1] + '</span><br /><a href="' + navBar[i][0][3] + '">' + navBar[i][0][2] + '!</a></td>' );

		document.writeln( '<td>' );

		for ( var j = 1; navBar[i][j] != null; j++ ) {

			if ( j != 1 ) {
				document.writeln( '<br />' );
			}

			document.writeln( '<a href="' + navBar[i][j][1] + '">' + navBar[i][j][0] + '</a>' );

		}

		document.writeln( '</td>' );
		document.writeln( '</tr>' );

	}

	document.writeln( '</table>' );

}

function worshipSchedule( summer ) { 		// Makes the home page index easier to read and update
	
	//
	// Output the worship schedule table
	//

	document.writeln( '	<table class="unbordered"> ' );
	document.writeln( '		<tr> ' );
	document.writeln( '			<td width="33%"> ' );
	document.writeln( '				<p class="w_ann"><span class="w_annhdr">-Sunday Morning-</span><br /><br /> ' );
//	document.writeln( '				<span class="w_time">8:00am</span><br /> ' );
//	document.writeln( '					Contemporary Worship<br /> ' );
//	document.writeln( '					Praise Band<br /> ' );
//	document.writeln( '					Child Care<br /><br /> ' );
	document.writeln( '				<span class="w_time">9:15am</span><br /> ' );
	document.writeln( '					Bible Study for All Ages<br /> ' );
	document.writeln( '					Child Care<br /><br /> ' );
	document.writeln( '				<span class="w_time">10:30am</span><br /> ' );
	document.writeln( '					Blended Worship<br /> ' );
	document.writeln( '					Child Care<br /><br /></p> ' );
	document.writeln( '			</td> ' );
	document.writeln( '			<td width="33%"> ' );
	document.writeln( '				<p class="w_ann"><span class="w_annhdr">-Sunday Evening-</span><br /><br /> ' );
	document.writeln( '				<span class="w_time">6:30pm</span><br /> ' );
	document.writeln( '					Worship &amp; Bible Study<br />- Drilling Deeper -<br /> ' );
//	document.writeln( '					Child Care<br /> ' );
//	document.writeln( '					<br /> ' );
//	document.writeln( '				<span class="w_time">6:30pm</span><br /> ' );
//	document.writeln( '					Youth-Led Worship<br /> ' );
//	document.writeln( '					Praise Band<br /> ' );
//	document.writeln( '					Sunday Night Live<br /> ' );
//	document.writeln( '					Child Care<br /><br /> ' );
	document.writeln( '					</p> ' );
	document.writeln( '			</td> ' );
	document.writeln( '			<td width="33%"> ' );
	document.writeln( '				<p class="w_ann"><span class="w_annhdr">-Wednesday Evening-</span><br /><br /> ' );
	if ( summer != 'summer' ) {
	document.writeln( '				<span class="w_time">6:00pm</span><br /> ' );
	document.writeln( '					Fellowship Supper<br /><br /> ' );
	}
//	document.writeln( '				<span class="w_time">6:00pm</span><br /> ' );
//	document.writeln( '					High School Bible Study Groups<br /> ' );
//	document.writeln( '					<br /> ' );
	document.writeln( '				<span class="w_time">6:45pm</span><br /> ' );
	document.writeln( '					Team KID, Royal Ambassadors<br /> ' );
	document.writeln( '					Children\'s Ministries<br /><br /> ' );
	document.writeln( '				<span class="w_time">7:00pm</span><br /> ' );
//	document.writeln( '					<i>CrossTalk</i><br /> ' );
//	document.writeln( '					<i>Discipleship Choices</i><br /> ' );
	document.writeln( '					Middle School Bible Study Groups<br /> ' );
	document.writeln( '					Adult Bible Study &amp; Corporate Prayer<br /> ' );
//	document.writeln( '					Child Care' );
	document.writeln( '					</p> ' );
	document.writeln( '			</td> ' );
	document.writeln( '		</tr> ' );
	document.writeln( '	</table> ' );

}


function doadd( n ) {

    // e.g. <script type="text/javascript">doadd( "richwilliamson","*","pitel","net");</script>

	var ea = n;
	
	// do it the hard way 8-(
	
	var adddot = 1;
	
	for ( var i = 1; i < arguments.length; i++ ) {
	
		if ( arguments[i] == '*' ) { 
			ea += '&#64;';
			adddot = 0;
		} else if ( arguments[i] != '' ) {
			if ( adddot ) {
				ea += '.';
			}
			ea += arguments[i];
			adddot = 1;
		}
	
	}

	document.write( "<a class='liame' href='mailto:" + ea + "'>" + ea + "</a>" );
	
}

//
//	This script helps display slideshows...
//
//	Step 1: Replace your <body> statement with one that looks like this:
//
//		<body onload="runSlideShow( '/misc/promos/ChurchPicnic/2006/2006 Oxbow Park Picnic ', '-300.jpg', '001', '002', '003' )">
//
//		The first parm is the directory where each image file lives. If 
//			your images are all over the world, just use '' for the first
//			parm.
//
//		The second parm is the "suffix" for each image file. If 
//			your images are all over the world, just use '' for the second
//			parm too.
//
//		The rest of the parms are the individual images you want as part
//			of the slideshow.
//
//	Step 2: Place an image like this some where in your document:
//
//		<img src="/misc/promos/ChurchPicnic/2006/2006 Oxbow Park Picnic 001-300.jpg" name="SlideShow" alt="2006 Oxbow Park Church Picnic" width="300" height="225" />
//
//		It does help the layout to have all images be the same size, or 
//			at least use a width and height for the largest image.
//		NOTE: Your image must have the unique name "SlideShow".
//
//	Step 3: Watch it!
//

var slPics = new Array();		// Array to hold URLs of images to display
var slPreLoad = new Array();	// Array to hold pre-loaded images
var slCurrent = 0; 				// The image currently being displayed

function runSlideShow() {

	// The first time this routine is invoked, it passes the
	// directory as the first argument and image file names 
	// in all the other arguments. 
	//
    if ( runSlideShow.arguments.length > 0 ) {
	
		var dir = runSlideShow.arguments[0];
		var suf = runSlideShow.arguments[1];
		
		for ( var i = 2; i < runSlideShow.arguments.length; i++ ) {
			slPics[ i-2 ] = dir + runSlideShow.arguments[i] + suf;
		}
	
	}

	var next = ( slCurrent + 1 ) % slPics.length;
	var delayThisTime = 5000;		// 5 seconds
	
	// If there is an image object in the next slot and that
	// object appears ready (complete), then set the document image
	if ( slPreLoad[next] && ( slPreLoad[next].complete || slPreLoad[next].complete == null ) ) {
	
		if ( document.all ) {
			document.images.SlideShow.style.filter = "blendTrans(duration=1)"
			document.images.SlideShow.filters.blendTrans.Apply()      
		}
		
		// The image in the document must have a name="SlideShow"
		document[ "SlideShow" ].src = slPreLoad[ next ].src;
		
		if ( document.all ) {
			document.images.SlideShow.filters.blendTrans.Play();
		}
		
		slCurrent = next;			// We can begin preloading the next image
		next = ( slCurrent + 1 ) % slPics.length;
		
	}

	if ( ! slPreLoad[next] ) {
		slPreLoad[ next ] = new Image;
		slPreLoad[ next ].src = slPics[ next ];
	} else if ( ! slPreLoad[next].complete && slPreLoad[next].complete != null ) {
		// There is an image object in the next slot, 
		// but it isn't loaded yet... no use trying
		// to change the document image until it comes
		// in... poll more often.
		delayThisTime = 200;		// 0.2 seconds
	}
	
//	window.status = "delayThisTime=[" + delayThisTime + "] slCurrent=[" + slCurrent + "]";
	
	setTimeout( "runSlideShow()", delayThisTime );
	
}

