// JavaScript Document
var timerID ;
function tzone(tz, os, ds, cl)
{
	this.ct = new Date(0) ;
	this.tz = tz ;
	this.os = os ;
	this.ds = ds ;
	this.cl = cl ;
}
function UpdateClocks()
{
	var ct = new Array(
		new tzone('', 0, 1, 'black'),
		new tzone('', -10, 1, 'black'),
		new tzone('', -9, 1, 'black'),
		new tzone('', -8, 1, 'black'),
		new tzone('', -7, 1, 'black'),
		new tzone('',  -6, 1, 'black'),
		new tzone('', -5, 1, 'black'),
		new tzone('',  -4, 1, 'black'),
		new tzone('', -3, 1, 'black'),
		new tzone('', 0, 1, 'black'),
		new tzone('', +1, 0, 'black'),
		new tzone('', +2, 0, 'black'),
		new tzone('', +3, 0, 'black'),
		new tzone('', +4, 0, 'black'),
		new tzone('',  +5, 0, 'black'),
		new tzone('', +6, 0, 'black'),
		new tzone('',  +8, 0, 'black'),
		new tzone('', +8, 0, 'black'),
		new tzone('',  +9, 0, 'black'),
		new tzone('', +10, 0, 'black'),
		new tzone('', +12, 0, 'black')
		
	) ;
	var dt = new Date() ;
	var startDST = new Date(dt.getFullYear(), 3, 1) ;
	while (startDST.getDay() != 0)
		startDST.setDate(startDST.getDate() + 1) ;
	var endDST = new Date(dt.getFullYear(), 9, 31) ;
	while (endDST.getDay() != 0)
		endDST.setDate(endDST.getDate() - 1) ;
	var ds_active ;
	if (startDST < dt && dt < endDST)
		ds_active = 1 ;
	else
		ds_active = 0 ;
	for(n=0 ; n<ct.length ; n++)
		if (ct[n].ds == 1 && ds_active == 1) ct[n].os++ ;
	// compensate time zones
	gmdt = new Date() ;
	for (n=0 ; n<ct.length ; n++)
		ct[n].ct = new Date(gmdt.getTime() + ct[n].os * 3600 * 1000) ;
	document.all.ClockBeijing.innerHTML =ct[16].tz + ClockString(ct[16].ct);	
	document.all.ClockNiuyue.innerHTML =ct[6].tz + ClockString(ct[6].ct);
	document.all.ClockLundun.innerHTML =ct[9].tz + ClockString(ct[9].ct);
	//document.all.ClockBali.innerHTML =ct[9].tz + ClockString2(ct[9].ct);	
	//document.all.ClockMadeli.innerHTML =ct[9].tz + ClockString3(ct[9].ct);		
	document.all.ClockBolin.innerHTML =ct[10].tz + ClockString(ct[10].ct);
	document.all.ClockDongjing.innerHTML =ct[18].tz + ClockString(ct[18].ct);
	document.all.ClockXini.innerHTML =ct[19].tz + ClockString(ct[19].ct);
	//document.all.ClockDibai.innerHTML =ct[20].tz + ClockString(ct[20].ct);
	document.all.ClockKailuo.innerHTML =ct[12].tz + ClockString(ct[12].ct);
	document.all.ClockMosike.innerHTML =ct[12].tz + ClockString(ct[12].ct);
	timerID = window.setTimeout("UpdateClocks()", 1001) ;
}
function ClockString(dt)
{
	var stemp, ampm ;
	var dt_year = dt.getUTCFullYear() ;
	var dt_month = dt.getUTCMonth() + 1 ;
	var dt_day = dt.getUTCDate() ;
	var dt_hour = dt.getUTCHours() ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;
	dt_year = dt_year.toString() ;
//	if (0 <= dt_hour && dt_hour < 12)
//	{
//		ampm = 'AM' ;
//		//if (dt_hour == 0) dt_hour = 12 ;		
//	} else {
//		ampm = 'PM' ;
//		dt_hour = dt_hour - 12 ;
//		//if (dt_hour == 0) dt_hour = 12 ;		
//	}
	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;
	if (dt_second < 10)
		dt_second = '0' + dt_second ;
	stemp =  dt_year+'-'+dt_month + '-' + dt_day;
	stemp = stemp + ' ' + dt_hour + ":" + dt_minute;
	return stemp ;
}

function ClockString2(dt)
{
	var stemp, ampm ;
	var dt_year = dt.getUTCFullYear() ;
	var dt_month = dt.getUTCMonth() + 1 ;
	var dt_day = dt.getUTCDate() ;
	var dt_hour = dt.getUTCHours()+1 ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;
	dt_year = dt_year.toString() ;
	if (0 <= dt_hour && dt_hour < 12)
	{
		ampm = 'AM' ;
		//if (dt_hour == 0) dt_hour = 12 ;		
	} else {
		ampm = 'PM' ;
		dt_hour = dt_hour - 12 ;
	//	if (dt_hour == 0) dt_hour = 12 ;		
	}
	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;
	if (dt_second < 10)
		dt_second = '0' + dt_second ;
	stemp =  dt_year+'-'+dt_month + '-' + dt_day;
	stemp = stemp + ' ' + dt_hour + ":" + dt_minute;
	return stemp ;
}

function ClockString3(dt)
{
	var stemp, ampm ;
	var dt_year = dt.getUTCFullYear() ;
	var dt_month = dt.getUTCMonth() + 1 ;
	var dt_day = dt.getUTCDate() ;
	var dt_hour = dt.getUTCHours()-1 ;
	var dt_minute = dt.getUTCMinutes() ;
	var dt_second = dt.getUTCSeconds() ;
	dt_year = dt_year.toString() ;
	if (0 <= dt_hour && dt_hour < 12)
	{
		ampm = 'AM' ;
		//if (dt_hour == 0) dt_hour = 12 ;		
	} else {
		ampm = 'PM' ;
		dt_hour = dt_hour - 12 ;
	//	if (dt_hour == 0) dt_hour = 12 ;		
	}
	if (dt_minute < 10)
		dt_minute = '0' + dt_minute ;
	if (dt_second < 10)
		dt_second = '0' + dt_second ;
	stemp =  dt_year+'-'+dt_month + '-' + dt_day;
	stemp = stemp + ' ' + dt_hour + ":" + dt_minute;
	return stemp ;
}