﻿function getWholeCookie(beginVar) {
	var endVar = document.cookie.indexOf (';', beginVar)
	if (endVar ==-1) {
		endVar = document.cookie.length;
	}
	return unescape(document.cookie.substring(beginVar,endVar));
}

function getCookie(name) {
	var argVar = name + '=';
	var argLength = argVar.length;
	var cookieLength = document.cookie.length;
	var i = 0;
	while (i < cookieLength) {
		var j = i + argLength;
		if (document.cookie.substring(i,j) == argVar) {
			return getWholeCookie(j);
		}
		i = document.cookie.indexOf(' ',i) + 1;
		if (i ==0) break;
	}
	return '';
}

function setCookie(name,value) {
	document.cookie = name + '=' + escape(value);
}


function getDataCookie(cookieName) {
	var data = '';
	if (navigator.cookieEnabled) data = getCookie(cookieName);
	if (data == '') data = 'styleDefault';
	return data;
}

function changeStyle(newStyle) {
	if (navigator.cookieEnabled) {
		setCookie('styleName',newStyle);
		location.href = self.location;
	}
	else alert('You need a Cookie enabled browser to use the style change capability. Please either turn on cookies or update your browser.');
}



