// ------------------------ date time output function----------------//
// ----------------------------- global variables ------------------------//

var sclock = document.clock.st.value;
// sclock="Fri Apr 9 11:00:00 1999"
arb = new Array("Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov","Dec");
ard = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
IE4    = (document.all)? ".style" : "";


//document.clock.refreshpage.value = 180 + " seconds";
var rDate = new Date();
var tr = rDate.getTime() + 181*1000;

// obtain time difference between server's and client's clock 
var sDate0 = new Date( sclock );
var cDate0 = new Date();
var ts0 =  sDate0.getTime();	// server's initial ms time 
var tc0 =  cDate0.getTime();	// client's initial ms time 1900 +
var bla = cDate0.getDate();
var blaa = cDate0.getMonth();
var blaaaa = cDate0.getDay();
var bx = arb[blaa];
var by = ard[blaaaa];
var blaaa =  document.clock.yr.value; //sDate0.getYear();
var dt = ts0 - tc0;


// -------- function ------ // 
function updateClock()
{
	// timer 
	var cDate = new Date();
	var tc = cDate.getTime();			// client (local) ms time 
	var ts = tc + dt;					// convert to server's ms time 
	var scDate = new Date();			// simulated server's 
	scDate.setTime( ts );				// "Date" object 


      //var hours = scDate.getHours();           // simulated server's frs commented out  
	//var minutes = scDate.getMinutes();       // simulated server's frs commented out  
	//var seconds = scDate.getSeconds();       // simulated server's frs commented out  

    	var hours = cDate.getHours();              // client time frs added  
	var minutes = cDate.getMinutes();          // client time frs added  
	var seconds = cDate.getSeconds();      	 // client time frs added  
	// var timeValue = "" + ((hours >12) ? hours -12 :hours); 
	var timeValue = "" + hours;
	timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
	timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
	document.clock.face.value =""+ by+ "., " +bx+ ". " +bla+ ", " +timeValue;

 
	
 // reset the refresh countdown  
 	rtd = Math.floor( (tr - tc)/1000 );
	if(  rtd <= 0 ) rtd = 0;
	var rtdValue = rtd + ((rtd == 1)?" second" : " seconds" );
	//document.clock.refreshpage.value = rtdValue;
	setTimeout("updateClock()",500);


}

updateClock();
             