var selectedMainLink    = null;
var mainLink_txt_to_obj = new Array();
var mainLink_sub_links  = new Array();

// sub link bools
var welcome_subs = false;
var about_us_subs = true;
var statement_of_faith_subs = false;
var philosophy_of_education_subs = false;
var what_is_classical_education_subs = true;
var future_plans_subs = true;
var enrollment_subs = false;
var employment_subs = false;
var calendar_subs = false;
var newsletter_subs = false;
var contact_subs = false;
var non_discrimination_subs = false;
var parentPage = false;


/*---------------------------*
 | Cross-Browser get element |
 *---------------------------*/
function getElement(id,scope) {

    if (scope == null)
        scope = "document";
    else
        scope = scope + ".document";


    if (document.all) {
        return eval(scope).all[id];
    }
    else if (document.getElementById) {
        return eval(scope).getElementById(id);
    }

}

function setup() {

    var linkDiv = getElement("mainLinks");
    var cLink   = null;
    var i       = 0;

    // Add mouseover highlight toggle events to all mainLink divs
    while (cLink = linkDiv.childNodes[i]) {


        if (cLink.className == "mainLink") {
            // Add highlight events
            cLink.onmouseover = mainLink_highlight;
            cLink.onmouseout  = mainLink_de_highlight;
        }
        
        ++i;

    }

    // Now enable IE5 and IE6 to properly display transparent PNG files
    // Code from http://homepage.ntlworld.com/bobosola/index.htm modified
    // by D. Lowhorn to use Peter-Paul Koch's browser detection
    
   //var arVersion = navigator.appVersion.split("MSIE")
   //var version = parseFloat(arVersion[1])
   if ( (BrowserDetect.browser == "Explorer") &&
        (BrowserDetect.version < 7) &&
        (BrowserDetect.version >= 5.5) &&
        (document.body.filters)) { 

      for(var i=0; i<document.images.length; i++) {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }

    }

}


function mainLink_highlight() {

    if (this != selectedMainLink)
        this.style.backgroundColor = "#555555";
    
}

function mainLink_de_highlight() {

    if (this != selectedMainLink)
        this.style.backgroundColor = "transparent";

}

/*
function mainLink_activate() {

    if (selectedMainLink != null) selectedMainLink.style.backgroundColor = "transparent";
    
    selectedMainLink = this;

    selectedMainLink.style.backgroundColor = "#555555";
    
    return;
}
*/

function loadedNewContent(txtTrigger) {

    var mainLink = getElement(txtTrigger);
    var i = 0;
    
    if (mainLink == selectedMainLink) return;
    
    if (selectedMainLink != null) {
        selectedMainLink.style.backgroundColor = "transparent";

        if (eval(selectedMainLink.id + "_subs") == true) {
            for (i = 0;i<eval(selectedMainLink.id + "_subs_list").length;i++)
                getElement(eval(selectedMainLink.id + "_subs_list")[i]).style.display = "none";
        }

    }
    
    if (mainLink != null) {
        mainLink.style.backgroundColor = "#ec4910";
        selectedMainLink     = mainLink;
    }

    // Check for sub links for this link
    if (eval(txtTrigger + "_subs")) {
        for (i = 0;i<eval(txtTrigger + "_subs_list").length;i++)
            getElement(eval(txtTrigger + "_subs_list")[i]).style.display = "block";
    }

}
