var now;
var then = new Date("12:00 pm 4/30/2011");
var counterclock = true;
function tick(){
	now = new Date();
	var srd, mrd, hrd;
	var hour = document.getElementById("hour");
	var minute = document.getElementById("minute");
	var second = document.getElementById("second");
	var diff = Math.floor((then.getTime() - now.getTime()) / 1000);
	if(diff > 43200){
	srd = (diff / 86400) * (360/29);
	setTimeout(tick, 60000);
	}else{
	hrd = diff / 120; // (diff / 3600) * 30;
	mrd = ((diff % 3600) / 60) * 6;
	srd = (diff % 60) * 6;
	setTimeout(tick, 999);
	}
	if(!counterclock){
	hrd = (hrd === undefined) ? undefined : 360 - hrd;
	mrd = (mrd === undefined) ? undefined : 360 - mrd;
	srd = (srd === undefined) ? undefined : 360 - srd;
	}
	second.style.display = (srd === undefined) ? "none" : "block";
        minute.style.display = (mrd === undefined) ? "none" : "block";
        hour.style.display = (hrd === undefined) ? "none" : "block";
	second.setAttribute("transform", "rotate(" + srd + " 50 50)");
	minute.setAttribute("transform", "rotate(" + mrd + " 50 50)");
	hour.setAttribute("transform", "rotate(" + hrd + " 50 50)");
}
function load(){
	var l = location.href;
	var c = l.substr(l.lastIndexOf("?") + 1);
	var i = c.indexOf("cc=");
	if(i != -1){
	var tf = c.substr(i + 3);
	counterclock = (tf == "false") ? false : true;
	}
	tick();
	setTimeout(tick, 1000);
}
window.onload = load;
