// This file is (c) 2005-2011 qlock.com. Unauthorized copying is prohibited. var autoUpdate=true;var currIndex=-1;var IE=document.all ? true : false;var mapW=640;var mapH=320;var dayOfWeek=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");function getDSTDay(year, num, dow, mth){mth--;if(dow==0){adow=1;dt=new Date();}else{dow-=3;dt=new Date(year,mth,1);fdow=(dt.getUTCDay()+5)% 7;adow=(dow-fdow)+1;if(adow <=0)adow+=7;}if(num==5){dt=new Date(year,mth,(3*7)+adow);t=dt.getTime();for(i=3;i<6;i++){dt=new Date(t);if(dt.getMonth()!=mth)break;t+=1000*60*60*24*7;}num=i;}dt.setUTCFullYear(year,mth,((num-1)*7)+adow);dt.setUTCHours(0,0,1);return dt;}function fixDigit(str){var s=new String(str);if(s.length < 2)return "0"+s;else return s;}function getTime(gmtOffset){var date=new Date();offset=gmtOffset*60*60*1000;diff=date.getTime()-startDate.getTime();date.setTime(diff+baseTime+offset);return date;}function formatTime(date){var time;var hour=date.getUTCHours();var min=fixDigit(date.getUTCMinutes());var sec=fixDigit(date.getUTCSeconds());var del=sec&1 ? ":" : ":";if(hour > 12)time=(hour-12)+del+min+" pm";else if(hour==12)time=12+del+min+" pm";else if(hour==0)time=12+del+min+" am";else time=hour+del+min+" am";return dayOfWeek[date.getUTCDay()]+" "+time;}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=qlock.div_;city=findChild(obj,"city");city.getElementsByTagName("P")[0].innerHTML=name;}function setTime(time,off,dst){obj=qlock.div_;l=findChild(obj,"time");l.getElementsByTagName("P")[0].innerHTML=time;if(off==0)gmt="GMT";else if(off > 0)gmt="GMT+"+off;else gmt="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=qlock;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){google.maps.LatLng.prototype.distanceFrom=function(newLatLng){var lat1=this.lat();var radianLat1=lat1*(Math.PI/180);var lng1=this.lng();var radianLng1=lng1*(Math.PI/180);var lat2=newLatLng.lat();var radianLat2=lat2*(Math.PI/180);var lng2=newLatLng.lng();var radianLng2=lng2*(Math.PI/180);var earth_radius=6378.1;var diffLat=(radianLat1-radianLat2);var diffLng=(radianLng1-radianLng2);var sinLat=Math.sin(diffLat/2);var sinLng=Math.sin(diffLng/2);var a=Math.pow(sinLat, 2.0)+Math.cos(radianLat1)*Math.cos(radianLat2)*Math.pow(sinLng, 2.0);var distance=earth_radius*2*Math.asin(Math.min(1, Math.sqrt(a)));return distance;};var minD=1000000000;var minIndex=-1;var latlng=new google.maps.LatLng(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[3],dstSet[4],dstSet[5]);if(dstSet[2] > dstSet[5]){if(time >=start || time < end)dstON=true;}else if(dstSet[2] < dstSet[5]){if(time >=start && time < end)dstON=true;}else if(dstSet[2]==dstSet[5]){dstON=true;}}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=qlock;var linksjump=document.getElementById('linksjump');currIndex=index;var vis;if(index >=0){setCity(cityList[index][0]);updateTime(index);{var coord=google.maps.LatLng(cityList[index][4],cityList[index][5]);gmarker.setPoint(coord);qlock.setPoint(coord);if(zoom)gmap.panTo(coord);document.getElementById('location').innerHTML="Location: "+getLocStr(cityList[index][4],cityList[index][5]);if(linksjump)linksjump.innerHTML="Add "+cityList[index][0]+" to your site >>";}}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