styleswitch=new function()
{
	this.set=function(title)
	{
		var i, a, main;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))
			{
				a.disabled = true;
				
				if(a.getAttribute("title") == title)
					a.disabled = false;
			}
		}
		
		var r=new request_object('index.php?act=site_styleswitch_setcookie&title='+encodeURIComponent(title), this.setcookie, true);
		
		this.setcookie=function()
		{
			//alert('ok');
		}
	}
	
	this.get=function()
	{
		var i, a;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled)
				return a.getAttribute("title");
		}
		return null;
	}
	
	this.getpreferred=function()
	{
		var i, a;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
		{
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title") )
				return a.getAttribute("title");
		}
		return null;
	}
	
	this.load=function(e)
	{
		var cookie = cookies.get("style");
		var title = cookie ? cookie : styleswitch.getpreferred();
		styleswitch.set(title);
	}
	
	this.unload=function(e)
	{
		var title = styleswitch.get();
		cookies.set("style", title, 365);
	}
}
