﻿  
  
 
function  getcookie()

{ 
var cookstring = new String(document.cookie);
var cookname = 'Cookiea=';

/*looks in the browsers cookies(document.cookie) for the one named Cookiea= and gets its index position*/
var startpos = cookstring.indexOf(cookname);

endc = cookstring.indexOf(';', startpos + cookname.length);


if(startpos!=-1)//if the cookie with this name was not founf startpos will be equal to -1
{
return cookstring.substring(startpos + cookname.length);

}
else 
{
	
return  "default";
}
}


var addr;

function setcookie(choce)
{

var cookdate = new Date();

//sets the cookies expire date to half an hour after the cookie has been downloaded
cookdate.setTime(cookdate.getTime() + 1000*60*30);
var cookname = 'Cookiea='+ choce +';' ; 
//writes the cookie with name(Cookiea)=value(My A Cookie.) and sets the expiry date
document.cookie = cookname+ 'expires=' +cookdate.toGMTString();

}

var shortcut = new String(document.location);

var loc = shortcut.split("/");

function addrChange()
{
addr ='';
addr = 'styles\/';

if(loc.length >4)
{
	var i;
	var max = loc.length - 4;
	for(i=0 ; i < max ; i++)
	{
		addr = '../' +addr;
	}
}
}



var sIndex;
function change(sIndex)
{



if(sIndex == 1)
	{
		setcookie('default');
	}
if(sIndex == 2)
	{
		setcookie('blue');
	}
if(sIndex == 3)
	{
		setcookie('green');
	}
if(sIndex == 4)
	{
		setcookie('teal');
	}
}

mycss = '';
mycss =  getcookie();
mycss = mycss.split(';');


mycss = mycss[0];

if(mycss == 'default')
	{
		addrChange();
		addr = addr + 'default.css';
	}
if(mycss == 'blue')
	{
		addrChange();
		addr = addr + 'blue.css';
		
	}
if(mycss == 'green')
	{
		addrChange();
		addr = addr + 'green.css';
		
	}
if(mycss == 'teal')
	{
		addrChange();
		addr = addr + 'teal.css';
		
	}



document.writeln("<link type=\"text/css\" rel=\"stylesheet\" href=" + addr + ">");		



