function SetCookie(name,value) {
	var theCookie = name + "=";
	theCookie = theCookie + escape(value);
	document.cookie = theCookie;
}

function GetCookieVal(offset) {
	var endstr = document.cookie.indexOf (";",offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset,endstr));
}

function GetACookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while(i < clen)
	{
	var j = i + alen;
		if (document.cookie.substring(i,j) == arg)
		{
		 return GetCookieVal(j);
		}
	i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) break;
		}
	return null;
}

function ChangeStyleSheet(sStyleSheet,sPath) {	
	var sDirPath;
	
	if (sPath == null) {
		sDirPath = "";
	} else {
		sDirPath = sPath
	}		
	
	SetCookie('css-font-size',sStyleSheet);
	sStyleSheet = 'MasterPages/scripts/' + sStyleSheet + '.css';
	sStyleSheet = sDirPath + sStyleSheet;
	
	document.getElementById('ctl00_cssHolder').setAttribute('href',sStyleSheet);	
}

function SetCurrentStyleSheet(sPath) {	
	var sStyleSheet;	
	(document.cookie.indexOf("css-font-size")!=-1)?cookieEnabled=true:cookieEnabled=false;
	
	//default
	sStyleSheet = 'accessibility';
	
	if (cookieEnabled) {
		sStyleSheet = GetACookie('css-font-size');
	}
	ChangeStyleSheet(sStyleSheet,sPath);
}
