var currentTime;var strTargetTimeZoneDisplayName="";var clockSpan;var DEBUG=false;var TICK=true;function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length);}if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}return null;}function startClock(targetTimeZoneOffsetValue,strTargetTimeZoneName,strTargetTimeZoneShortName,spanId,serverTimeZoneOffset){strTargetTimeZoneDisplayName=strTargetTimeZoneShortName;if(DEBUG){alert("zoneoffset "+targetTimeZoneOffsetValue);}if(DEBUG){alert("zoneid "+strTargetTimeZoneName);}if(DEBUG){alert("zoneIdDisplay "+strTargetTimeZoneShortName);}if(DEBUG){alert("zoneIdDisplay "+serverTimeZoneOffset);}var strCurrentServerTime=readCookie("t");if(DEBUG){alert("value from cookie is "+strCurrentServerTime);}if(!strCurrentServerTime){currentTime=new Date().getTime();if(DEBUG){alert("value from PC is "+currentTime);}if(DEBUG){alert("value targetTimeZoneOffsetValue is "+targetTimeZoneOffsetValue);}currentTime-=targetTimeZoneOffsetValue;if(DEBUG){alert("Using PC time.  And its value is "+currentTime);}}else{var year=strCurrentServerTime.substring(0,4);var month=strCurrentServerTime.substring(4,6);var date=strCurrentServerTime.substring(6,8);var hour=strCurrentServerTime.substring(8,10);var minute=strCurrentServerTime.substring(10,12);var second=strCurrentServerTime.substring(12,14);var currentServerDate=new Date(year,parseInt(month,10)-1,date,hour,minute,second,0);if(DEBUG){alert("Current Server Time:"+currentServerDate);}currentTime=currentServerDate.getTime();if(DEBUG){alert("currentTime"+currentTime);}currentTime-=serverTimeZoneOffset;if(DEBUG){alert("serverTimeZoneOffset time "+serverTimeZoneOffset);}if(DEBUG){alert("currentTime AFTER SUBS"+currentTime);}}if(DEBUG){alert("UTC time is "+new Date(currentTime));}var trget=getTimeAdjustmentValue(strTargetTimeZoneName,currentTime,targetTimeZoneOffsetValue);if(DEBUG){alert("target after getTimeAdjustmentValue "+trget);}currentTime+=trget;if(DEBUG){alert("targetTimeZoneOffsetValue="+targetTimeZoneOffsetValue+", and currentTime is now "+currentTime);}if(DEBUG){alert(strTargetTimeZoneName);}var daylightAdjustment=getDaylightAdjustmentValue(strTargetTimeZoneName,currentTime);if(DEBUG){alert("daylightAdjustment is "+daylightAdjustment);}currentTime+=daylightAdjustment;strTargetTimeZoneDisplayName=getAbbreviation(strTargetTimeZoneDisplayName);clockSpan=document.getElementById(spanId);if(clockSpan){updateClock();if(TICK){setInterval("updateClock()",1000);}}else{if(DEBUG){alert("Invalid Id specified to display clock");}}}function getDisplayableDate(timeInMilliSeconds,strTargetTimeZoneName){var d=new Date(timeInMilliSeconds);var day=d.getDate();var month=d.getMonth();var year=d.getFullYear();var hours=d.getHours();var minutes=d.getMinutes();var seconds=d.getSeconds();var timeofday="";if(hours<12){timeofday="am";}else{timeofday="pm";}if(hours>12){hours=hours-12;}return day+" "+getMonthName(month,"short")+", "+year+" "+hours+":"+numberFormat(minutes)+":"+numberFormat(seconds)+" "+timeofday+" "+" ("+strTargetTimeZoneDisplayName+")";}function numberFormat(number){if(number<10){return"0"+number;}else{return number;}}function getMonthName(monthValue,style){var monthName="";switch(monthValue){case 0:monthName="January";break;case 1:monthName="February";break;case 2:monthName="March";break;case 3:monthName="April";break;case 4:monthName="May";break;case 5:monthName="June";break;case 6:monthName="July";break;case 7:monthName="August";break;case 8:monthName="September";break;case 9:monthName="October";break;case 10:monthName="November";break;case 11:monthName="December";break;}if(style=="short"){return monthName.substring(0,3);}else{return monthName;}}function updateClock(){currentTime+=1000;clockSpan.innerHTML=getDisplayableDate(currentTime,strTargetTimeZoneDisplayName);}var TIME_ZONE_MAP=new Object();loadTimeZoneData(TIME_ZONE_MAP);function TimeZone(shortName,timeZoneId,startHour,startDate,startMonth,endHour,endDate,endMonth,daylightType,offset){this.shortName=shortName;this.timeZoneId=timeZoneId;this.startHour=startHour;this.startDate=startDate;this.startMonth=startMonth;this.endHour=endHour;this.endDate=endDate;this.endMonth=endMonth;this.daylightType=daylightType;this.offset=offset;this.getDaylightAdjustment=computeDaylightAdjustment;}var MONTH_DAYS=new Array(31,29,31,30,31,30,31,31,30,31,30,31);function getYearHours(month,day,hour){var daysSinceJan1=0;for(i=0;i<month;i++){daysSinceJan1+=MONTH_DAYS[i];}daysSinceJan1+=day;var hoursSinceJan1=daysSinceJan1*24+hour;return hoursSinceJan1;}function computeDaylightAdjustment(timeInMilliSeconds){var timeInMilliSecondsInTargetTZ=timeInMilliSeconds+this.offset*60*60*1000;var timeInTargetTZ=new Date(timeInMilliSecondsInTargetTZ);var dayOfMonth=timeInTargetTZ.getDate();var month=timeInTargetTZ.getMonth();var hour=timeInTargetTZ.getHours();var currentTimeYearHours=getYearHours(month,dayOfMonth,hour);var daylightStartYearHours=getYearHours(this.startMonth,this.startDate,this.startHour);var daylightEndyearHours=getYearHours(this.endMonth,this.endDate,this.endHour);var daylightSavingMilliSeconds=0;if(currentTimeYearHours>=daylightStartYearHours&&currentTimeYearHours<=daylightEndyearHours){if(DEBUG){alert("Daylight Savings applied");}daylightSavingMilliSeconds=60*60*1000;}if(this.daylightType=="daylight"){return daylightSavingMilliSeconds;}else{return daylightSavingMilliSeconds==0?60*60*1000:0;}}function loadTimeZoneData(timeZoneMap){timeZoneMap["America/Chicago"]=new TimeZone("CDT","America/Chicago",8,9,2,8,2,10,"daylight",-6);timeZoneMap["America/Mexico_City"]=new TimeZone("CDT","America/Mexico_City",8,6,3,7,26,9,"daylight",-6);timeZoneMap["Atlantic/Bermuda"]=new TimeZone("ADT","Atlantic/Bermuda",6,9,2,5,2,10,"daylight",-4);timeZoneMap["Europe/Andorra"]=new TimeZone("CEDT","Europe/Andorra",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Vienna"]=new TimeZone("CEDT","Europe/Vienna",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Brussels"]=new TimeZone("CEDT","Europe/Brussels",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Sarajevo"]=new TimeZone("CEDT","Europe/Sarajevo",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Zurich"]=new TimeZone("CEDT","Europe/Zurich ",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Prague"]=new TimeZone("CEDT","Europe/Prague",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Berlin"]=new TimeZone("CEDT","Europe/Berlin",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Copenhagen"]=new TimeZone("CEDT","Europe/Copenhagen",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Madrid"]=new TimeZone("CEDT","Europe/Madrid",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Paris"]=new TimeZone("CEDT","Europe/Paris",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Gibraltar"]=new TimeZone("CEDT","Europe/Gibraltar",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Zagreb"]=new TimeZone("CEDT","Europe/Zagreb",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Budapest"]=new TimeZone("CEDT","Europe/Budapest",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Rome"]=new TimeZone("CEDT","Europe/Rome",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Vaduz"]=new TimeZone("CEDT","Europe/Vaduz",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Luxembourg"]=new TimeZone("CEDT","Europe/Luxembourg",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Monaco "]=new TimeZone("CEDT","Europe/Monaco ",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Skopje"]=new TimeZone("CEDT","Europe/Skopje",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Malta"]=new TimeZone("CEDT","Europe/Malta",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Amsterdam"]=new TimeZone("CEDT","Europe/Amsterdam",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Oslo"]=new TimeZone("CEDT","Europe/Oslo",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Warsaw"]=new TimeZone("CEDT","Europe/Warsaw",1,30,2,1,26,9,"daylight",1);timeZoneMap["Arctic/Longyearbyen"]=new TimeZone("CEDT","Arctic/Longyearbyen",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/San_Marino"]=new TimeZone("CEDT","Europe/San_Marino",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Bratislava"]=new TimeZone("CEDT","Europe/Bratislava",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Ljubljana"]=new TimeZone("CEDT","Europe/Ljubljana",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Stockholm"]=new TimeZone("CEDT","Europe/Stockholm",1,30,2,1,26,9,"daylight",1);timeZoneMap["Africa/Tunis"]=new TimeZone("CEDT","Africa/Tunis",1,30,2,1,26,9,"daylight",1);timeZoneMap["Europe/Vatican"]=new TimeZone("CEDT","Europe/Vatican",1,30,2,1,26,9,"daylight",1);timeZoneMap["Asia/Yerevan"]=new TimeZone("AMDT","Asia/Yerevan",22,29,2,22,25,9,"daylight",4);timeZoneMap["America/Nassau"]=new TimeZone("EDT","America/Nassau",7,9,2,6,2,10,"daylight",-5);timeZoneMap["America/Montreal"]=new TimeZone("EDT","America/Montreal",7,9,2,6,2,10,"daylight",-5);timeZoneMap["America/Grand_Turk"]=new TimeZone("EDT","America/Grand_Turk",7,9,2,6,2,10,"daylight",-5);timeZoneMap["Asia/Baku"]=new TimeZone("AZDT","Asia/Baku ",0,30,2,0,26,9,"daylight",4);timeZoneMap["Europe/London"]=new TimeZone("GMT","Europe/London ",1,30,2,1,26,9,"daylight",0);timeZoneMap["Europe/Dublin"]=new TimeZone("GMT","Europe/Dublin",1,30,2,1,26,9,"daylight",0);timeZoneMap["Europe/Sofia"]=new TimeZone("EEDT","Europe/Sofia",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Minsk"]=new TimeZone("EEDT","Europe/Minsk",0,30,2,0,26,9,"daylight",2);timeZoneMap["Asia/Nicosia"]=new TimeZone("EEDT","Asia/Nicosia",1,30,2,1,26,9,"daylight",2);timeZoneMap["Africa/Cairo"]=new TimeZone("EEDT","Africa/Cairo",22,24,3,21,25,8,"daylight",2);timeZoneMap["Europe/Tallinn"]=new TimeZone("EEDT","Europe/Tallinn",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Helsinki"]=new TimeZone("EEDT","Europe/Helsinki",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Athens"]=new TimeZone("EEDT","Europe/Athens",1,30,2,1,26,9,"daylight",2);timeZoneMap["Asia/Amman"]=new TimeZone("EEDT","Asia/Amman ",22,26,2,22,30,9,"daylight",2);timeZoneMap["Asia/Beirut"]=new TimeZone("EEDT","Asia/Beirut ",22,29,2,21,25,9,"daylight",2);timeZoneMap["Europe/Vilnius"]=new TimeZone("EEDT","Europe/Vilnius",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Riga"]=new TimeZone("EEDT","Europe/Riga ",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Chisinau"]=new TimeZone("EEDT","Europe/Chisinau",1,30,2,1,26,9,"daylight",2);timeZoneMap["Asia/Gaza"]=new TimeZone("EEDT","Asia/Gaza",22,31,2,9,16,9,"daylight",2);timeZoneMap["Europe/Bucharest"]=new TimeZone("EEDT","Europe/Bucharest",1,30,2,1,26,9,"daylight",2);timeZoneMap["Asia/Damascus"]=new TimeZone("EEDT","Asia/Damascus",22,27,3,21,30,8,"daylight",2);timeZoneMap["Europe/Istanbul"]=new TimeZone("EEDT","Europe/Istanbul",1,30,2,1,26,9,"daylight",2);timeZoneMap["Europe/Kiev"]=new TimeZone("EEDT","Europe/Kiev",1,30,2,1,26,9,"daylight",2);timeZoneMap["Asia/Baghdad"]=new TimeZone("ADT","Asia/Baghdad ",0,1,3,0,1,9,"daylight",3);timeZoneMap["America/Sao_Paulo"]=new TimeZone("BDT","America/Sao_Paulo",2,2,10,3,24,1,"daylight",-3);timeZoneMap["America/Santiago"]=new TimeZone("CLDT","America/Santiago  ",3,9,2,4,12,9,"daylight",-4);timeZoneMap["America/Havana"]=new TimeZone("CDT","America/Havana",5,9,2,5,2,10,"daylight",-5);timeZoneMap["Atlantic/Faeroe"]=new TimeZone("WEDT","Atlantic/Faeroe",1,30,2,1,26,9,"daylight",0);timeZoneMap["Europe/Lisbon"]=new TimeZone("WEDT","Europe/Lisbon",1,30,2,1,26,9,"daylight",0);timeZoneMap["America/Godthab"]=new TimeZone("WGDT","America/Godthab",1,30,2,1,26,9,"daylight",-3);timeZoneMap["Asia/Yekaterinburg"]=new TimeZone("YEKDT","Asia/Yekaterinburg",21,28,2,21,25,9,"daylight",5);timeZoneMap["Asia/Jerusalem"]=new TimeZone("IDT","Asia/Jerusalem",0,28,2,11,4,9,"daylight",2);timeZoneMap["America/Asuncion"]=new TimeZone("PYDT","America/Asuncion",4,19,9,23,31,11,"standard",-4);timeZoneMap["Europe/Moscow"]=new TimeZone("MSD","Europe/Moscow",23,29,2,23,25,9,"daylight",3);timeZoneMap["America/Miquelon"]=new TimeZone("PMDT","America/Miquelon",11,9,2,11,2,10,"daylight",-3);timeZoneMap["Africa/Windhoek"]=new TimeZone("WADT","Africa/Windhoek",1,7,8,23,31,11,"standard",1);timeZoneMap["America/Montevideo"]=new TimeZone("UYT","America/Montevideo",5,5,9,23,31,11,"standard",-3);timeZoneMap["Pacific/Auckland"]=new TimeZone("NZDT","Pacific/Auckland",14,27,8,23,31,11,"standard",12);timeZoneMap["Antarctica/McMurdo"]=new TimeZone("NZDT","Antarctica/McMurdo",14,4,9,23,31,11,"standard",12);timeZoneMap["Australia/Sydney"]=new TimeZone("EDT","Australia/Sydney",16,5,9,16,6,3,"standard",10);timeZoneMap["Atlantic/Stanley"]=new TimeZone("FKDT","Atlantic/Stanley",6,7,8,23,31,11,"standard",-4);timeZoneMap["America/Buenos_Aires"]=new TimeZone("ARDT","America/Buenos_Aires",8,18,9,8,15,2,"standard",-3);}function getDaylightAdjustmentValue(targetTimeZoneId,timeInMilliSeconds){if(DEBUG){alert("'"+targetTimeZoneId+"'");}if(DEBUG){alert("new"+TIME_ZONE_MAP[targetTimeZoneId]);}var timeZoneObject=TIME_ZONE_MAP[targetTimeZoneId];if(timeZoneObject){if(DEBUG){alert("timeZoneObject.getDaylightAdjustment(timeInMilliSeconds): "+timeZoneObject.getDaylightAdjustment(timeInMilliSeconds));}strTargetTimeZoneDisplayName=timeZoneObject.shortName;if(DEBUG){alert("short name"+strTargetTimeZoneDisplayName);}return timeZoneObject.getDaylightAdjustment(timeInMilliSeconds);}else{return 0;}}function getTimeAdjustmentValue(targetTimeZoneId,timeInMilliSeconds,offsetValue){if(DEBUG){alert(offsetValue+" "+timeInMilliSeconds);}return offsetValue;}function getAbbreviation(strTargetTimeZoneDisplayName){if(DEBUG){alert(strTargetTimeZoneDisplayName+strTargetTimeZoneDisplayName.length);}var TimeZoneId="";var ind=0;ind=strTargetTimeZoneDisplayName.indexOf(" ");if(ind<1&&ind<strTargetTimeZoneDisplayName.length){TimeZoneId=strTargetTimeZoneDisplayName;}else{var str2=new Array();str2=strTargetTimeZoneDisplayName.split(" ");for(var x=0;x<str2.length;x=x+1){str2[x].substring(0,1);TimeZoneId+=str2[x].substring(0,1);}TimeZoneId=TimeZoneId.toUpperCase();}if(DEBUG){alert(TimeZoneId);}return TimeZoneId;}