﻿// Nav functions for MCC site -- 12/12/02 Casey Corcoran @ CDI
// Set up vars
var navArray, subPageArray, previousObj, previousID, selectedID;
// URL string passed paramter
if (location.search.substring(1) == "") {
    selectedID = 0;
} else {
    selectedID = parseFloat(location.search.substring(1));
}
// Sub page name array
subPageArray = [
"about/04_01_00_Index.aspx",
"about/04_01_01_OrgChart.aspx",
"about/04_01_02_Funding.aspx",
"about/04_01_03_Environment.aspx",
"about/04_01_04_Facilities.aspx"
];
// Initalize Array containing nav info
navArray = new Array();
// Class definition
function navImage(id, up, down) {
    this.id = id;
    this.up = up;
    this.down = down;
}
// Add a new navImage object to navArray
function addNavImage(id, up, down) {
    var tmpObj = new navImage(id, up, down);
    navArray[navArray.length] = tmpObj;
}
// Turn previously selected navImage off and turn current on
function navToggle(selectedObj, id) {
    if (id != previousID) { // Same button twice clicked check
        if (previousObj && previousObj != id) previousObj.src = navArray[previousID].up; // Restore previous navImage to "up" state
        selectedObj.src = navArray[id].down; // Swap current navImage
        if (navigator.appName == "Microsoft Internet Explorer") selectedObj.blur(); // IE focusRect fix - Will break function in Mozilla w/out check
        // Reference selected IMG Object
        previousObj = selectedObj;
        previousID = id;
    }

}
// Add navImage objects here
addNavImage("navImage_1", "images/04_About/00_nav_01.gif", "images/04_About/00_nav_01_down.gif");
addNavImage("navImage_2", "images/04_About/00_nav_02.gif", "images/04_About/00_nav_02_down.gif");
addNavImage("navImage_3", "images/04_About/00_nav_03.gif", "images/04_About/00_nav_03_down.gif");
addNavImage("navImage_4", "images/04_About/00_nav_04.gif", "images/04_About/00_nav_04_down.gif");
//
function initialSwap() {
    sf = MM_findObj('scrollFrame');
    sf.src = subPageArray[selectedID];
    window.frames["scrollFrame"].window.location = subPageArray[selectedID];

    var swapImg = MM_findObj('navImage_' + selectedID);
    if (swapImg) {
        navToggle(swapImg, selectedID - 1);
    }
}

function GP_AdvOpenWindow(theURL, winName, features, popWidth, popHeight, winAlign, ignorelink, alwaysOnTop, autoCloseTime, borderless) { //v2.0
    var leftPos = 0, topPos = 0, autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;
    if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
    if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
    if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
        if (document.all || document.layers || document.getElementById) { w = screen.availWidth; h = screen.availHeight; }
        if (winAlign.indexOf("center") != -1) { topPos = (h - popHeight) / 2; leftPos = (w - popWidth) / 2; }
        if (winAlign.indexOf("bottom") != -1) topPos = h - popHeight; if (winAlign.indexOf("right") != -1) leftPos = w - popWidth;
        if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0;
        features += (features.length > 0 ? ',' : '') + 'top=' + topPos + ',left=' + leftPos;
    }
    if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features += ",fullscreen=1";
    if (window["popupWindow"] == null) window["popupWindow"] = new Array();
    var wp = popupWindow.length;
    popupWindow[wp] = window.open(theURL, winName, features);
    if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;
    if (document.all || document.layers || document.getElementById) {
        if (borderless && borderless != "") { popupWindow[wp].resizeTo(popWidth, popHeight); popupWindow[wp].moveTo(leftPos, topPos); }
        if (alwaysOnTop && alwaysOnTop != "") {
            ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
            popupWindow[wp].document.body.onload = function() { window.setInterval("window.focus();", 50); };
        }
        if (autoCloseTime && autoCloseTime > 0) {
            popupWindow[wp].document.body.onbeforeunload = function() {
                if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
                window.onbeforeunload = null;
            }
            autoCloseTimeoutHandle = window.setTimeout("popupWindow[" + wp + "].close()", autoCloseTime * 1000);
        }
        window.onbeforeunload = function() { for (var i = 0; i < popupWindow.length; i++) popupWindow[i].close(); };
    }
    document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

window.onload = initialSwap; 
