//-- Global functions ---------------------------

/**
 * Gets the element with the given ID from the current document. The element is
 * retrieved for different types of browsers.
 *
 * @param id    the ID of the desired element
 * @return      the object representing the element; @c null if an error
 *              occurred
 */
function getElem(id) {
    if (document.getElementById) {
        return document.getElementById(id);
    } else if (document.all) {
        return document.all[id];
    } else {
        return null;
    }
}

/**
 * Restores the font size of the document by reading a value from a cookie.
 */
function restoreFontSize() {
    var size = 3;
    var pos = document.cookie.indexOf("fontSize=");
    if (pos != -1) {
        var end = document.cookie.indexOf(";", pos + 9);
        if (end == -1) end = document.cookie.length;
        size = parseInt(document.cookie.substring(pos + 9, end));
    }
    setFontSize(size);
}

/**
 * Changes the font size in the current document and stores the value for later
 * usage in a cookie.
 *
 * @param[in] size  [int] a value between 1 and 5 indicating the relative font
 *                  size
 */
function setFontSize(size) {
    $("div#font-size-sel li.current").removeClass("current");
    $("body").css("font-size", (11 + size) + "px");
    $("div#font-size-sel li#size-" + size).addClass("current");
    document.cookie = "fontSize=" + size + "; path=/; max-age=" +
        (60 * 60 * 24 * 30);
}


//-- Global code --------------------------------

$(document).ready(function() {
    restoreFontSize();
});

// kate: indent-mode normal; indent-width 4;
