var title = document.title;
var num = "";
var lnum = "";
function fixtitle() {
    if (num.length) {
        if (title.length + num.length + 11 <= 95) {
            document.title = title + " [search: " + num + "]";
        } else {
            document.title = "[search: " + num + "] " + title;
        }
    } else {
        document.title = title;
    }
}
function getInnerText(o) {
    var s = "";
    var oo = o;
    while (true) {
        if (o.nodeType == 3) {
            var t = o.nodeValue.replace(/[\xa0\s]+/g, " ");
            if (t.match(/^ /) && s.match(/\s$/)) {
                s += t.substring(1);
            } else {
                s += t;
            }
        } else if (o.nodeType == 1) {
            var t = o.nodeName.toLowerCase();
            if (t == "br" || t == "p") {
                s = s.replace(/ $/, "") + " ";
            }
        }
        if (o.hasChildNodes()) {
            o = o.childNodes.item(0);
        } else if (o.nextSibling) {
            o = o.nextSibling;
        } else if (o == oo) {
            break;
        } else {
            while (true) {
                o = o.parentNode;
                if (!o || o == oo) {
                    break;
                }
                if (o.nextSibling) {
                    o = o.nextSibling;
                    break;
                }
            }
            if (!o || o == oo) {
                break;
            }
        }
    }
    return s.replace(/^[^ -~] /, "");
}
function hot(c) {
    if (c == "/") {
        var a = document.getElementsByTagName("A");
        var t = a.item(a.length - 1).href;
        location = t == "http://www.toucanet.com/" ? "/menu.html" : t;
    } else {
        return true;
    }
    return false;
}
function k(e) {
    var key;
    if (document.all) {
        key = event.keyCode;
    } else {
        key = e.which;
        if (e.altKey || e.ctrlKey) {
            return true;
        }
    }
    var rv = true;
    var a = document.getElementsByTagName("A");
    var x = String.fromCharCode(key).toLowerCase();
    if (!hot(x)) {
        return false;
    }
    if (key == 8 && lnum.length > 0) {
        lnum = lnum.substring(0, lnum.length - 1);
    } else {
        lnum += x;
    }
    var z1 = -1, z2 = -1, z3 = -1;
    for (var i = a.length - 1; i >= 0; --i) {
        if (!a.item(i).myInnerText) {
            a.item(i).myInnerText = getInnerText(a.item(i));
        }
        var s = a.item(i).myInnerText.toLowerCase();
        if (lnum == s.substring(0, lnum.length)) {
            if (lnum.length == s.length) {
                z1 = i;
            }
            z2 = i;
        }
        if (x == s.charAt(0)) {
            z3 = i;
        }
    }
    if (z1 >= 0) {
        z3 = z1;
    } else if (z2 >= 0) {
        z3 = z2;
    } else if (z3 >= 0) {
        lnum = x;
    } else {
        lnum = "";
    }
    num = "";
    if (z3 >= 0) {
        a.item(z3).focus();
        num = a.item(z3).myInnerText.substring(0, lnum.length);
        rv = false;
    }
    fixtitle();
    return rv;
}
function f() {
    var a = document.getElementsByTagName("A");
    for (var i = a.length - 1; i >= 0; --i) {
        a.item(i).style.color = "blue";
        if (!a.item(i).myInnerText) {
            a.item(i).myInnerText = getInnerText(a.item(i));
        }
        if (document.location.href.indexOf("/archives/p/") >= 0 &&
            a.item(i).title == "" &&
            a.item(i).myInnerText.length > 32) {
            a.item(i).title = a.item(i).innerHTML;
            var z = a.item(i).myInnerText.lastIndexOf(" ", 32);
            var s = a.item(i).myInnerText.substring(0, z >= 0 ? z + 1 : 32) +
                "...";
            var t = "";
            for (var j = 0; j < s.length; ++j) {
                t += "&#" + s.charCodeAt(j) + ";";
            }
            a.item(i).innerHTML = t;
        }
    }
    if (document.getElementById("hide")) {
        document.getElementById("hide").style.display = "none";
    }
    if (document.getElementById("links")) {
        document.getElementById("links").style.display = "none";
    }
    document.title = title;
}
function g() {
    var a = document.getElementsByTagName("A");
    for (var i = a.length - 1; i >= 0; --i) {
        a.item(i).style.color = "";
        if (a.item(i).title != "" &&
            a.item(i).innerText.lastIndexOf("...") >= 0) {
            a.item(i).innerHTML = a.item(i).title;
            a.item(i).title = "";
        }
    }
    if (document.getElementById("hide")) {
        document.getElementById("hide").style.display = "block";
    }
    if (document.getElementById("links")) {
        document.getElementById("links").style.display = "block";
    }
    fixtitle();
}
function h() {
    var a = document.getElementsByTagName("IMG");
    for (var i = a.length - 1; i >= 0; --i) {
        a.item(i).style.display = "none";
    }
    a = document.getElementById("img").getElementsByTagName("A").item(0);
    a.href = "javascript:s()";
    a.innerHTML = "<SMALL>&radic;</SMALL> Show images";
    a.myInnerText = "";
}
function s() {
    var a = document.getElementsByTagName("IMG");
    for (var i = a.length - 1; i >= 0; --i) {
        a.item(i).style.display = "inline";
        if (!a.item(i).complete) {
            a.item(i).outerHTML = a.item(i).outerHTML;
        }
    }
    a = document.getElementById("img").getElementsByTagName("A").item(0);
    a.href = "javascript:h()";
    a.innerHTML = "&times; Hide images";
    a.myInnerText = "";
}
if (document.all) {
    window.onbeforeprint = f;
    window.onafterprint = g;
}
document.onkeypress = k;
