// Get later time
$(document).ready(function() {
	$.get("/check.php?p=getTimer", function(data){
		getTime(parseFloat(data));
	});
	window.setTimeout("updateFeatured();", 10000);
	
	$("#facebook").hover(
	function(){
		$(this).animate({ right: "0" }, {queue:false, duration:"normal"} );
	},
	function(){
		$(this).animate({ right: "-206" }, {queue:false, duration:"normal"} );
	});
	
});


function getTime(later) {

if(later % 300 == 0 && later > 0)
{
	$.get("/check.php?p=getTimer", function(data){
		later = parseFloat(data);
	});
}

if(later >= 0){
		window.setTimeout("getTime(" + (later - 1) + ");", 1000);
}

var days = later / 60 / 60 / 24;
var daysRound = Math.floor(days);

var hours = later / 60 / 60;
var hoursRound = Math.floor(hours);

var hours2 = later / 60 / 60 - (24 * daysRound);
var hoursRound2 = Math.floor(hours2);

var minutes = later / 60 - (24 * 60 * daysRound) - (60 * hoursRound2);
var minutesRound = Math.floor(minutes);
var seconds = later - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound2) - (60 * minutesRound);
var secondsRound = Math.round(seconds);

if(hoursRound < 0 || minutesRound < 0 || secondsRound < 0){
	document.getElementById('hours').innerHTML = "0";
	document.getElementById('minutes').innerHTML = "0";
	document.getElementById('seconds').innerHTML = "0";
}else{
	document.getElementById('hours').innerHTML = hoursRound;
	document.getElementById('minutes').innerHTML = minutesRound;
	document.getElementById('seconds').innerHTML = secondsRound;
}

}

