$(document).ready(function(){
	var count = 0;

	$.getJSON('/services.php', {request : 'getCountdownSeconds'}, function(response){
		count = response.timeout;
	});

	// 1800 seconds left 60 * 60 

	countdown = setInterval(function(){
		//var time = new Date(parseInt(-1 * (count * 1000)));
		var time = new Date();
		var minutes = time.getMinutes();
		var seconds = time.getSeconds();

		var Uhours = time.getUTCHours();
		var Uminutes = time.getUTCMinutes();
		var Useconds = time.getUTCSeconds();

		var hours = Uhours - 8;
		if (hours < 0) hours += 24;

		timeLeftHours = 23 - hours;
		timeLeftMins = 59 - Uminutes;
		timeLeftSecs = 59 - Useconds;

		if (timeLeftHours > 24) {
			timeLeftHours %= 24
		} else if (timeLeftHours == 24) {
			timeLeftHours = 0;
		}

		txtHrs = ((timeLeftHours.toString()).length == 1) ? ("0" + timeLeftHours) : timeLeftHours;
		txtMins = ((timeLeftMins.toString()).length == 1) ? ("0" + timeLeftMins) : timeLeftMins;
		txtSecs = ((timeLeftSecs.toString()).length == 1) ? ("0" + timeLeftSecs) : timeLeftSecs;

		$('#cdhours').html(txtHrs);
		$('#cdminutes').html(txtMins);
		$('#cdseconds').html(txtSecs);

		Cufon.replace('.gotham');

	//	count--;
	}, 1000);
});

