// --------------------------------------------------------------------
//
// 	bhh.js (for baptisthospitalityhouse.org)
//
// --------------------------------------------------------------------

function doadd( n ) {

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

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


function load( subPage ) {

	if ( GBrowserIsCompatible() ) {

		var bhhLat = 44.053884;
		var bhhLon = -92.488875;
	
		var latitude = bhhLat; 			// default to BHH
		var longitude = bhhLon;
		var zoom = 14;
		
		if ( subPage == 'HyVee' ) {
			latitude = 44.060;
			longitude = -92.47;
			zoom = 13;
		} else if ( subPage == 'Target' ) {
			latitude = 44.0633011;
			longitude = -92.5031281;
			zoom = 13;
		} else if ( subPage == 'Wal-Mart' ) {
			latitude = 44.0777054;
			longitude = -92.5123291;
			zoom = 13;
		} else if ( subPage == 'StMarys' ) {
			latitude = 44.0202751;
			longitude = -92.4811630;
			zoom = 13;
		} else if ( subPage == 'Methodist' ) {
			latitude = 44.0240669;
			longitude = -92.4662247;
			zoom = 13;
		} else if ( subPage == 'Mayo' ) {
			latitude = 44.0220184;
			longitude = -92.4669724;
			zoom = 13;
		}
	
		var map = new GMap2( document.getElementById( "map" ) );
		
		map.addControl( new GSmallMapControl() );
		
		map.setCenter( new GLatLng( latitude, longitude ), zoom );
		
		var point = new GLatLng( bhhLat, bhhLon );
		var marker = new GMarker( point );
		map.addOverlay( marker );
		marker.openInfoWindowHtml( "Baptist Hospitality House<br />2825 18th Ave NW", 1 );
		
		if ( subPage != 'bhh' && subPage != '' ) { 
		
			var point2 = new GLatLng( latitude, longitude );
			var marker2 = new GMarker( point2 );
			map.addOverlay( marker2 );
			marker2.openInfoWindowHtml( subPage, 1 );
		
		}
		
	}
	
}


//
//	NAME: runSlideShow.js
//
//	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, a common image suffix
	// as the second 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
	}
	
	setTimeout( "runSlideShow()", delayThisTime );
	
}

