function findChild(elem, className) { if(elem.className==className) return elem; var i; for(i=0; i < elem.childNodes.length;i++) { var e=findChild(elem.childNodes[i], className); if(e)return e; } return null; } function setCity(name) { obj=wclock.div_; city=findChild(obj,"city"); city.getElementsByTagName("P")[0].innerHTML=name; } function setTime(time,off,dst) { obj=wclock.div_; l=findChild(obj,"time"); l.getElementsByTagName("P")[0].innerHTML=time; if(off==0)gmt="UTC/GMT"; else if(off > 0)gmt="UTC/GMT+"+off; else gmt="UTC/GMT "+off; l=findChild(obj,"gmt"); l.getElementsByTagName("P")[0].innerHTML=gmt; l=findChild(obj,"dst"); l.getElementsByTagName("P")[0].innerHTML=dst?"DST":""; } function moveClock(x,y) { obj=wclock; obj.style.left=x+"px"; obj.style.top=y+"px"; } var isOnMap=false; var oldLng=0; var oldLat=0; function MouseMove(e){if(moving)return; var lng=e.x; var lat=e.y; if((lng==oldLng)&&(lat==oldLat))return; oldLng=lng; oldLat=lat; showCity(findClosest(lat,lng),false); isOnMap=true; } function findClosest(lat, lng) { var minD=1000000000; var minIndex=-1; var latlng=new GLatLng(lat,lng); for(i=1;i=0) { dstSet=dstList[cityList[index][3]]; year=time.getFullYear(); var start=getDSTDay(year,dstSet[0],dstSet[1],dstSet[2]); var end=getDSTDay(year+(dstSet[2]>dstSet[5] ? 1 : 0),dstSet[3],dstSet[4],dstSet[5]); dstON=(time >=start)&&(time < end); } else{}if(dstON) { time=new Date(time.getTime()+(1000*60*60)); } setTime(formatTime(time),cityList[index][2],dstON); } function getLocStr(lng,lat) { var o=""; if(lng >=0)o+=lng.toFixed(2)+" N"; else o+=-lng.toFixed(2)+" S";o+=", "; if(lat >=0)o+=lat.toFixed(2)+" E"; else o+=-lat.toFixed(2)+" W";return o; } var cnt=0; function showCity(index,zoom) { var map=document.getElementById('map'); var clock=wclock; currIndex=index; var vis; if(index >=0) { setCity(cityList[index][0]); updateTime(index); { var coord=new GLatLng(cityList[index][4],cityList[index][5]); gmarker.setPoint(coord); wclock.setPoint(coord); if(zoom)gmap.panTo(coord); document.getElementById('location').innerHTML="Location: "+getLocStr(cityList[index][4],cityList[index][5]); } } else{} } function showAll(){var out=""; for(i=0; i"; } document.getElementById("map").innerHTML=out; } function update() { if(currIndex >=0)updateTime(currIndex); setTimeout(update,1000); } var findIndex=-1; var hilightStart; var lastKey; var myTimeout=0; function complete() { switch(lastKey){case 13: case 33: case 34: case 35: case 35: case 36: case 37: case 39: case 45: case 46: return; } var cname=" ";findIndex=-1; if(lastKey !=8) { var input=document.getElementById("find"); var str=input.value.toLowerCase(); if(str.length) { var i;for(i=0; i=0)cname=countryList[ci]; else cname="";if(autoUpdate)showCity(i,true); findIndex=i; if(typeof completeDone !="undefined")completeDone();break; } } } } var country=document.getElementById("country"); if(country)country.getElementsByTagName("P")[0].innerHTML=cname; if(typeof findChange !="undefined")findChange(); } function doFind(ctl) { document.getElementById("find").select(); document.getElementById("find").focus(); if(findIndex >=0)showCity(findIndex,true); return false; } function keyup() { if(!myTimeout)myTimeout=setTimeout(complete,10); } function keydown(event) { if(myTimeout){clearTimeout(myTimeout); myTimeout=0; } lastKey=event.keyCode; if(event.keyCode==8)document.getElementById("find").value.substr(0,hilightStart)}function resizeHandler(){if(currIndex >=0)showCity(currIndex); } function doFocus() { document.getElementById("find").select(); } function findCityByName(city) { var str=city.toLowerCase(); if(str.length) { var i; for(i=0; i