
/*

    DO NOT CHANGE

*/
/* globals */
var isDOMCapable = false;

/* DOM methods and collections used in the script */
if (document.getElementsByTagName && document.getElementById
    && document.createElement && document.createTextNode
    && document.appendChild) {
    isDOMCapable = true;
}

function addEvent(obj, evType, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on" + evType, fn);
        return r;
    } else {
        return false;
    }
}

/* Function to fix IE's Bug showing active links and remove rectangle around links */
function init(id, src, text, introtxt) {
    if (document.getElementsByTagName) {
        var anchors = document.getElementsByTagName("a");
        for (var i = 0; i < anchors.length; i++) {
            var myAnchor = anchors[i];
            if (!myAnchor.onclick) {
                myAnchor.onclick = function () {
                    if (document.all) { // only for IE
                        this.blur();
                    }
                    if (this.href.indexOf("404.html") != -1) { // do not follow dead links
                        this.blur();
                        return false;
                    } else if (isIntranet && window.location.hostname != this.hostname) { // assume that this is an external link
                        makeNewWindow(this);
			   return false;
                    }
                    //return true;
                }
            }
        }
    }
    renderPrintLink(id, src, text, introtxt);
    initActiveSelection();
}

function printPage() {

    var isIE = (navigator.appName == "Microsoft Internet Explorer") ? true: false;
    var platform = navigator.platform;
    var isMac = (platform.match(/mac/i)) ? true : false;
    var isMacIE = isIE && isMac;
    var isSafari = navigator.userAgent.indexOf("Safari") != -1;
    
    if (window.print && !isMacIE && !isSafari) {
        window.print();
    } else if (document.getElementsByTagName) {
        var a;
        for(var i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
            if (a.getAttribute("rel").indexOf("style") != -1) {
                a.disabled = true;
                if (a.getAttribute("rel").indexOf("alt") != -1 && a.getAttribute("title") == "Druckansicht") {
                    a.disabled = false;
                }
            }
        }
    } else {
        alert("Diese Funktion wird von Ihrem Browser nicht unterst&uuml;tzt.\nBitte benutzen Sie die Druckfunktion Ihres Browsers.");
    }

}

if (!document.getElementById) {
    document.getElementById = function() { return null; }
}

function renderPrintLink(id, src, text, introtxt) {
    var node = document.getElementById(id);
    if (isDOMCapable && node) {
        if (introtxt && introtxt != "") {
            introtxt += " ";
            node.appendChild(document.createTextNode(introtxt));
        }
        var img = document.createElement("img");
        img.setAttribute("src", src);
        img.setAttribute("alt", text);
        node.appendChild(img);
        var a = document.createElement("a");
        a.href = "javascript:printPage();";
        a.style.color = "#2b477f"; // Required by IE/Win
        a.appendChild(document.createTextNode(text));
        node.appendChild(a);
        var span = document.createElement("span");
        span.className = "white";
        span.appendChild(document.createTextNode(" |"));
        node.appendChild(span);
        
    }
}


// attach event
var yetSelected = false;
function initActiveSelection() {
    var activeSelectEl = document.getElementById("bland-active");
    if (activeSelectEl) {
        addEvent(activeSelectEl, "change", appendSelectionOrt);
    }
}


// Global variable for subwindow reference
var newWindow;
// Generate and fill the new window
function makeNewWindow(obj) {
    newWindow = window.open("", "sub", "status,resizable,height=200,width=400");
    // handle Navigator 2, which doesn't have an opener property
    if (!newWindow.opener) {
        newWindow.opener = window;
    }
    // delay writing until window exists in IE/Windows
    setTimeout("writeToWindow('" + obj + "')", 500);
    newWindow.focus();
}



