function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
		return unescape(aCrumb[1]);
	}

	return null;
}

function SetCookie(sName, sValue)
{
	var expires = new Date();
	expires.setTime(expires.getTime() + 3E11);   // about 10 years
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + expires.toGMTString() + "; path=/";
}

var size = GetCookie("size");
size = size == null ? 1.0 : parseFloat(size);

var hi = GetCookie("hi");
hi = hi == null ? 0 : parseInt(hi);


function ChangeSize(sizeChange) {
    size += sizeChange;
    
    size = Math.min(size, 1.6);
    size = Math.max(size, 1.0);
    
    //window.alert(size);
    
    document.body.style.fontSize = size + "em";
    SetCookie("size", size);
}

function ToggleHi() {
    hi = hi == 1 ? 0 : 1;
    ChangeOverride(hi == 0 ? "" : "/wp-content/plugins/visibility/visibility.css");    SetCookie("hi", hi);
}

function ChangeOverride(styleUrl) {
    document.getElementById("override").href = styleUrl;
}
