var now;
var second;
var minute;
var hour;
var hourdiff = new Array(2);
var timer;
var actclock;



now=new Date()

sny=0; //summer time in new york
//Summer = Standard + 1 hour.

// the sny (summer time in new york should be calculated probably)


hourdiff[1]= 0; //difference from UTC for London
hourdiff[2]= -5+sny; //difference from UTC for New York + summer time

actclock=1; 

function checkTime() {
		now=new Date();
		second=now.getSeconds();
		minute=now.getMinutes();
		hour=now.getUTCHours();
		spinIt();
		timer=setTimeout("checkTime()",200);
}

function checkAmPm(hour) {
	if (hour>=24) {
		return("AM")
	}
	if ((hour>=12)&&(hour<24)) {
		return("PM")
	}
	if ((hour>=0)&&(hour<12)) {
		return("AM")
	}
	if ((hour>=-12)&&(hour<0)) {
		return("PM")
	}
}

function normilizeTime(hourvar){
	while(hourvar>=12) {
		hourvar=hourvar-12;
	}
	while(hourvar<0) {
		hourvar=hourvar+12;
	}
	return (hourvar)
}

function spinIt() {
	if (minute<10) {minute="0"+minute;}
if (document.layers) { //NS4
    layerRef="document.layers";
    styleRef="";
    showRef="show";
    hideRef="hide";
    if (second==60) {second=0}
	which="seclayer1"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(second*40)) +'"');
	which="seclayer2"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(second*40)) +'"');

    if (minute==60) {minute=0}
	which="minlayer1"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(minute*40)) +'"');
	which="minlayer2"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(minute*40)) +'"');
	hour1=(hour+hourdiff[1]);
	hour2=(hour+hourdiff[2]);
	which="ampm1"
	varampm=checkAmPm(hour1)
	hour1=normilizeTime(hour1);
	writeLayerText(which, hour1+":"+minute+ " " + varampm)
    if (minute==60) {minute=0}
	hour1=Math.round(hour1*5+((minute)/12));
    if (hour1==60) {hour1=0}
	which="ampm2"
	varampm=checkAmPm(hour2)
	hour2=normilizeTime(hour2);
	writeLayerText(which, hour2+":"+minute+ " " + varampm)
    if (minute==60) {minute=0}
	hour2=Math.round(hour2*5+((minute)/12));
    if (hour2==60) {hour2=0}
	which="hourlayer1"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(hour1*40)) +'"');
	which="hourlayer2"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(hour2*40)) +'"');


} else if (document.all) {   //IE4
    layerRef="document.all";
    styleRef=".style";
    showRef="visible";
    hideRef="hidden";
     if (second==60) {second=0}
	which="seclayer1"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(second*40)) +'"');
	which="seclayer2"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(second*40)) +'"');

    if (minute==60) {minute=0}
	which="minlayer1"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(minute*40)) +'"');
	which="minlayer2"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(minute*40)) +'"');

   	hour1=(hour+hourdiff[1]);
	hour2=(hour+hourdiff[2]);
	which="ampm1"

	varampm=checkAmPm(hour1)
	hour1=normilizeTime(hour1);
	writeLayerText(which, hour1+":"+minute+ " " + varampm)
    if (minute==60) {minute=0}
	hour1=Math.round(hour1*5+((minute)/12));
    if (hour1==60) {hour1=0}
	which="ampm2"
	
	varampm=checkAmPm(hour2)
	hour2=normilizeTime(hour2);
	writeLayerText(which, hour2+":"+minute+ " " + varampm)	
    if (minute==60) {minute=0}
	hour2=Math.round(hour2*5+((minute)/12));
    if (hour2==60) {hour2=0}
	which="hourlayer1"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(hour1*40)) +'"');
	which="hourlayer2"
   	eval(layerRef + '["' + which +'"]' + styleRef + '.top = "' + (51-(hour2*40)) +'"');

} else if (document.documentElement) {         //NS6
    layerRef="document.getElementById";
    styleRef=".style";
    showRef="visible";
    hideRef="hidden";
     if (second==60) {second=0}
	which="seclayer1"
   	eval(layerRef + '("' + which +'")' + styleRef + '.top = "' + (51-(second*40)) +'"');
	which="seclayer2"
   	eval(layerRef + '("' + which +'")' + styleRef + '.top = "' + (51-(second*40)) +'"');

    if (minute==60) {minute=0}
	which="minlayer1"
   	eval(layerRef + '("' + which +'")' + styleRef + '.top = "' + (51-(minute*40)) +'"');
	which="minlayer2"
   	eval(layerRef + '("' + which +'")' + styleRef + '.top = "' + (51-(minute*40)) +'"');

   	hour1=(hour+hourdiff[1]);
	hour2=(hour+hourdiff[2]);
	which="ampm1"

	varampm=checkAmPm(hour1)
	hour1=normilizeTime(hour1);
	writeLayerText(which, hour1+":"+minute+ " " + varampm)
    if (minute==60) {minute=0}
	hour1=Math.round(hour1*5+((minute)/12));
    if (hour1==60) {hour1=0}
	which="ampm2"
	
	varampm=checkAmPm(hour2)
	hour2=normilizeTime(hour2);
	writeLayerText(which, hour2+":"+minute+ " " + varampm)	
    if (minute==60) {minute=0}
	hour2=Math.round(hour2*5+((minute)/12));
    if (hour2==60) {hour2=0}
	which="hourlayer1"
   	eval(layerRef + '("' + which +'")' + styleRef + '.top = "' + (51-(hour1*40)) +'"');
	which="hourlayer2"
   	eval(layerRef + '("' + which +'")' + styleRef + '.top = "' + (51-(hour2*40)) +'"');
   	}
}

function show_time(uhr) {
	if (document.layers) {          //NS4
		layerRef="document.layers";
		styleRef="";
		showRef="show";
		hideRef="hide";
		eval(layerRef + '["ampm'+uhr+'"]' + styleRef + '.visibility = "' + showRef +'"');
	} else if (document.all) {        //IE4
		layerRef="document.all";
		styleRef=".style";
		showRef="visible";
		hideRef="hidden";
		eval(layerRef + '["ampm'+uhr+'"]' + styleRef + '.visibility = "' + showRef +'"');
	} else if (document.documentElement) {         //NS6
		layerRef="document.getElementById";
		styleRef=".style";
		showRef="visible";
		hideRef="hidden";
		eval(layerRef + '("ampm'+uhr+'")' + styleRef + '.visibility = "' + showRef +'"');
	}
}

function close_time(uhr) {
	if (document.layers) {     //NS4
		layerRef="document.layers";
		styleRef="";
		showRef="show";
		hideRef="hide";
		eval(layerRef + '["ampm'+uhr+'"]' + styleRef + '.visibility = "' + hideRef +'"');
	} else if (document.all) {   //IE4
		layerRef="document.all";
		styleRef=".style";
		showRef="visible";
		hideRef="hidden";
		eval(layerRef + '["ampm'+uhr+'"]' + styleRef + '.visibility = "' + hideRef +'"');
	} else if (document.documentElement) {        //NS6
		layerRef="document.getElementById";
		styleRef=".style";
		showRef="visible";
		hideRef="hidden";
		eval(layerRef + '("ampm'+uhr+'")' + styleRef + '.visibility = "' + hideRef +'"');
	}
}


function writeLayerText(id,text) {
	if (document.getElementById)  { //NS6
		lay = document.getElementById(id);
		lay.innerHTML = '';
		lay.innerHTML = "<font face='arial' size='1' color='#808080'>" + text + "</font>";
	} else if (document.all) {          //IE4
		lay = document.all[id];
		lay.innerHTML = "<font face='arial' size='1' color='#808080'>" + text + "</font>";
	} else if (document.layers)  {     //NS4
		lay = document.layers[id];	
		textlay = "<font face='arial' size='1' color='#808080'>" + text + "</font>";
		lay.document.open();
		lay.document.write(textlay);
		lay.document.close();
	}
}


