var rcTimer;

$(document).ready(function(){
	if (timeSecs > 0) {
		rcTimer = setInterval('setTime()',999);
		showTime();
	} else {
		showRCArrived();
	}	
	$("#ryderCountdown").fadeIn("slow");	
		
});

function showTime() {
	var timeSecs2 = timeSecs;
	cDays = Math.floor(timeSecs2/86400);
	timeSecs2 = timeSecs2 - (cDays*86400);
	if (cDays == 0)
	{
		cDays = "00";
	}
	cHours = Math.floor((timeSecs2)/3600);
	if (cHours <10) cHours = '0' + cHours;
	timeSecs2 = timeSecs2 - (cHours * 3600);
	cMins = Math.floor(timeSecs2/60);
	if (cMins < 10) cMins = '0' + cMins;
	
	timeSecs2 = timeSecs2 - (cMins * 60);
	
	if (timeSecs2 < 10) timeSecs2 = '0' + timeSecs2;	

	$("#ryderCountdown").css('filter','alpha(opacity=100)');	
	$("p#countdownDays").html(cDays);
	$("p#countdownHours").html(cHours);
	$("p#countdownMins").html(cMins);
	
	$("p#countdownSecs").html(timeSecs2);
	$("#ryderCountdown").css('filter','alpha(opacity=80)');
}

function setTime() {
	timeSecs--;
	if (timeSecs >= 0) {
		showTime();
	} else {
		clearInterval(rcTimer);
		showRCArrived();
	}
}

function showRCArrived() {
	$("div#ryderCountdown h4").html("Welcome to Newport").css("font-size","1.3em");
	$("#rcInner").html("<div id='rcArrived'>Host city to The 2010 Ryder Cup</div>");
}

