window.onload = function() {
    external();
    currentPage();

    if (isMSIE()) {
        doc("CounterLine").setAttribute("ondblclick", new Function("showCounter()"));
    } else {
        doc("CounterLine").setAttribute("ondblclick", "showCounter()");
    }

}

function isMSIE() {
    if (window.opera) {
        return false;
    } else if (document.all) {
        return true;
    } else {
        return false;
    }
}

function doc(ID) {
    if (isMSIE()) {
        return document.all(ID);
    } else {
        return document.getElementById(ID);
    }
}

function external() {
    if (!document.getElementsByTagName) {
        return false;
    }
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.href) {
            if (anchor.getAttribute("class") == "external" || anchor.getAttribute("className") == "external") {
                anchor.target = "_blank";
            }
        }
    }
}

function currentPage() {
    if (!document.getElementsByTagName) {
        return false;
    }
    var Sidebar = document.getElementById("Sidebar");
    var anchors = Sidebar.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (document.URL == anchor.href && anchor.getElementsByTagName("img").length == 0) {
            anchor.removeAttribute("href");
            anchor.style.color = "#FF0000";
            anchor.style.textDecoration = "none";
        }
    }
}

function showCounter() {
    doc("Counter").style.visibility = "visible";
}