var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var crosscount="";
var serverTime = "";
var timeOffset = "";
var futureTime = "";
var newTime = "";
var loaded = 0;
var startClientTime = "";


function start_countdown(servertime,countdownto)
{
	// set the offset once.

 	startClientTime = Date.parse(getTodayString());	
	timeOffset = startClientTime - Date.parse(servertime);
	
	newTime =  Date.parse(countdownto) + timeOffset;

	//alert('server = ' + servertime + "\nfuture is " + countdownto + "\nclient is " + startClientTime + "\noffset is " + timeOffset + "\nnew time = " + newTime);


	if (document.all||document.getElementById)
	{
		countdown();
	}
}


function getTodayString()
{
	var today=new Date()
	var todayy=today.getYear()
	if (todayy < 1000)
	{
		todayy+=1900
	}
	var todaym=today.getMonth()
	var todayd=today.getDate()
	var todayh=today.getHours()
	var todaymin=today.getMinutes()
	var todaysec=today.getSeconds()

	if(todayd  <= 9)		{		todayd 	= "0"+todayd;		}
	if(todayh <= 9)		{		todayh 	= "0"+todayh;		}
	if(todaymin  <= 9)	{		todaymin 	= "0"+todaymin;		}
	if(todaysec  <= 9)	{		todaysec 	= "0"+todaysec;		}


	
	var todaystring = montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
	

	return(todaystring);
}


function countdown()
{
	nowTime = Date.parse(getTodayString());
	
	if(newTime <= nowTime)
	{
		document.location="/?t=mission";
		return;
	}

	dd = newTime - nowTime;


	dday=Math.floor(dd/(60*60*1000*24)*1);
	dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
	dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
	dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);

		
	if(dday  <= 9)		{		dday 	= "0"+dday;		}
	if(dhour <= 9)		{		dhour 	= "0"+dhour;		}
	if(dmin  <= 9)		{		dmin 	= "0"+dmin;		}
	if(dsec  <= 9)		{		dsec 	= "0"+dsec;		}

	
	//if on day of occasion


	if (document.all||document.getElementById)
	{
		if(document.getElementById('countdownstr'))
		{
			document.getElementById('countdownstr').innerHTML = dhour+" : "+dmin+" : "+dsec;
		}
	}
	

	setTimeout("countdown()",1000);
}

function passWord()
{
	var passw = prompt('Please Enter the password to enter the Facilitator Page','');
	
	if(passw == "messervey")
	{
		document.location="/?t=facilitatornotesextra";
	}
	else
	{
		document.location="/?t=facilitatornotes";
	}
}

loaded=1;
