﻿// JScript File

///////////////////////////////////////////////////////////
// "Live Clock Lite" script - Version 1.0
// By Mark Plachetta (astroboy@zip.com.au)
//
// Get the latest version at:
// http://www.zip.com.au/~astroboy/liveclock/
//
// Based on the original script: "Upper Corner Live Clock"
// available at:
// - Dynamic Drive (http://www.dynamicdrive.com)
// - Website Abstraction (http://www.wsabstract.com)
// ========================================================
// CHANGES TO ORIGINAL SCRIPT:
// - Gave more flexibility in positioning of clock
// - Added date construct (Advanced version only)
// - User configurable
// ========================================================
// Both "Advanced" and "Lite" versions are available free
// of charge, see the website for more information on the
// two scripts.
///////////////////////////////////////////////////////////
// Revised by Sarah Fung

	var my12_hour = 0;

	var dn = ""; var old = "";
	
	var off1 = 8;
	var off2 = 0;
	var off3= -5;


	function show_clock(offhours,id) {

		//show clock in NS 4        
		if (document.layers)
                document.ClockPosNS.visibility="show"
		if (old == "die") { return; }
		
		var Digital = new Date();
		

		var hours = Digital.getUTCHours();
		var minutes = Digital.getUTCMinutes();
		var seconds = Digital.getUTCSeconds();
       
        var offmin = (offhours*60)%60;
        
        minutes = minutes + offmin;
        
        if (minutes>=60)
        {
             hours = hours + 1;
             minutes = minutes -60;
        }
        
        if (minutes<0)
        {
            hours = hours - 1;
            minutes = 60 - minutes;
        }       
       
        hours = hours+Math.floor(offhours);
                
        if (hours>24)
        {
            hours = hours-24;
        }
        
        if (hours<0)
        {
            hours = hours+24;
        }
        
        
		if (my12_hour) {
			dn = "AM";
			if (hours > 12) { dn = "PM"; hours = hours - 12; }
			if (hours == 0) { hours = 12; }
		} else {
			dn = "";
		}
		if (hours <= 9) { hours = "0"+hours; }
		if (minutes <= 9) { minutes = "0"+minutes; }
		if (seconds <= 9) { seconds = "0"+seconds; }

		myclock = '';
		myclock += hours+':'+minutes+':'+seconds+' '+dn;


		if (old == "true") {
			document.write(myclock);
			old = "die"; return;
		}

		if (document.layers) {
			clockpos = document.ClockPosNS;
			liveclock = clockpos.document.LiveClockNS;
			liveclock.document.write(myclock);
			liveclock.document.close();
		} else if (document.getElementById) {
			document.getElementById(id).innerHTML = myclock;
		}
		
		setTimeout("show_clock("+offhours+",'"+id+"')",1000);
		
		//alert("hello");
}