// JavaScript Document


function initCookie()
{
	if(navigator.cookieEnabled)
	{
			//alert("Cookie enabled");	
		if(document.cookie)
			{
				if(readStyle())
				{
				var elm = readStyle().toString();
				switchInit(elm, readStyle());
				
				}else
				{
					switchInit("default", "default");
				}
					//alert("Cookie is = " + elm);	
			}
	}else{
		//alert("Please enable cookies");	
	}
}

function switchInit(element,title)
{
	var i;
	
	var elm = document.getElementById(element);

	 var theLinks = document.getElementsByTagName("link");
   for(i=0; i < theLinks.length; i++) {
     if(theLinks[i].getAttribute("rel").indexOf("style") != -1 && theLinks[i].getAttribute("title")) {
       theLinks[i].disabled = true;
	   resetLink();
	  
       if(theLinks[i].getAttribute("title") == title) theLinks[i].disabled = false;
     }
	  
   }
  // elm.style.textDecoration = 'none';
 elm.style.backgroundPosition="0px -18px";
}

function switchStyle(element,title) {

				setStyle (title);
			
	var i;
	
	

	 var theLinks = document.getElementsByTagName("link");
   for(i=0; i < theLinks.length; i++) {
     if(theLinks[i].getAttribute("rel").indexOf("style") != -1 && theLinks[i].getAttribute("title")) {
       theLinks[i].disabled = true;
	   resetLink();
	  
       if(theLinks[i].getAttribute("title") == title) theLinks[i].disabled = false;
     }
	  
   }
 // element.style.textDecoration = 'none';
 element.style.backgroundPosition="0px -18px";

}

function resetLink()
{
	var i;
	var selectors = document.getElementById("options");
	var selector = selectors.getElementsByTagName("a");
	for(i=0; i < selector.length; i++)
	{
		//selector[i].style.textDecoration = 'underline';
		selector[i].style.backgroundPosition="0px 0px";
	}
	
	
}

function setStyle (newstyle){
  
var expdate = new Date();
  
expdate.setTime(expdate.getTime() 
  
	+ (1000*3600*24*365));
  
document.cookie = 'style=' + newstyle + '; expires=' 
  
	+ expdate.toGMTString() + '; path=/';
  

  
//self.location = self.location;
  
}

function readStyle()
{
	var cookie = document.cookie;
	var first = cookie.indexOf("style=");
	
	if(first >= 0)
	{
		var str = cookie.substring(first, cookie.length);
		var last = str.indexOf(";");
		
		if(last < 0) last = str.length;
		
		str = str.substring(0, last).split("=");
		return unescape(str[1]);
		
		
	}else{
	
	return null;
	}
	
}

window.onload = function()
{
initCookie();
//alert("Window load");
}