// --------------------------------------------------------------------
//
// master.js (for the yfc quizzing web page)
//

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

	// --------------------------------------------------------------------
	//
	// All pages have the standard navigation aids on the left column.
	//

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

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

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

	document.writeln( '		<td class="side banner" onMouseOver="this.className=\'side banner bannerHover\';" onMouseOut="this.className=\'side banner\';" onClick="window.location=\'http://www.rochesterareayfc.org/\';">' );
	document.writeln( '			<img src="http://rochesterbiblequizzing.org/images/yfclogo.jpg" title="Click here for the Rochester Area Youth for Christ Home Page" alt="Rochester Area Youth for Christ" width="90" />' );
	document.writeln( '		</td>' );
	document.writeln( '		<td class="banner" onMouseOver="this.className=\'banner bannerHover\';" onMouseOut="this.className=\'banner\';" onClick="window.location=\'/index.htm\';" title="Click here for Rochester Area Youth for Christ Bible Quizzing Home Page">' );
	document.writeln( '			Youth for Christ Bible Quizzing' );
	document.writeln( '			<img src="/images/TShirtLogo1-blue.gif" width="140" alt="Over 25 years of Quizzing God\'s Word" title="Over 25 years of Quizzing God\'s Word" style="float: right;" />' );
	document.writeln( '		</td>' );

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

	// Second row is the content row, with navigation links on the left

	document.writeln( '	<tr>' );
    
	if ( page != 'nonav' ) {

	document.writeln( '		<td class="side sideNav noprint">' );

 	document.writeln( '			<table class="sideNavTable">' );
	
 	document.writeln( '			    <tr>' );
 	document.writeln( '					<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/index.htm">Home</a></td>' );
	document.writeln( '				</tr>' );

	document.writeln( '				<tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/BlueSheets.html">Blue Sheet Study Questions</a></td>' );
 	document.writeln( '			    </tr>' );

	document.writeln( '				<tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/RYBQOMC/">Olympic Memory Challenge</a></td>' );
 	document.writeln( '			    </tr>' );
    
 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/Rules.html">Quiz Rules</a></td>' );
 	document.writeln( '			    </tr>' );
    
 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/Quizzing-Scoresheet.pdf">Quizzing Scoresheet</a></td>' );
 	document.writeln( '			    </tr>' );
    
 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/Scorekeeper-Guidelines.pdf">Scorekeeper Guidelines</a></td>' );
 	document.writeln( '			    </tr>' );

 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="http://wbqa.org">World Bible Quiz Association</a></td>' );
 	document.writeln( '			    </tr>' );

 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/Resources.html">Quizzing Resources</a></td>' );
 	document.writeln( '			    </tr>' );

 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/PastResults">Past Results</a></td>' );
 	document.writeln( '			    </tr>' );

 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/Promotion.html">Promotional Materials</a></td>' );
 	document.writeln( '			    </tr>' );

 	document.writeln( '			    <tr>' );
 	document.writeln( '			    	<td><img class="dot" src="/images/dot.gif" width="3" alt="" align="middle" /><a href="/JobDescriptions/JobDescriptions.pdf">Volunteer Job Descriptions</a></td>' );
 	document.writeln( '			    </tr>' );
    
 	document.writeln( '			</table>' );	
	
	document.writeln( '		</td>' );

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

	document.writeln( '		<td class="content">' );
	
	} else {
	
		document.writeln( '		<td colspan="2" class="content">' );
	
	}

}

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>' );
	document.writeln( '	<tr class="noprint">' );
	document.writeln( '		<td colspan="2" style="font-size: 12px; text-align: right; background-color: #F0F0FF;">' );
	document.writeln( '			<a class="hidden_link" href="http://validator.w3.org/check?uri=referer">Y</a>ou are guest <img style="vertical-align: bottom;" src="http://ebcrochester.org/cgi/countbmp.php?counter=yfcquizzing&bg=F0F0FF" alt="2247" /></td>' );
	document.writeln( '	</tr>' );
	
	document.writeln( '</table>' );
	
	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-4");' );
	document.writeln( 'pageTracker._trackPageview();' );
	document.writeln( '} catch(err) {}</script>' );

}


function doadd( n ) {

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

	var name = n;
	var ea = '';
	
	// do it the hard way 8-(
	
	var adddot = 0;
	
	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 href='mailto:" + ea + "'>" + name + "</a>" );
	
}



function dophone( n ) {

    // e.g. <script type="text/javascript">dophone( "555", "123", "4545" );</script>

	var name = n;
	var ea = '';
	
	// do it the hard way 8-(
	
	var adddot = 0;
	
	for ( var i = 0; i < arguments.length; i++ ) {
		
		if ( i > 0 ) {
			document.write( '-' );
		}
	
		document.write( arguments[i] );
	
	}

	
}


//
//	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 ( arguments.length > 0 ) {
	
		var dir = arguments[0];
		var suf = arguments[1];
		
		for ( var i = 2; i < arguments.length; i++ ) {
			slPics[ i-2 ] = dir + 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 );
	
}


