﻿kMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
function getMonth(m) { // returns human readable month based on int input, 0==january, etc.
    return(kMonths[m]);
}


function WorldClock(){

now=new Date();

hr=now.getHours();

min=now.getMinutes();

sec=now.getSeconds();

off=now.getTimezoneOffset()/60;

hr=hr+parseInt(off)-8;



save=0;
month=now.getMonth()+1;
day=now.getDate();
year=now.getYear();
if (year<1000) year+=1900;

if (month==3 && day>=9) save=1;
if (month>3) save=1;
if (month==11 && day>=2) save=0;
if (month>11) save=0;

hr+=save;

//alert ("month="+month+" day="+day);



if (hr < 0) hr+=24;

if (hr > 23) hr-=24;

ampm = (hr > 11)?"PM":"AM";



if (hr == 0) hr=12;

if (hr > 12) hr=hr-12;

if (hr < 10) hr="0"+hr;

if (min < 10) min="0"+min;

if (sec < 10) sec="0"+sec;



finaltime = "San Francisco &nbsp;<span style='color:#cccccc'>|</span>&nbsp; " + getMonth(month-1) + " " + day + ", " + year + " &nbsp;<span style='color:#cccccc'>|</span>&nbsp; " + hr + ":" + min + ":" + sec + " " + ampm;



if (document.all)

worldclock.innerHTML=finaltime;

else if (document.getElementById)

document.getElementById("worldclock").innerHTML=finaltime;




setTimeout('WorldClock()',1000);

}