﻿// the month entered must be one less than current month. ie; 0=January, 11=December
// the hour is in 24 hour format. 0=12am, 15=3pm etc
// format: dateBegin = new Date(year,month-1,day,hour,min,sec)
// example: dateBegin = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm

dateBegin = new Date(2008,2,3,7,0,0);   //the conference begins
dateEnded = new Date(2008,2,7,0,0,0);   //the conference ends


function GetCount(){
	var navLocationLoad=location.pathname.toLowerCase();
	if (navLocationLoad.indexOf(SPCdefault) >= 0) {
	    days=0;hours=0;mins=0;secs=0;s_days="";s_hours="";s_mins="";s_secs="";
		dateNow = new Date();									//grab current date
		amount = dateBegin.getTime() - dateNow.getTime();		//calc milliseconds between dates
		amountend = dateEnded.getTime() - dateNow.getTime();	//calc milliseconds of end of conference
		amountduring = dateNow.getTime() - dateBegin.getTime();
		delete dateNow;
	
		
		if(amountend < 0)   // conference has ended
		{
	        s_days += "<img src='images/spacer.gif' height='48' width='1' />";
	        s_days += "The conference is complete.<br>Click here to see more.";
		    
		    //hide the times and show the message
		    document.getElementById('timedisplay').style.display="none";
		    document.getElementById('daydisplay').style.fontSize="8pt";
		    document.getElementById('daydisplay').innerHTML=s_days;
		}
		else if(amount < 0)  // conference is in process
		{
		    amountduring = Math.floor(amountduring/1000);//drop the "milliseconds" so just secs
			days=Math.floor(amountduring/86400);//days
			amountduring=amountduring%86400;
	
			days = days+1;
	        s_days += "<img src='images/spacer.gif' height='48' width='1' /><b>";
			if(days != 0){s_days += "Day " + days + "</b>";}
	        s_days += "<br>Happening now!";
	        
		    //hide the times and show the message
		    document.getElementById('timedisplay').style.display="none";
		    document.getElementById('daydisplay').style.fontSize="9pt";
	        document.getElementById('daydisplay').innerHTML=s_days;
		    setTimeout("GetCount()", 1000);
		}
		// date is still good
		else
		{
			amount = Math.floor(amount/1000);//drop the "milliseconds" so just secs
	
			days=Math.floor(amount/86400);//days
			amount=amount%86400;
	
			hours=Math.floor(amount/3600);//hours
			amount=amount%3600;
	
			mins=Math.floor(amount/60);//minutes
			amount=amount%60;
	
			secs=Math.floor(amount);//seconds
	
		
	        s_days += "<img src='images/spacer.gif' height='45' width='1' /><b>";
		        	
			if(days != 0){s_days += days + "</b> day"+((days!=1)?"s":"");}                  //days
			if(days != 0 || hours != 0){s_hours += hours;} else {s_hours = "0";}            //hours
			if(days != 0 || hours != 0 || mins != 0){s_mins += mins;} else {s_mins = "0";}  //minutes
			s_secs += secs;                                                                 //seconds
	
			//output
	        document.getElementById('daydisplay').innerHTML=s_days;
	        document.getElementById('hourdisplay').innerHTML=s_hours;
	        document.getElementById('mindisplay').innerHTML=s_mins;
	        document.getElementById('secdisplay').innerHTML=s_secs;
			setTimeout("GetCount()", 1000);
		}
	}
}