// JavaScript Document

function open_contactWindow()
	{
		window.open("contact.html","_blank","width=550,height=600");
		return false;
	}
	
function countdownTimer()
	{
		// set the current Date and Time
		now = new Date();
		
		// convert to milliseconds since 1/1/70
		fromNow = now.getTime();
		
		// set Reality Bytes start time and convert to milliseconds since 1/1/70
		festivalStart = Date.parse("Apr 1, 2009 22:00:00");
		festivalEnd = Date.parse("Apr 4, 2009 22:00:00");
		timeLeft = festivalStart - fromNow;
		
		// convert milliseconds to days and drop after decimal
		daysLeft = Math.floor(timeLeft/(60*60*1000*24));
		
		// convert what's dropped to hours and drop after decimal
		hoursLeft = Math.floor((timeLeft%(60*60*1000*24))/(60*60*1000));
		
		// convert what's dropped to minutes and drop after decimal
		minutesLeft = Math.floor(((timeLeft%(60*60*1000*24))%(60*60*1000))/(60*1000));
		
		// convert what's dropped to seconds and drop after decimal
		secondsLeft = Math.floor((((timeLeft%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000);
		
		// convert what's dropped to milliseconds and round to two digits
		millisecondsLeft = Math.floor((((timeLeft%(60*60*1000*24))%(60*60*1000))%(60*1000))%1000/10);
		
		// add a zero in front of numbers < 10
		hoursLeft = checkTime(hoursLeft);
		minutesLeft = checkTime(minutesLeft);
		secondsLeft = checkTime(secondsLeft);
		millisecondsLeft = checkTime(millisecondsLeft);
		
		// write result to div
		if (timeLeft > 0)
			{
				document.getElementById("timer").innerHTML="Countdown to Festival Start "+daysLeft+":"+hoursLeft+":"+minutesLeft+":"+secondsLeft+"."+millisecondsLeft;
			}
		else if (festivalEnd - fromNow >= 0)
			{
				document.getElementById("timer").innerHTML="<h3>It's Festival Time!</h3>";
			}
		else
			{
				document.getElementById("timer").innerHTML="<h3>See You in Spring 2010!</h3>";
			}
			
		// refresh every 10 milliseconds
		setTimeout("countdownTimer()",10);
	}
	
			
function checkTime(i)
	{
		if (i<10)
			{
				i="0" + i;
			}
		return i;
	}
	
function explodeMenu(menuNumber)
	{
		var thisMenu = document.getElementById(menuNumber)
		if (thisMenu.style.display == "block")
			{
				thisMenu.style.display = "none";
			}
		else
			{
				thisMenu.style.display = "block";
			}
		return false;
	}
	
function open_Storm()
			{
				window.open("eyesOfStorm.html","_blank","height=450,width=550");
			}
function open_People()
			{
				window.open("aPeopleThing.html","_blank","height=450,width=550");
			}
			

function cyclePoster()
	{
		document.poster.src=posterArray[index].src;
		index++;
		
		if (index>=3)
			{
				index=0;
			}
		setTimeout("cyclePoster()",5000);
		return;
	}
	
	
