/*-----------------------------------------------------*/
/*                                                     */
/* open links in a new window, if they have the        */
/* attribute rel="external_link"                       */
/*                                                     */
/* used to avoid the attribute target"_blank"          */
/* within xhtml strict                                 */
/*                                                     */
/*-----------------------------------------------------*/

function open_external_link() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") &&
            anchor.getAttribute("rel") == "external_link")
        anchor.target = "_blank";
    }
}





/*-----------------------------------------------------*/
/*                                                     */
/* write a value into the search box                   */
/* change the color of the fonts in the search box     */
/*                                                     */
/*-----------------------------------------------------*/

function search_box_text(FeldText,Color) {
    if(document.getElementById) {
        document.getElementById("search_query").value = FeldText;
        document.getElementById("search_query").style.color = Color;
        document.getElementById("search_submit_button").value = "go";
    }
}






function set_cookie(name,value) {
    expire_date = new Date();
    in_one_year = expire_date.getTime() + (365 * 24 * 60 * 60 * 1000);
    expire_date.setTime(in_one_year);
    document.cookie = name + "=" + value + "; expires=" + expire_date.toGMTString() + ";path=/;";
}

function read_cookie_value(cookie_name) {
    if(document.cookie.match(cookie_name)) {
        cookie_name_length = cookie_name.length;
        var cookie_position = document.cookie.indexOf(cookie_name);
        var start_value_reading = cookie_position + cookie_name_length + 1;
        var interim_value = document.cookie.substr(start_value_reading);
        var position_next_separator = interim_value.indexOf(";");

        if(position_next_separator != "-1") {
            var stop_value_reading = position_next_separator;
            var cookie_value = document.cookie.substr(start_value_reading,stop_value_reading);
        } else {
            var cookie_value = document.cookie.substr(start_value_reading);
        }
        return cookie_value;
    }
}
 


function change_body_font(span) {
    font_size = span.substr(5,7);
    new_font_size = font_size.replace("_",".");
    set_cookie("accessibility_font_size",new_font_size);
    location.reload();
}

function show_font_switcher() {
    document.write("<div id=\"font_switcher\">");
    document.write("<ul>");
    document.write("<li><dfn>1:<\/dfn><a href=\"javascript:history.go(0)\" id=\"font_0_8\" onclick=\"change_body_font(this.id);\" onkeypress=\"this.onclick\" title=\"kleine Schriftgr&ouml;&szlig;e\"><span class=\"switcher-bold-small\">A<\/span>kleiner<\/a><\/li>");
    document.write("<li><dfn>2:<\/dfn><a href=\"javascript:history.go(0)\" id=\"font_1_0\" onclick=\"change_body_font(this.id);\" onkeypress=\"this.onclick\" title=\"standard Schriftgr&ouml;&szlig;e\"><span class=\"switcher-bold\">A<\/span>standard<\/a><\/li>");
    document.write("<li><dfn>3:<\/dfn><a href=\"javascript:history.go(0)\" id=\"font_1_2\" onclick=\"change_body_font(this.id);\" onkeypress=\"this.onclick\" title=\"gro&szlig;e Schriftgr&ouml;&szlig;e\"><span class=\"switcher-bold-big\">A<\/span>gr&ouml;&szlig;er<\/a><\/li>");
    document.write("<\/ul>");
    document.write("<div class=\"cleaner\">\&nbsp\;<\/div>");
    document.write("<\/div>");
}

function apply_accessibility_font() {
    cookie_value = read_cookie_value("accessibility_font_size");
    document.getElementById("header").style.fontSize = cookie_value + "em";
    document.getElementById("left").style.fontSize = cookie_value + "em";
    document.getElementById("middle").style.fontSize = cookie_value + "em";
    document.getElementById("right").style.fontSize = cookie_value + "em";
}