// <!-- Beginning of JavaScript -

// CREDITS:
// World Time on Doubleclick by Urs Dudli and Peter Gehrig 
// Copyright (c) 2000 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.241fun.ch.
// info@24fun.ch
// 2/22/2000

// IMPORTANT: 
// If you add this script to a script-library or script-archive 
// you have to add a link to http://www.24fun.ch on the webpage 
// where this script will be running.

// CONFIGURATION:
// Copy the script-block into the head section of your HTML-file.
// Copy the style-sheet into the head section of your HTML-file.
// Configure the part "timestyle" of the style-sheet (font, font-size, color etc.)
// Copy the div-container (id="timediv") into the end of the body-section.
// Configure the variables below:

// Add as many locations as you like. The value right after the capital 
// represents the capital's time difference to GMT-time measured in hours
var worldtime = new Array()
worldtime[0]="Azores|-1"
worldtime[1]="Baghdad|3"
worldtime[2]="Beijing|8"
worldtime[3]="Berlin|1"
worldtime[4]="Buenos Aires|-3"
worldtime[5]="Illinois|-6"
worldtime[6]="Denver|-7"
worldtime[7]="Hong Kong|8"
worldtime[8]="Honolulu|-10"
worldtime[9]="Johannesburg|2"
worldtime[10]="Kairo|2"
worldtime[11]="Lima|-5"
worldtime[12]="London|0"
worldtime[13]="Mexico City|-6"
worldtime[14]="Moscow|3"
worldtime[15]="New Jersey|-5"
worldtime[16]="Paris|1"
worldtime[17]="Perth|8"
worldtime[18]="Rio de Janheiro|-2"
worldtime[19]="California|-8"
worldtime[20]="Sydney|11"
worldtime[21]="Tokyo|9"
worldtime[22]="Edmonton, Alberta|-7"
worldtime[23]="Texas|-6"
worldtime[24]="North Carolina|-5"
worldtime[25]="Montreal, Quebec|-5"
worldtime[26]="Milan|1"
worldtime[27]="Singapore|8"
worldtime[28]="South Korea|9"
worldtime[29]="Saudi Arabia|3"
worldtime[30]="Sarnia, Ontario|-5"
worldtime[31]="Louisiana|-6"
worldtime[32]="Calgary, Alberta|-7"

var hours
var shifthours
var minutes
var seconds
var localhours
var pause=2000
var thisplace
var thisline=""
var showmenu=1
var a_p = ""
var displayHours = ""


function showtimeNew(intVar) {

thisline = "";

	for (i=0; i<=worldtime.length-1;i++) {
		thisplace=worldtime[i].split("|")
		thistime= new Date()
		hours=thistime.getUTCHours()
		hours=eval(hours)
		shifthours=eval(thisplace[1])
//		localhours=eval(shifthours+hours)
// DAYLIGHT SAVINGS ::: 05152009
		localhours=eval(shifthours+hours+1)

		if (localhours <0) {localhours=24+localhours}
		if (localhours >=24) {localhours=localhours-24}
	

if (localhours < 12) {
	a_p = "AM";
} else {
	a_p = "PM";
}

displayHours = localhours;
if (localhours == 0) {
	displayHours = 12;
}
if (localhours > 12) {
	displayHours = localhours - 12;
}

		minutes=thistime.getUTCMinutes()
		seconds=thistime.getUTCSeconds()
	
		if (thisplace[0]=='Delhi') {
			minutes=eval(minutes+30)
			if (minutes>=60) {
				minutes=eval(minutes-60)
				localhours=eval(localhours+1)
			}
		}
		if (eval(minutes) < 10) {minutes="0"+minutes}
		if (eval(seconds) < 10) {seconds="0"+seconds}
		if (eval(localhours) < 10) {localhours="0"+localhours}

		if (i == intVar) {
//			thisline+=localhours+":"+minutes+":"+seconds+" "+thisplace[0]+"<br>"
			thisline+="&nbsp;&nbsp;"+displayHours+":"+minutes+" "+a_p+" - "+thisplace[0]+"&nbsp;&nbsp;<br>"
		}
		
	}

Tip(thisline);

}





function showtime(intVar) {

	for (i=0; i<=worldtime.length-1;i++) {
		thisplace=worldtime[i].split("|")
		thistime= new Date()
		hours=thistime.getUTCHours()
		hours=eval(hours)
		shifthours=eval(thisplace[1])
		localhours=eval(shifthours+hours)
		if (localhours <0) {localhours=24+localhours}
		if (localhours >=24) {localhours=localhours-24}
	

if (localhours < 12) {
	a_p = "AM";
} else {
	a_p = "PM";
}

displayHours = localhours;
if (localhours == 0) {
	displayHours = 12;
}
if (localhours > 12) {
	displayHours = localhours - 12;
}

		minutes=thistime.getUTCMinutes()
		seconds=thistime.getUTCSeconds()
	
		if (thisplace[0]=='Delhi') {
			minutes=eval(minutes+30)
			if (minutes>=60) {
				minutes=eval(minutes-60)
				localhours=eval(localhours+1)
			}
		}
		if (eval(minutes) < 10) {minutes="0"+minutes}
		if (eval(seconds) < 10) {seconds="0"+seconds}
		if (eval(localhours) < 10) {localhours="0"+localhours}

		if (i == intVar) {
//			thisline+=localhours+":"+minutes+":"+seconds+" "+thisplace[0]+"<br>"
			thisline+="&nbsp;&nbsp;"+displayHours+":"+minutes+" "+a_p+" - "+thisplace[0]+"&nbsp;&nbsp;<br>"
		}
		
	}
	if (document.all) {
		timediv.innerHTML=thisline
		thisline=""
		// var timer=setTimeout("showtime()",10000)
	}
	if (document.layers) {
		document.timediv.document.write("<span id='nn' class='timestyle'>")
		document.timediv.document.write(thisline)
		document.timediv.document.write("</span>")
		document.timediv.document.close()
		thisline=""
	}
}


function dblclick(intVar) {
	if (document.all && showmenu==1) {
		document.all.timediv.style.visibility="visible"
		document.all.timediv.style.posLeft=x+5
		document.all.timediv.style.posTop=y-20
		showtime(intVar)
	}
	if (document.layers && showmenu==1) {
		document.timediv.visibility="visible"
		document.timediv.left=x-40
		document.timediv.top=y-80
		showtime(intVar)
	}
	if (document.all && showmenu!=1) {
		document.all.timediv.style.visibility="hidden"
	}
	if (document.layers && showmenu!=1) {
		document.timediv.visibility="hidden"
	}
	showmenu=showmenu*-1
}


if (document.layers) {
// document.captureEvents(Event.ONDBLCLICK);
}
document.ondblclick=dblclick;

if (document.layers){
//	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

function handlerMM(e){
	x = (document.layers) ? e.pageX : event.clientX
	y = (document.layers) ? e.pageY : event.clientY
}

// - End of JavaScript - -->
