﻿//Check for browser type.
function Is() {   // convert all characters to lowercase to simplify testing
    var agt = navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
    this.agt = agt;

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    this.nav = ((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1)
                && (agt.indexOf('webtv') == -1) && (agt.indexOf('hotjava') == -1));
    this.nav2 = (this.nav && (this.major == 2));
    this.nav3 = (this.nav && (this.major == 3));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)));
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);
    this.safari = (agt.indexOf('safari') != -1);

    this.ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3 = (this.ie && (this.major < 4));
    this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 4") != -1));
    this.ie4up = (this.ie && (this.major >= 4));
    this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0") != -1));
    this.ie5_5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") != -1));
    this.ie5up = (this.ie && !this.ie3 && !this.ie4);
    this.ie5_5up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6 = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.") != -1));
    this.ie6up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
    this.ie7 = (this.ie && (this.major == 4) && (agt.indexOf("msie 7.") != -1));
    this.ie7up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5 && !this.ie6);

}

var browser;
browser = new Is();



/* Rollover Menu */
function SimpleSwap(el, which) {
    el.src = el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup() {
    var x = document.getElementsByTagName("img");
    for (var i = 0; i < x.length; i++) {
        var osrc = x[i].getAttribute("osrc");
        if (!osrc) continue;

        // preload image
        // comment the next two lines to disable image pre-loading
        x[i].osrc_img = new Image();
        x[i].osrc_img.src = osrc;
        // set event handlers
        x[i].onmouseover = new Function("SimpleSwap(this,'osrc');");
        x[i].onmouseout = new Function("SimpleSwap(this);");
        // save original src
        x[i].setAttribute("origsrc", x[i].src);
    }
}

/* Collapse Menu */
function toggleMenu(objID) {
    if (!document.getElementById) return;
    var ob = document.getElementById(objID).style;
    ob.display = (ob.display == 'block') ? 'none' : 'block';
}


function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}


var PreSimpleSwapOnload = (window.onload) ? window.onload : function() { };
window.onload = function() { PreSimpleSwapOnload(); SimpleSwapSetup(); }
addLoadEvent(function() { addLoadEvent(leftMenu.activate(true)); })


