/*
	script_map.js
	
	Scripts for MAP page of hernowornowhere.com
	Copyright (C)2009 Gordon Hicks, all rights reserved
*/


	// Page Initialization
	window.onload = init;
	function init() {
		splash();
		initMap();
	}

	// so we can track of the load state of these image...
	var splashImage = new Image();
	splashImage.src = "img/splash.gif";


	function splash() {
		// if not showSplash, then bail out..
		if ( !showSplash ) return;
		// start the clock...
		resetTimer();
		// go...
		resetTimer();
		splashShow();
	}
	
	function splashShow() {
		// waiting on image load...
		// ** does this thing work? ??
		if ( !splashImage.complete) {
			// not yet...
			if ( elapsed() < 4000 ) { // ms - time to wait for splash image to load
				// keep checking...
				setTimeout("splashShow()",100);
			} else {
				// too long - bail out
				document.getElementById('page').style.visibility = 'visible' ;
				return;
			}	
		} 
		// ok, go...
		resetTimer();
		document.getElementById('body').style.backgroundColor = '#FFFF00' ;
		document.getElementById('splash').style.visibility = 'visible' ;
		document.getElementById('splash').style.zIndex = '3' ;
		setTimeout("splashHide()",4000); // ms - how long to show splash page
	}

	function splashHide() {
		if ( !document.getElementById )  return;
		document.getElementById('splash').style.visibility = 'hidden' ;
		document.getElementById('body').style.backgroundColor = 'white' ;
		document.getElementById('splash').style.zIndex = '1' ;
		document.getElementById('page').style.visibility = 'visible' ;
		// set a cookie that expires 3:00 am tomorrow...
		var theDate = new Date(); // today, now
		theDate.setTime( theDate.valueOf() + (21*60*60*1000) ); // 21 hours in future
		var expiryDate = new Date( theDate.getFullYear(), theDate.getMonth(), theDate.getDate(), 3, 0, 0, 0 ); // 3 am tomorrow
		document.cookie = 'skipIntro=true; expires=' + expiryDate.toGMTString();
	}


	function initMap() {
		document.getElementById('mouseover-exhi').style.visibility='hidden';
		document.getElementById('mouseover-dayo').style.visibility='hidden';
		document.getElementById('mouseover-thep').style.visibility='hidden';
		document.getElementById('mouseover-bade').style.visibility='hidden';
		document.getElementById('mouseover-davi').style.visibility='hidden';
		document.getElementById('mouseover-dumo').style.visibility='hidden';
		document.getElementById('mouseover-gold').style.visibility='hidden';
		document.getElementById('mouseover-hann').style.visibility='hidden';
		document.getElementById('mouseover-hort').style.visibility='hidden';
		document.getElementById('mouseover-klei').style.visibility='hidden';
		document.getElementById('mouseover-kohh').style.visibility='hidden';
		document.getElementById('mouseover-mark').style.visibility='hidden';
		document.getElementById('mouseover-mood').style.visibility='hidden';
		document.getElementById('mouseover-peac').style.visibility='hidden';
		document.getElementById('mouseover-sasa').style.visibility='hidden';
		document.getElementById('mouseover-vanh').style.visibility='hidden';
	}


	
	
	function resetTimer() {
		timer = new Date();
	}	

	function elapsed() {
		// calculate elapsed time in ms
		var now = new Date();
		return (now - timer);
	}


