var admin5={
	init:function(){
		
		var elms = document.getElementsByName("sliding");

		for(var g=0; g<elms.length; g++){
			
			var lielms = elms[g].getElementsByTagName('LI');
			
			for(var i=0; i<lielms.length; i++){
				
				lielms[i].onmousedown = function(){
					
					var pnobj = this.parentNode.parentNode.nextSibling.tagName == "DIV" ? this.parentNode.parentNode.nextSibling : this.parentNode.parentNode.nextSibling.nextSibling;
					var objsx = pnobj.getElementsByTagName('UL');
					var elmsx = this.parentNode.getElementsByTagName('LI');
					var thisx = 0;
					
					for(var j=0; j<elmsx.length; j++){
						if(elmsx[j] == this) thisx = j;
						elmsx[j].className="";
						objsx[j].style.display="none";
					}
					
					this.className='on';
					objsx[thisx].style.display="";
					
				}
			}
		}

		if(Cookie.getCookie('smeta'))
		{
			var elms = $('content').getElementsByTagName('DIV');
			for(var i=0; i<elms.length; i++){
				if(elms[i].className == 'box2'){
					elms[i].style.display = 'none';
				}
			}
			$('content').getElementsByTagName('A')[0].innerHTML='摘要模式';
		}
		
	}
}

function $(element) {
	var elements = new Array();
	if (arguments.length > 1) {
		for (var i = 0, elements = [], length = arguments.length; i < length; i++)
		elements.push($(arguments[i]));
		return elements;
	}
	element = document.getElementById(element);
	return element;
}

var Cookie=new Object();
Cookie.setCookie=function(name,value,option){
	var str=name+"="+escape(value);		
	if(option){
		if(option.expireDays){
			var date=new Date();
			var ms=option.expireDays*24*3600*1000;
			date.setTime(date.getTime()+ms);
			str+="; expires="+date.toGMTString();
		}	
		if(option.path)str+="; path="+path;
		if(option.domain)str+="; domain"+domain;
		if(option.secure)str+="; true";	
	}
	document.cookie=str;
}

Cookie.getCookie=function(name){
	var cookieArray=document.cookie.split("; ");
	var cookie=new Object();
	for(var i=0;i<cookieArray.length;i++){
		var arr=cookieArray[i].split("=");
		if(arr[0]==name)return unescape(arr[1]);
	}
	return "";
}

Cookie.deleteCookie=function(name){
	this.setCookie(name,"",{expireDays:-1});
}

function list_mode(elm){
	
	var elms = $('content').getElementsByTagName('DIV');
	
	if(Cookie.getCookie('smeta')){
		
		for(var i=0; i<elms.length; i++){
			if(elms[i].className == 'box2'){
				elms[i].style.display = 'block';
			}
		}
		Cookie.deleteCookie('smeta');
		elm.innerHTML='简洁模式';
		
	}else{
		for(var i=0; i<elms.length; i++){
			if(elms[i].className == 'box2'){
				elms[i].style.display = 'none';
			}
		}
		Cookie.setCookie('smeta',1);
		elm.innerHTML='摘要模式';
	}
}

function spcover(id){
	var tp = arguments[1]?arguments[1]:'u';
	var dp = arguments[2]?arguments[2]:'view';
	var d  = new Date();
	var url = '/plus/spcover.php?id='+id+'&tp='+tp+'&dp='+dp+'&time='+d.getUTCSeconds();
	var req;
	var msg;
	
	if (window.XMLHttpRequest) { // Non-IE browsers
		req = new XMLHttpRequest();
		try {
			req.open("GET", url, false);
		} catch (e) {
			alert(e);
		}
		req.send(null);
	} else if (window.ActiveXObject) { // IE
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.open("GET", url, false);
			req.send();
		}
	}
	if (req.readyState == 4) { 
		if (req.status == 200) { 
			if (req.responseText == 0) {
				msg = "您已经投过票了，感谢您的参与!";
			} else {
				var diggs = req.responseText.split(':');
				
				var sUp = parseInt(diggs[0]);
				var sDown = parseInt(diggs[1]);
				var sTotal = sUp+sDown;
				var spUp=(sUp/sTotal)*100;
				spUp=Math.round(spUp*10)/10;
				var spDown=100-spUp;
				spDown=Math.round(spDown*10)/10;
				if(sTotal!=0){
					$('s1').innerHTML=sUp;
					$('s2').innerHTML=sDown;
					$('sp1').innerHTML=spUp+'%';
					$('sp2').innerHTML=spDown+'%';
					$('eimg1').style.width = parseInt((sUp/sTotal)*55);
					$('eimg2').style.width = parseInt((sDown/sTotal)*55);
				}

				msg = "投票成功！";
			}
		}
	} else {
		msg = "暂时不能进行投票";
	}
	if(dp == 'vote'){
		alert(msg);
	}
	
}