
// ==============================================
//              Timezone Cheat Clock
// ==============================================
//         Version "Charlie" (2007-05-16)
//
//  http://www.6times9.com/javascript/cheatclock
//
//        Copyright 2006  Richard Winskill
// ==============================================

// For details and instructions, see http://www.6times9.com/javascript/cheatclock/

function cheatclock(chthour, chtmin, chtsec, chtid){
//Add 1 to the seconds
	chtsec=chtsec+1;
//When seconds reach 60, reset seconds to 0 and increase minutes by 1
	if(chtsec>59){chtsec=0; chtmin=chtmin+1;}
//When minutes reach 60, reset minutes to 0 and increase hour by 1
	if(chtmin>59){chtmin=0; chthour=chthour+1;}
//If hour is 0, make hour 24 (easier maths)
	if(chthour==0){chthour=24;}
//When hour passes 24, reset hour to 1;
	if(chthour>24){chthour=1;}
//If hour is before noon or hour is midnight, it's AM; otherwise it's PM
	if(chthour<12 || chthour==24){ap="AM";} else {ap="PM";}
//Create "outhour" variable to display a 12-hour time but keep the maths right by remembering 24-hour "chthour" variable
	outhour=chthour
	if(outhour>12){outhour=outhour-12;}
//Add a leading zero to seconds a minutes if they are less than 10
	if(chtsec<10){secz="0";}else{secz="";}
	if(chtmin<10){minz="0";}else{minz="";}
//Output the time string to the HTML element with ID CHTID
	document.getElementById(chtid).innerHTML=outhour+":"+minz+chtmin+":"+secz+chtsec+" "+ap;
//Tell the function to repeat every 1000ms (1 second)
	setTimeout('cheatclock('+chthour+', '+chtmin+', '+chtsec+', "'+chtid+'")',1000);
}

//Handle other window.onload's
var prevonload=window.onload;
if(typeof(prevonload)=="function"){window.onload=function(){prevonload();run1_cheatclock();}; }else{ window.onload=function(){run1_cheatclock();}; }