var sUserAgent	= navigator.userAgent;
var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1;
var maincat   = 0;
window.setTimeout("history.go(0)", 420000);

var xmlHttp;
function GetXmlHttpObject(){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest) objXMLHttp=new XMLHttpRequest();
	else if (window.ActiveXObject)	objXMLHttp=new ActiveXObject('Microsoft.XMLHTTP');
	return objXMLHttp;
}
/////////////////search//////////////////////////
function Opt_show(num){
	if(num	== 1){
		document.getElementById("ques").value	= "";
	}else if(num	== 2){
		document.getElementById("ques").value	= "Search";
	}
}
function searchck(f){
	var	 Msearch	= document.getElementById("ques");
	if(Msearch.value	== "" || Msearch.value	== null){
		alert("Please enter a search query.");
		Msearch.focus();
		return false;
	}else{
		if(document.getElementById("way").checked==false){ 	
			document.getElementById("ques").name = "q";
			f.action = "http://search.msn.com/results.aspx";	
		} 
	}
	return true;
}
// drop down menu
var S_move=true;
var mhigh = "188px";
var S_state=1;
var S_time;
var speed = 20;
var sUserAgent	= navigator.userAgent;
var isIE		= sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1;
function ini_large(){
	if(isIE) document.getElementById("edition").style.overflow = "hidden";
	if(S_move){
		S_move = false;		
		Dobj = document.getElementById("country").style;
		if(S_state == 2){ 
			mhigh = Dobj.height;
			large();
		}else {
			document.onmousemove = Mouse_position;
			Dobj.height = "21px";
			large2();
		}
	}
}
function large(){
	if(eval(Dobj.height.substring(0,Dobj.height.indexOf('p'))) > 32){
		Dobj.height = eval(Dobj.height.substring(0,Dobj.height.indexOf('p'))) - 10 + "px";
		S_time = setTimeout("large()",speed);
	}else{
		Dobj.height = "21px";
		clearTimeout(S_time);
		S_state = 1;
		S_move = true;
		document.onmousemove = null;
	}	
}
function large2(){
	if(eval(Dobj.height.substring(0,Dobj.height.indexOf('p'))) < (eval(mhigh.substring(0,mhigh.indexOf('p')))-10)){
		Dobj.height = eval(Dobj.height.substring(0,Dobj.height.indexOf('p'))) + 7 + "px";
		S_time = setTimeout("large2()",speed);
	}else{
		Dobj.height = mhigh;
		clearTimeout(S_time);
		S_state = 2;
		S_move = true;
	}
}

function reduce(){
	if((M_posx<todo || M_posx>(todo+135) || M_posy<95 || M_posy>285) || M_cnt){
		S_move = false;
		M_cnt = true;
		large();	
	}
}

var M_posx;
var M_posy;
var reduceTime;
var M_cnt;
var todo;
function Mouse_position(e) {
	M_posx = 0;
	M_posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		M_posx = e.pageX;
		M_posy = e.pageY;
	} 
	else if (e.clientX || e.clientY) 	{
		M_posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		M_posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	
	todo = findPos(document.getElementById("country"))[0];
	if(M_posx<todo || M_posx>(todo+135) || M_posy<80 || M_posy>285){
		M_cnt = false;
		if(reduceTime)	clearTimeout(reduceTime);
		reduceTime = setTimeout("reduce()",250);
	}
}

function findPos(obj) {
	var pos = new Array();
	pos[0] = pos[1] = 0;
	if (obj.offsetParent) {
		pos[0] = obj.offsetLeft
		pos[1] = obj.offsetTop
		while (obj = obj.offsetParent) {
			pos[0] += obj.offsetLeft
			pos[1] += obj.offsetTop
		}
	}
	return pos;
}

function gotopage(Obj){
	clearTimeout(S_time);
	S_state = 1;
	document.getElementById("e_first").innerHTML = Obj.innerHTML;
	document.getElementById("country").style.height = "21px";
}

// advertisement
function click_textad(val,val2){
	xmlHttp=GetXmlHttpObject();
	var url="/textad/click_textad.php";
	url=url+"?banner="+val;
	url=url+"&zone="+val2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}	
function view_textad(val,val2){
	xmlHttp=GetXmlHttpObject();
	var url="/textad/view_textad.php";
	url=url+"?banner="+val;
	url=url+"&zone="+val2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
function PopUp(URL, width, height,scroll) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, 'infoPage', 'toolbar=0,scrollbars='+scroll+',location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left = 100,top = 0');");
}

function view_banner(val,val2){
	xmlHttp=GetXmlHttpObject();
	var url="/banner/view_banner.php";
	url=url+"?banner="+val;
	url=url+"&zone="+val2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}

function click_banner(val,val2){
	xmlHttp=GetXmlHttpObject();
	var url="/banner/click_banner.php";
	url=url+"?banner="+val;
	url=url+"&zone="+val2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}	
function openflash(width,height,src){ 
    var text="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width="+width+" height="+height+"><param name=movie value="+src+"><param name=quality value=high ><param name=wmode value=transparent><param name=menu value=false><embed src="+src+" quality=high  pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width="+width+" height="+height+"  wmode=transparent menu=false></embed></object>"; 
	document.write(text); 
} 
function openflash2(divid,width,height,src){ 
    var text="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width="+width+" height="+height+"><param name=movie value="+src+"><param name=quality value=high ><param name=wmode value=transparent><param name=menu value=false><embed src="+src+" quality=high  pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width="+width+" height="+height+"  wmode=transparent menu=false></embed></object>"; 
	document.getElementById(divid).innerHTML=text;
} 

//ZhaiHao Modify
function write_editor(emailaddress) {
	window.location = 'mailto:'+emailaddress+'?subject=Reader Feedback&body=Dear Editor, %0D%0A%0D%0A';
}

//most popular tab
var which_part;
var argnum;
var settime;
function over_change_top(val){
	for(var i=0;i<arr2.length;i++){
		for(var j=0;j<arr.length;j++){
			for(var k=1;k<8;k++){
				if(document.getElementById(arr[j]+k))document.getElementById(arr[j]+k).style.color = "#0860A8";
			}
		}
		if(val==i&&document.getElementById(arr2[i])){
			document.getElementById(arr2[i]).style.background= "url(/images/most_bar_bg3.gif)";
			document.getElementById(arr2[i]).style.color = "#CC0000";
			document.getElementById(arr[i]).style.display = "block";
		}else if(document.getElementById(arr2[i])){
			document.getElementById(arr2[i]).style.background = "url(/images/most_bar_bg2.gif)";
			document.getElementById(arr2[i]).style.color = "#000000";
			document.getElementById(arr[i]).style.display = "none";			
		}else{
			document.getElementById(arr2[i]).style.background = "url(/images/most_bar_bg2.gif)";
			document.getElementById(arr2[i]).style.color = "#000000";
			document.getElementById(arr[i]).style.display = "none";				
		}
	}	
	which_part = arr[val];
	clearTimeout(settime);
	argnum = 1;
	if(document.getElementById(which_part+"7"))mostread_top();
}	

function mostread_top(){
	document.getElementById(which_part+argnum).style.color="#000000";
	if(argnum!=1){ 
		document.getElementById(which_part+(argnum-1)).style.color="#0860A8";
	}else{
	    document.getElementById(which_part+"7").style.color="#0860A8";
	}
	if(argnum++ == 7) argnum=1;
	settime = setTimeout("mostread_top()",2500);
}