/* Count down until any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here! */

function foaCount()
{
	//countdown(2009,11,30,19,00,0)
	ajaxFunction();
}

function countdown(yr,m,d,hr,min,sec)
{
	var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

	theyear = yr; themonth = m; theday = d; thehour = hr; themin = min; thesec = sec;
	
	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()
	var todaystring = montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
	
	futurestring = montharray[m-1] +" "+ d +", "+ yr +" "+ hr +":"+ min +":"+ sec
	
	dd = Date.parse(futurestring) - Date.parse(todaystring)
	
	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 <= 0 && dhour <= 0 && dmin <= 0 && dsec <= 1)
	{
		document.forms.count.count2.value=" Live Timing Now On! "
		return
	}
	else
		document.forms.count.count2.value = "  days  " + dday +  " |  hours  " + dhour + " |  minutes  " + dmin + " |  seconds  " + dsec
		setTimeout("countdown(theyear,themonth,theday,thehour,themin,thesec)",1000)
}

function ajaxFunction()
{
	var ajaxRequest;
	
	try
	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} 
	catch (e)
	{
		// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{
				alert("Countdown Failed!");
				return false;
			}
		}
	}
	
	// create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState == 4)
		{
			document.count.count2.value = ajaxRequest.responseText;
		}
	}
	ajaxRequest.open("GET", "serverTime_dev.php", true);
	ajaxRequest.send(null); 
	
	setTimeout("ajaxFunction()", 1000);
}


