//<![CDATA[
function Clock(CE, startTime){
this.TTO=0;
this.CE = CE;
this.Flag=true;
this.tD=startTime;
this.Upd();
}

Clock.prototype.Upd=function()
{
	if(this.TTO){clearTimeout(this.TTO);this.TTO=0;}
	this.tD.setSeconds(this.tD.getSeconds()+1)
	this.CE.innerHTML=this.FormatDate(this.tD);	
	var self=this;
	this.TTO=setTimeout(function(){self.Upd();},3000);
	//this.Flag=!this.Flag;
}

Clock.prototype.FormatDate=function(dt)
{
	var hour=dt.getHours();
	var minutes=dt.getMinutes();
	var pm=true;
	if(hour<12)
	{
	    pm=false;
	    if(hour==0) 
	    {
		        hour=12;
	    }        	
	}
	else if(hour>12)
		hour=hour-12;
	return hour + ((this.Flag) ? ":":" ") + this.Pad(minutes) + " " + (pm ? "pm":"am");
}

Clock.prototype.Pad=function(number)
{
	return (number<=9) ? "0"+number:""+number;		
}

//]]>