var skin={};

skin.addEvent=function(){
	var skins =document.getElementById("skin").getElementsByTagName("li");
	for (i=0;i<skins.length;i++)
	{
		skins[i].onclick=function(){skin.setSkin(this.id.substring(5))};
	}
}

skin.setCookie=function(n){
	var expires=new Date();
	expires.setTime(expires.getTime()+10*24*3600*1000);
	document.cookie="asd="+n+";expires="+expires.toGMTString()+";path=/";
}

skin.readCookie=function(){
	var skin=0
	var mycookie=document.cookie;
	var start1=mycookie.indexOf("asd=");
	if(start1==-1){
		skin=0;
	}
	else{
		var start=mycookie.indexOf("=",start1)+1;
		var end=start+1
//		if(end=-1){
//			end=mycookie.length;
//		}
		var values= unescape(mycookie.substring(start,end));
		if (values!=null)
		{
			skin=values;
		}
	}
	return skin;
	
}

skin.setSkin=function(n){
	var skins =document.getElementById("skin").getElementsByTagName("li");
	for (i=0;i<skins.length;i++)
	{
		skins[i].className="";
	}
	//alert(n);
	skin.setCookie(n);
	document.getElementById("skin_"+n).className="selected";
	//document.getElementById("menu096b").style.display="";
	document.getElementById("cssfile").href="/skins/skin"+n+"/style.css";
	
}

window.onload=function(){
	skin.setSkin(skin.readCookie());
	skin.addEvent();
}

document.write("<link href='/skins/skin"+skin.readCookie()+"/style.css' rel='stylesheet' type='text/css' id='cssfile' />")
