// JavaScript Documentvar GmtInitIndex = 1;//初始化时区

//以下不用改
var cdlist = new Array();
var g_index=5;

cdlist.push(new Array('Rio de Janeiro Time',-3,false));
cdlist.push(new Array('EDT Time',-4,false));
cdlist.push(new Array('EST Time',-5,false));
cdlist.push(new Array('CST Time',-6,false));
cdlist.push(new Array('PST Time',-8,false));
cdlist.push(new Array('London Time',0,false));
cdlist.push(new Array('Warsaw Time',1,true));
cdlist.push(new Array('Athens Time',2,true));
cdlist.push(new Array('Beijing Time',8,false));
cdlist.push(new Array('Sydney Time',10,false));

/*
cdlist.push(new Array('(GMT -12:00) Eniwetok, Kwajalein',-12,false));

cdlist.push(new Array('(GMT -11:00) Midway Island, Samoa',-11,false));
cdlist.push(new Array('(GMT -10:00) Hawaii',-10,false));

cdlist.push(new Array('(GMT -09:00) Alaska',-9,false));
cdlist.push(new Array('(GMT -08:00) Pacific Time (US &amp; Canada), Tijuana',-8,false));
cdlist.push(new Array('(GMT -07:00) Mountain Time (US &amp; Canada), Arizona',-7,false));
cdlist.push(new Array('(GMT -06:00) Central Time (US &amp; Canada), Mexico City',-6,false));
cdlist.push(new Array('(GMT -05:00) Eastern Time (US &amp; Canada), Bogota, Lima, Quito',-5,false));

cdlist.push(new Array('(GMT -04:00) Atlantic Time (Canada), Caracas, La Paz',-4,false));
cdlist.push(new Array('(GMT -03:30) Newfoundland',-3.5,false));
cdlist.push(new Array('(GMT -03:00) Brassila, Buenos Aires, Georgetown, Falkland Is',-3,false));
cdlist.push(new Array('(GMT -02:00) Mid-Atlantic, Ascension Is., St. Helena',-2,false));
cdlist.push(new Array('(GMT -01:00) Azores, Cape Verde Islands',-1,false));
cdlist.push(new Array('(GMT) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia',0,false));
cdlist.push(new Array('(GMT +01:00) Amsterdam, Berlin, Brussels, Madrid, Paris, Rome',1,false));
cdlist.push(new Array('(GMT +02:00) Cairo, Helsinki, Kaliningrad, South Africa',2,false));
cdlist.push(new Array('(GMT +03:00) Baghdad, Riyadh, Moscow, Nairobi',3,false));

cdlist.push(new Array('(GMT +03:30) Tehran',3.5,false));
cdlist.push(new Array('(GMT +04:00) Abu Dhabi, Baku, Muscat, Tbilisi',4,false));
cdlist.push(new Array('(GMT +04:30) Kabul',4.5,false));
cdlist.push(new Array('(GMT +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent',5,false));
cdlist.push(new Array('(GMT +05:30) Bombay, Calcutta, Madras, New Delhi',5.5,false));
cdlist.push(new Array('(GMT +05:45) Katmandu',5.75,false));
cdlist.push(new Array('(GMT +06:00) Almaty, Colombo, Dhaka, Novosibirsk',6,false));
cdlist.push(new Array('(GMT +06:30) Rangoon',6.5,false));
cdlist.push(new Array('(GMT +07:00) Bangkok, Hanoi, Jakarta',7,false));

cdlist.push(new Array('(GMT +08:00) Beijing, Hong Kong, Perth, Singapore, Taipei',8,false));
cdlist.push(new Array('(GMT +09:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk',9,false));
cdlist.push(new Array('(GMT +09:30) Adelaide, Darwin',9.5,false));
cdlist.push(new Array('(GMT +10:00) Canberra, Guam, Melbourne, Sydney, Vladivostok',10,false));
cdlist.push(new Array('(GMT +11:00) Magadan, New Caledonia, Solomon Islands',11,false));
cdlist.push(new Array('(GMT +12:00) Auckland, Wellington, Fiji, Marshall Island',12,false));
//</select>
*/
function mm(obj,t){
    if (t==1){
        obj.className = 'ch';
        obj.style.background = '#CCCCCC';
        obj.style.cursor = 'pointer';
    }else{
    	obj.style.background = '';
        obj.className = '';
    }
}
function hidden(es){
    var es = document.getElementById(es);
    es.style.display = 'none';
}
function dispEvent(obj,id){
    var es = document.getElementById(id);
    var obj = document.getElementById(obj);
    
    if (es.style.display == ''){
        hidden(id);
        return;
    }
    
    var s = '';
    var sur = '';
    for (var i=0; i<cdlist.length; i++){
        s = '<div style="width:100%;" onmouseover="mm(this,1)" onmouseout="mm(this,0)" ';
        s = s + 'onclick="setClock('+i+')">';
        s = s +cdlist[i][0]+'</div>';
        sur = sur + s;
    }
    
    var xy = getXY(obj);
    xy.top += obj.offsetHeight+1;
    es.style.left = xy.left;
    es.style.top = xy.top;
    es.innerHTML = sur;
    es.style.display = 'block';
    if (typeof(es.textContent)!='undefined'){
        es.style.left = xy.left+'px';
        es.style.top = xy.top+'px';
		es.style.width='200px';
        es = document.getElementById('fu')
    }
	try{
    es.focus();
	}catch(ex){}
    return false;
}
function getXY(obj){
    var vleft = obj.offsetLeft;
    var vtop = obj.offsetTop;
    while (obj = obj.offsetParent){
        vleft += obj.offsetLeft;
        vtop += obj.offsetTop;
        
    }
    return {left:vleft,top:vtop};
}

function setClock(i){
    hidden('cdtext');
    g_timezone=g_index=i;
}

// You'd better use' getTime ,setTime,
function THINPIGServerTime()
{
  	var date=new Date();
	
	var timezone=cdlist[0];
	l=cdlist.length;
	for(i=0;i<l;i++){
		if(cdlist[i][1]==g_timezone){
			timezone=cdlist[i];
			g_index=i;
			break;
		}
	}
	
	
	
	
	var newdate=new Date(date.getTime()  + timezone[1]*60*60*1000  +date.getTimezoneOffset()*60*1000); //当前 15 点。 时间差  -4 小时 , 15 + -4 为 伦敦时间
	//+ cdlist[g_index][1]*60*60*1000 + 12*60*60*1000 + date.getTimezoneOffset()*60*1000
	//var m=cdlist[g_index][0].match(/[^)]+\)/);
	//var str=m[0];
	var str = cdlist[g_index][0];
	var obj = document.getElementById('cdlab').innerHTML=str;
	document.getElementById("time").innerHTML=newdate.toLocaleTimeString(); 
	document.getElementById("clock").innerHTML = newdate.toDateString();
  
	return;	
}

setInterval("THINPIGServerTime()", 1000);
//setTimeout("THINPIGServerTime()", 1000);
//if (GmtInitIndex != GmtIndex){
    //setClock(GmtInitIndex);
//}
