//更换皮肤
function ChangeSkin(str){
	skincss=document.getElementById("SkinCss");
	if(str==getCookie("SkinCss")) return false;
	SetCookie("SkinCss",str);
	skincss.href='skin_img/'+str+'/style.css';
}
//设置cookie
function SetCookie(name,value){
    var Days=30;//此 cookie 将被保存 30 天
    var exp=new Date();
    exp.setTime(exp.getTime()+Days*24*60*60*1000);
    document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();
}
//读取cookie
function getCookie(name){
    var arr =document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr!= null) return unescape(arr[2]);
	return null;
}

//li里的ul控制
function SubUlCtrl(ob){
	var ul=null;
	if(typeof(ob)=="string"){		
		ul=document.getElementById(ob).getElementsByTagName("ul")[0];	
		//分类浏览
		if(ob.indexOf("parentBooks")==0){
			var pbd_Nav_BookType=document.getElementById("pbd_Nav_BookType").getElementsByTagName("li");
			for(i=0;i<pbd_Nav_BookType.length;i++){
				var idName=pbd_Nav_BookType[i].getAttribute("id");
				if(idName==null || idName==ob){continue;}
				if(idName.indexOf("parentBooks")==0 && pbd_Nav_BookType[i].getElementsByTagName("ul")[0]!=undefined){
					pbd_Nav_BookType[i].getElementsByTagName("ul")[0].style.cssText="display:none";
				}
			}
			if(ul==undefined){return true;}			
			ul.style.cssText=="" || ul.style.display=="none" ? ul.style.cssText="display:block" : ul.style.cssText="display:none";	
		}
		//新书推荐
		else if(ob.indexOf("NewBookFrame")==0){
			for(i=1;i<5;i++){
				var idName="NewBookFrame"+i;
				if(idName==ob){continue;}
				if(document.getElementById(idName).getElementsByTagName("ul")[0]!=undefined){
					document.getElementById(idName).getElementsByTagName("ul")[0].style.cssText="display:none";
				}
			}
			if(ul==undefined){return false;}			
			if(ul.style.cssText=="" || ul.style.display=="none"){ul.style.cssText="display:block";}
		}
		return false;
	}
	//无ID控制，仅限当前元素的父级里的ul
	else if(typeof(ob)=="object"){
		if(ob.parentNode.className=="PackageListTitle"){
			ob=ob.parentNode.parentNode;
		}
		else{ob=ob.parentNode;}
		ul=ob.getElementsByTagName("ul")[0];
		if(ul==undefined){return true;}			
		if(ul.style.cssText=="" || ul.style.display=="none"){
			ul.style.cssText="display:block";
			ob.className="open";
		}
		else{
			ul.style.cssText="display:none";
			ob.className="";
		}
		return false;
	}
}
