var CLOCKS={ // v0.1
	timeStamp:new Date(),
	dstOffset:0,
	init:function(){
		CLOCKS.dstOffset=CLOCKS.getDstOffset();
		if($.getByClass("home",document,"body")[0]){
			CLOCKS.initClock("clock-portland",CLOCKS.dstOffset-8);
			CLOCKS.initClock("clock-chicago",CLOCKS.dstOffset-6);
			CLOCKS.initClock("clock-shanghai",8);
			setTimeout("CLOCKS.updateClock()",500);
			}
		},
	getDstOffset:function(){
		todayDate=new Date();
		todayYear=document.all?todayDate.getYear():1900+todayDate.getYear();
		todayMonth=todayDate.getMonth()+1;
		todayDay=todayDate.getDate();
		if(todayMonth>=4&&todayMonth<=10)return 1;
		else if(todayMonth<=2||todayMonth==12)return 0;
		else if(todayMonth==3){
			secondSunday=0;
			for(dayCounter=8;dayCounter<=14;dayCounter++){
				temp=new Date(todayYear,2,dayCounter,0,0,0);
				if(temp.getDay()==0)secondSunday=dayCounter;
				}
			return todayDay>=secondSunday?1:0;
			}
		else if(todayMonth==11){
			firstSunday=0;
			for(dayCounter=1;dayCounter<=7;dayCounter++){
				temp=new Date(todayYear,10,dayCounter,0,0,0);
				if(temp.getDay()==0)firstSunday=dayCounter;
				}
			return todayDay>=firstSunday?0:1;
			}
		},
	initClock:function(clockId,utcOffset){
		CLOCKS.setClockTime(clockId,utcOffset);
		clock=$.getById(clockId);
		$.getByTag("span",clock)[0].innerHTML="<object "+(document.all?classid="classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\"":classid="classid=\"java:AnalogClockApplet.class\" type=\"application/x-java-applet\"")+" height=\"60\" width=\"60\"><param name=\"code\" value=\"AnalogClockApplet\" /><param name=\"codebase\" value=\"/_obj/java/\" /><param name=\"time-zone\" value=\""+utcOffset+"\" /><param name=\"show-seconds\" value=\"true\" /><param name=\"hand-color\" value=\"#60B0CF\" /><param name=\"second-hand-color\" value=\"#D1D1CE\" /><param name=\"face-color\" value=\"#FFFFFF\" /><param name=\"frame-color\" value=\"#999999\" /><param name=\"background-color\" value=\"#F1F1F1\" /></object>";
		clock.style.visibility="visible";
		},
	setClockTime:function(clockId,utcOffset){
		clock=$.getById(clockId);
		clockTime=$.getByClass("time",clock)[0];
		hour=(CLOCKS.timeStamp.getUTCHours()+utcOffset)%24;if(hour<0)hour=hour+24;
		// alert(CLOCKS.timeStamp.getUTCHours());
		minute=CLOCKS.timeStamp.getUTCMinutes();
		clockTime.innerHTML=(hour%12==0?12:hour%12)+":"+(minute<10?"0"+minute:minute)+"<span>"+(hour<12?"AM":"PM")+"</span>";
		},
	updateClock:function(){
		updateDate=new Date();
		if(updateDate.getUTCMinutes()!=CLOCKS.timeStamp.getUTCMinutes()){
			CLOCKS.timeStamp = updateDate;
			CLOCKS.setClockTime("clock-portland",CLOCKS.dstOffset-8);
			CLOCKS.setClockTime("clock-chicago",CLOCKS.dstOffset-6);
			CLOCKS.setClockTime("clock-shanghai",8);
			setTimeout("CLOCKS.updateClock()",500);
			}
		else setTimeout("CLOCKS.updateClock()",500);
		}
	};

$.addOnload(CLOCKS.init);
