// JavaScript Document

function getCookie(NameOfCookie)
{
        if (document.cookie.length > 0) {
                var begin = document.cookie.indexOf(NameOfCookie+"=");
                if (begin != -1) {
                        begin += NameOfCookie.length+1;
                        end = document.cookie.indexOf(";", begin);
                        if (end == -1) end = document.cookie.length;
                        return unescape(document.cookie.substring(begin, end));
                }
        }
        return null;
}

function setCookie(NameOfCookie, value, expiredays)
{
        var ExpireDate = new Date();
        if (expiredays == null) expiredays = 365; // keep the settings for a year
        ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
        document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) +
                "; path=/";
}

function delCookie(NameOfCookie)
{
        if (getCookie(NameOfCookie)) {
                document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +
                "; path=/";
        }
}



var currentFontSize = getCookie('fontSize');
if (currentFontSize == null) currentFontSize = 11;

function changeFontSize(sizeDifference) {
    currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference);

    if (currentFontSize > 16) {
        currentFontSize = 16;
    } else if(currentFontSize < 8) {
        currentFontSize = 8;
    }
    setFontSize(currentFontSize);
    setCookie('fontSize', currentFontSize, null);
    return false;
};

function setFontSize(fontSize) {
    var stObj = (document.getElementById) ? document.getElementById('LINKS') : document.all('LINKS');
    /* subnavi deaktiviert
    stObj = stObj.firstChild;
    var sentry = 15;
    while (stObj.className != 'subnavi' && sentry) { stObj = stObj.nextSibling; sentry--; }
    if (stObj.className == 'subnavi') stObj.style.fontSize = fontSize + 'px';
    for (sentry = 0; sentry < stObj.childNodes.length; sentry++)
    	stObj.childNodes[sentry].style.fontSize = fontSize + 'px';
    */
    stObj = (document.getElementById) ? document.getElementById('main') : document.all('main');
	 

    if (stObj) {
    	stObj.style.fontSize = fontSize + 'px';
    } else {
    	stObj = (document.getElementById) ? document.getElementById('Links') : document.all('Links');
	stObj.style.fontSize = fontSize + 'px';
    	stObj = (document.getElementById) ? document.getElementById('Center') : document.all('Center');
	stObj.style.fontSize = fontSize + 'px';
    }
};

window.onload = function() { setFontSize(currentFontSize); }
