﻿// JScript File
var isNS = false;;

if (document.layers) { (isNS=true) }
var HIDDEN = (isNS) ? 'hide' : 'hidden';
var VISIBLE = (isNS) ? 'show' : 'visible';

function Clock()
{    
this.clipTop = 0;
this.clipBottom = 0;
this.clipLeft = 0;
this.clipRight = 0;
this.imgSeconds = new Array();
this.imgMinutes = new Array();
this.imgHours = new Array();
this.clipHours="";
this.clipMinutes="";
this.clipSeconds="";
this.startLeft = 0;
this.startTop = 0;
this.centerLeft = new Array();
this.clockNumber = 4;  
this.timeShift = new Array();
this.timeShift[0] = -4;
this.timeShift[1] = 7;
this.timeShift[2] = 1;
this.timeShift[3] = 9;
this.anchorImg = "";
this.SecImgName = "imgSeconds";
this.MinImgName = "imgMinutes";
this.HouImgName = "imgHours";
this.offsetLeft = 0;
this.offsetTop = 0;
}
Clock.prototype = {
initClock : function()
{

{
var rr = this.anchorImg;
var clockImg = document.getElementById(this.anchorImg);

if(clockImg){
this.startTop = clockImg.offsetTop + 24 + this.offsetTop;
this.centerLeft[0] = clockImg.offsetLeft + 43 + this.offsetLeft;
this.centerLeft[1] = this.centerLeft[0] + 113;
this.centerLeft[2] = this.centerLeft[1] + 113;
this.centerLeft[3] = this.centerLeft[2] +113;
for(var i = 0; i < this.clockNumber; i++)
{  
this.imgSeconds[i] = document.getElementById(this.SecImgName+'_'+i).style;
this.imgMinutes[i] = document.getElementById(this.MinImgName+'_'+i).style;
this.imgHours[i] = document.getElementById(this.HouImgName+'_'+i).style;
this.imgSeconds[i].overflow = 'hidden';
this.imgMinutes[i].overflow = 'hidden';
this.imgHours[i].overflow = 'hidden';
this.imgHours[i].top=this.startTop+"px";
this.imgMinutes[i].top=this.startTop+"px";
this.imgSeconds[i].top=this.startTop+"px";
this.imgSeconds[i].visibility=VISIBLE;
this.imgMinutes[i].visibility=VISIBLE;
this.imgHours[i].visibility=VISIBLE;
}

}

}    
 },
 
    tickIE : function()  {
        var now = new Date();
        var nowHours = now.getUTCHours();
        var nowMinutes = now.getUTCMinutes();
        var nowSeconds = now.getUTCSeconds();

        if (nowHours >= 12) {nowHours=nowHours-12;}

 for(var i = 0; i < this.clockNumber; i++)
{

 var hr = nowHours+this.timeShift[i];//4-5=-1
 if (hr < 0) {hr=hr+12;}
  if (hr >= 12) {hr=hr-12;}

 var h_posLeft=  -((hr)*80*5+((Math.round(nowMinutes/12))*80))+this.centerLeft[i];
    this.imgHours[i].left=  h_posLeft+"px";


 
 this.clipLeft = -(h_posLeft)+this.centerLeft[i] -40;
 this.clipRight= this.clipLeft+80;
 this.clipHours ="rect("+0+"px "+this.clipRight+"px "+160+"px "+this.clipLeft+"px)";
 
 this.imgHours[i].clip=this.clipHours;

 
  var m_posLeft=-((nowMinutes+1)*80)+this.centerLeft[i]+1;//40
  this.imgMinutes[i].left=m_posLeft+"px";//40

 this.clipLeft = -(m_posLeft)+this.centerLeft[i]-40;//+132
 this.clipRight= this.clipLeft+80;
 this.clipMinutes ="rect("+0+"px "+this.clipRight+"px "+160+"px "+this.clipLeft+"px)";

this.imgMinutes[i].clip=this.clipMinutes;
 
 var s_posLeft=-((nowSeconds+1)*80)+this.centerLeft[i]+0;
  this.imgSeconds[i].left=s_posLeft+"px";

 
 this.clipLeft = -(s_posLeft)+this.centerLeft[i]-40;
 this.clipRight= this.clipLeft+80;
 this.clipSeconds ="rect("+0+"px "+this.clipRight+"px "+160+"px "+this.clipLeft+"px)";
 this.imgSeconds[i].clip=this.clipSeconds;
 }

}

 }



