﻿function showloading(isdisplay){
	if(isdisplay) {
		var xScroll, yScroll;
			
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY-300;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else {
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
			
		var windowWidth, windowHeight;
			
		if (self.innerHeight) {
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) {
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}	
	
		document.getElementById("loadinglayer").style.display = "block";
		document.getElementById("loadinglayer").style.width = pageWidth+"px";
		document.getElementById("loadinglayer").style.height = pageHeight+"px";
		document.getElementById("loadingdiv").style.display = "block";
		document.getElementById("loadingdiv").style.top = (yScroll-windowHeight+windowHeight/2+16)+"px";
		document.getElementById("loadingdiv").style.left = (pageWidth/2-50)+"px";
	} else {
		document.getElementById("loadinglayer").style.display = "none";
		document.getElementById("loadingdiv").style.display = "none";
	}
}
function doZoom(size){
	document.getElementById("article_content").style.fontSize=size+'px';
}	
function addMe(title){
      var url = document.location;
	  window.external.addFavorite(url,title);
}
function printArticle(){
	print();
}
function showIt(id,isDisplay){
	if(isDisplay){
		document.getElementById(id).style.display='';
	}else{
		document.getElementById(id).style.display='none';
	}
}
function hide(c_id){
 if (document.getElementById(c_id).style.display=="none") {
   var arrsort=document.getElementsByTagName("ul"); 
    for(var i=0;i<arrsort.length;i++)    {
       if(arrsort[i].id.indexOf("sort_")>-1)       {
        document.getElementById(arrsort[i].id).style.display="none";
       }
    }
     document.getElementById(c_id).style.display="";
 }
}
function getCookie(ckname){
	var cookieValue = "";
	var search = ckname + "=";
	offset = document.cookie.indexOf(search);
	if (offset != -1) {
		offset += search.length;
		end = document.cookie.indexOf(";", offset);
		if (end == -1) end = document.cookie.length;
		cookieValue = unescape(document.cookie.substring(offset, end));
	}
	return cookieValue;
}
function delCookie(name){
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function refreshCode()
{
	var now=new Date();
	document.getElementById("piccode").src="sunbu_code.aspx?random="+now;
}
function signOut()
{
	delCookie("username");
	window.location.href = "/Default.aspx";
}
