var clockID;
var offset;
function startClock( offsetValue ){
 offset = offsetValue;
 window.status = "Clock Started";
 clockID = setInterval(updateTime,1000);
}
function stopClock(){
 clockID = clearInterval(clockID);
}
function updateTime(){
  var d,stime="",h=0,m=0,s=0;
  var c=":", meridian="";
  d = new Date();
  if((d.getUTCHours()+offset)<0)
    h=(d.getUTCHours()+offset+24);
  else
    h=(d.getUTCHours()+offset);
    
  m=d.getUTCMinutes();
  s=d.getUTCSeconds();

  if (h<24 && h>12) {
  	meridian="PM";
  	if (h>12)
  		h=h-12;
  }
  else {
  	if ( h==12 )
	  	meridian="PM";
	  else
	  	meridian="AM";
	  if ( h>24 ) {
	  	h=h-24;
	  	meridian="AM";
	  }
	  if ( h==24 ) {
	  	h=h-12;
	  	meridian="AM";
	  }
  }

  if (h<10)
    stime+=0;
    
  stime+=(h+c);
  
  if(m<10)
    stime+=0;
    
  stime+=(m+c);
  
  if(s<10)
    stime+=0;
    
  stime+=(s);
  stime+=" ";
  stime+=meridian;
  
  if (document.layers) {
      with (document.stimeElement.document.stimeLayer.document) {
          write(stime);
          close();
      }
  }
  else { timeElement.innerHTML = stime };
}
