// Text sizes
var numDefaultFontSize = 80; /* No percent sign */
var numMinimumFontSize = 60; /* No percent sign */

function setFontSize (strFontSize){
  if (strFontSize) {
    document.body.style.fontSize = strFontSize;
    setCookie ('fontSize', strFontSize);
  }
}
function changeFontSize (numDifference){
  var strFontSize = document.body.style.fontSize;
  if (strFontSize == "") strFontSize = numDefaultFontSize + "%";
  if (numDifference) {
    strFontSize = strFontSize.substring(0, strFontSize.length-1);
    strFontSize = (strFontSize * 1) + (numDifference * 1);
    if (strFontSize * 1 < numMinimumFontSize * 1) strFontSize = numMinimumFontSize;
    strFontSize = strFontSize + '%';
  }
  setFontSize (strFontSize);
}

// Themes
function changeTheme (strTheme){
  document.body.className = strTheme;
  setCookie ('theme', strTheme);
}

// Status
function setStatus (strMessage){
  window.status = strMessage;
}

// Initialisation
function setStyles () {
  changeTheme(getCookie('theme'));
  setFontSize(getCookie('fontSize'));
}
function writeAccessibilityLinks() {
  document.write('<a href="#" onmouseover="setStatus(\'Text smaller\'); return true;" onmouseout="setStatus(\'\'); return true;" onclick="changeFontSize(-10); return false;">Text smaller</a> | ');
  document.write('<a href="#" onmouseover="setStatus(\'Text standard\'); return true;" onmouseout="setStatus(\'\'); return true;" onclick="setFontSize(numDefaultFontSize + \'%\'); return false;">Text standard</a> | ');
  document.write('<a href="#" onmouseover="setStatus(\'Text larger\'); return true;" onmouseout="setStatus(\'\'); return true;" onclick="changeFontSize(10); return false;">Text larger</a>');
}

// Cookies
function setCookie (strName, strValue, numExpires, strPath, strDomain, strSecure)  {
  var objExpiryDate;
  if (numExpires) {
    var objToday = new Date();
    objToday.setTime(objToday.getTime());
    numExpires = numExpires * 1000 * 60 * 60 * 24;
    var objExpiryDate = new Date(objToday.getTime() + numExpires);
  }
  document.cookie = strName     + "=" + escape(strValue) +
    (numExpires ? ";expires=" + objExpiryDate.toGMTString() : "" ) + 
    (strPath    ? ";path="    + path                        : "" ) + 
    (strDomain  ? ";domain="  + domain                      : "" ) +
    (strSecure  ? ";secure"                                 : "" );
}
function getCookie (strParameter) {
	var arrAllCookies = document.cookie.split( ';' );
	var arrTempCookie = '';
	var strCookieName = '';
	var strCookieValue = '';
	var blnCookieFound = false;
	for (i = 0; i < arrAllCookies.length; i++) {
		arrTempCookie = arrAllCookies[i].split( '=' );
		strCookieName = arrTempCookie[0].replace(/^\s+|\s+$/g, '');
		if (strCookieName == strParameter) {
			blnCookieF = true;
			if (arrTempCookie.length > 1) {
				strCookieValue = unescape(arrTempCookie[1].replace(/^\s+|\s+$/g,''));
			}
			return strCookieValue;
			break;
		}
		arrTempCookie = null;
		strCookieName = '';
	}
	if (!blnCookieFound) {
		return null;
	}
}	


