
var fontSize = 10;
var act = document.getElementById("normal");
var cookieBezeichner = "BodyFontSize";
var largerFont = '12';
var largeFont = '11';
var normalFont = '10';

function largerFontSize(){
    setFontSize(largerFont);
    if (act && act.firstChild) {
        act.firstChild.style.textDecoration = "none";
    }
    act = document.getElementById("larger");
    if (act && act.firstChild) {
        act.firstChild.style.textDecoration = "underline";
    }
}

function largeFontSize() {
    setFontSize(largeFont);
    if (act && act.firstChild) {
        act.firstChild.style.textDecoration = "none";
    }
    act = document.getElementById("large");
    if (act && act.firstChild) {
        act.firstChild.style.textDecoration = "underline";
    }
}

function normalizeFontSize() {
    setFontSize(normalFont);
    if (act && act.firstChild) {
        act.firstChild.style.textDecoration = "none";
    }
    act = document.getElementById("normal");
    if (act && act.firstChild) {
        act.firstChild.style.textDecoration = "underline";
    }
}

function setFontSize(sze) {
    fontSize = sze;
    document.getElementsByTagName("body")[0].style.fontSize = fontSize + "pt";
    setCookie(cookieBezeichner, sze);
}

function resetStyle() {
    /*Style in der Fusszeile auf allen Schriftgrössen zurücksetzen*/
    act = document.getElementById("normal");
    if (act && act.firstChild) { act.firstChild.style.textDecoration = "none"; }
    act = document.getElementById("large");
    if (act && act.firstChild) { act.firstChild.style.textDecoration = "none"; }
    act = document.getElementById("larger");
    if (act && act.firstChild) { act.firstChild.style.textDecoration = "none"; }
}

function setCookie(Bezeichner, Wert) {
    //Dauer: in Tagen --> 86400000ms = 24h
    Milisekunden = 86400000;
    Dauer = 30; 
    jetzt = new Date();
    endDate = new Date(jetzt.getTime() + Dauer * Milisekunden);
    document.cookie = Bezeichner + "=" + Wert + ";expires=" + endDate.toGMTString() + ";path=/";
}

function initFontSize() {
    resetStyle();
    fontSize = ReadCookie(cookieBezeichner);
    switch (fontSize)
    {
        case largerFont:
            largerFontSize();
            break;
        case largeFont:
            largeFontSize()
            break;
        default:
            normalizeFontSize();
    }
}


function ReadCookie(Bezeichner) {
    res = '';
    if (document.cookie) {
        a = document.cookie;
        while(a != '') {
            while(a.substr(0, 1) == ' ') {
                a = a.substr(1, a.length);
            }
            cookiename = a.substring(0, a.indexOf('='));
            if (a.indexOf(';') != -1) {
                cookiewert = a.substring(a.indexOf('=') + 1, a.indexOf(';'));
            }
            else {
                cookiewert = a.substr(a.indexOf('=') + 1, a.length);
            }
            if (Bezeichner == cookiename) {
                res = cookiewert;
            }
            i = a.indexOf(';') + 1;
            if (i == 0) {
                i = a.length
            }
            a = a.substring(i, a.length);
        }
    }
    return (res)
}
