
//article counter
function article_counter(val){
	xmlHttp=GetXmlHttpObject();
	var url="/article/article_counter.php";
	url=url+"?id="+val;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
//font size
function setFontSize(sz){
	if(sz == 9 || sz == 12 || sz == 18){
		document.getElementById("first_paragraph").className= "f" + sz + "black_at";
 		document.getElementById("b_paragraph").className= "f" + sz + "black_at";
 		setCookie("IBTIMES_FONTSIZE", sz,365);
 	}
}

function loadingFontSize(){
	var sz = parseInt(getCookie("IBTIMES_FONTSIZE"));
	if(sz == 12 || sz == 18){
		setFontSize(sz);
	}
}

function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

//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);
}
function tab_color(val,val2){
	for(var i=1;i<=val2;i++){
		if(i==val){
			document.getElementById("tag"+val).style.backgroundColor="#3A5EC6";
			document.getElementById("tag"+val).style.color="#ffffff";
			document.getElementById("article_tag"+val).style.display = "block";
		}else{
			document.getElementById("tag"+i).style.backgroundColor="#ffffff";
			document.getElementById("tag"+i).style.color="#3A5EC6";	
			document.getElementById("article_tag"+i).style.display = "none";	
		}
	}
}
function article_tags(val,val2,keywords,article_id){
	xmlHttp=GetXmlHttpObject();
	for(var i=1;i<=val2;i++){
		if(i==val){
			document.getElementById("tag"+val).style.backgroundColor="#3A5EC6";
			document.getElementById("tag"+val).style.color="#ffffff";
		}else{
			document.getElementById("tag"+i).style.backgroundColor="#ffffff";
			document.getElementById("tag"+i).style.color="#3A5EC6";	
		}
	}
	var url='/article/article_tags.php';
	url=url+'?article_id='+article_id+'&keywords='+keywords;
	xmlHttp.onreadystatechange=changed_article_tags; 
	xmlHttp.open('GET',url,true);
	xmlHttp.send(null);			
}

function changed_article_tags() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=='complete'){
		 var gettext=xmlHttp.responseText.split('@@');
		document.getElementById(gettext[0]).innerHTML=gettext[1];
	}
} 
function news_val(Obj,num){
	if(num	== 1){
		Obj.value	= "";
	}else if(num	== 2){
		Obj.value	= "email";
	}
}
/////// comment///
function checkform(f,val){
	if(f.nickname.value==""){ 
		alert("Please type in nickname");
		f.nickname.focus();
		return false;
	}
	if(f.comments.value==""){
		alert("Please type in comment");
		f.comments.focus();
		return false;
	}
	f.artid.value = artid;
	f.src_from.value = s_from;
	f.keywords.value = keywords;
	f.date.value = c_date;
	if(val==0)	f.re_reid.value = 0;
	else        f.re_reid.value = value;
	return true;
}

//print article
function POPprint(num,table){
	window.open("/services/pop_print.htm?id="+num+"&tb="+table,"printing","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=520,height=520 ,left = 100,top = 100");
}

function popUp(URL, width, height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, 'infoPage', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=' + width + ',height=' + height + ',left = 100,top = 0');");
}
