//Globals
var keepArrowAt = 0;
var isSectionPage = (document.location + "").indexOf("Sections/") > -1;
var isAtoZ = (document.location + "").indexOf("Category/Dictionary.htm") > -1;
isAtoZ = isAtoZ | (document.location + "").indexOf("Category/Index.htm") > -1;
var textWidth = 141;

// Add dhtmllib style browser indicator for gecko
if (window.navigator.product && (window.navigator.product.indexOf("Gecko") >= 0))  {
    isMinNS6 = 1;
}

// This next section runs immediately and defines a style dependant on the browser.
// Could also run logic here that defines styles based on the frame using isSectionPage

if (isSectionPage) {
    textWidth = textWidth - 19;
}

// Add control for menu link positioning and formatting for all browsers
if (isMinNS4 == 1) {
    if (isMinNS6 == 1) {
        document.write("<STYLE>\n.MenuPara {\n\twidth: " + textWidth + "px; text-align: right; margin-bottom: 8px;\n}\n");
        document.write("\n.MenuTable {\n\ttext-align: right; margin-bottom: 4px;\n}\n</STYLE>");
    } else {
        document.write("<STYLE>\n.MenuPara {\n\twidth: " + (textWidth-7) + "px; text-align: right; margin-top: -3px;\n}\n");
        document.write("\n.MenuTable {\n\ttext-align: right; line-height: 4px;\n}\n</STYLE>");
    }
} else {
    document.write("<STYLE>\n.MenuPara {\n\twidth: " + textWidth + "px; text-align: right; margin-bottom: 8px;\n}\n");
    document.write("\n.MenuTable {\n\ttext-align: right; margin-bottom: 4px;\n}\n</STYLE>");
}


// Define list styles
if (isMinNS4 == 1) {
       document.write("<STYLE>\nOL {\n\t margin-left: 0px;\n}\n");
       document.write("\nUL {\n\t margin-left: -2px;\n}\n</STYLE>");
} else {
       document.write("<STYLE>\nOL, LI {\n\t margin-left: 22px;\n}\n");
       document.write("\nUL {\n\t margin-left: 18px;\n}\n</STYLE>");
}

function shiftToItemSub(sNo) {
    a = getLayer("S" + sNo);
    l = getLayer("MenuArrow");
    ay = getPageTop(a);
    ax = 303;

    // Cure frame width problem
    if (isSectionPage) {
        ax += -19;
        if (isMinNS4 == 1) {
            ax += -4;
        }
    }

    // Add offset for NS
    if (isMinNS4 == 1) {
        ax += -4;
    }

    moveLayerTo(l, ax, ay);

    showLayer(l);
    return true;
}

function shiftToItemAtoM(mNo) {
    a = getLayer("M" + mNo);
    l = getLayer("MenuArrow");
    ay = getPageTop(a);
    ax = 110;

    // Cure frame width problem
    if (isSectionPage) {
        ax += -19;
        if (isMinNS4 == 1) {
            ax += -4;
        }
    }

    // Add offset for NS
    if (isMinNS4 == 1) {
        ax += -4;
    }

    moveLayerTo(l, ax, ay);

    showLayer(l);
    return true;
}

function shiftToItem(mNo) {
    a = getLayer("M" + mNo);
    l = getLayer("MenuArrow");
    ay = getPageTop(a);
    ax = 144;

    // Cure frame width problem
    if (isSectionPage) {
        ax += -19;
        if (isMinNS4 == 1) {
            ax += -4;
        }
    }

    // Add offset for NS
    if (isMinNS4 == 1) {
        ax += -4;
    }

    moveLayerTo(l, ax, ay);

    showLayer(l);
    return true;
}

function hideArrow() {
//    if (keepArrowAt==0) {
        hideLayer(getLayer("MenuArrow"));
//    } else {
//        shiftToItem(keepArrowAt);
//    }
    return true;
}


function keepItemBold(keepItem) {
    // Note: KeepItemBold no longer makes stuff bold - well ok it does
    
    if ((isMinIE4 == 1) && (keepArrowAt > 0) ) {
        tag = eval("document.all.M" + keepArrowAt + ".children[0]");
        tag.style.fontWeight="normal";
        tag.style.color="black";
    }

    keepArrowAt = keepItem;

    if (isMinIE4 == 1) {
        tag = eval("document.all.M" + keepArrowAt + ".children[0]");
        tag.style.fontWeight="bold";
        tag.style.color="#CC0033";
    }

    shiftSelectedToItem(keepArrowAt);

}

function keepItemBoldSub(keepItem) {
    // Note: KeepItemBold no longer makes stuff bold - well ok it does
    keepArrowAt = keepItem;

    if (isMinIE4 == 1) {
        tag = eval("document.all.S" + keepArrowAt + ".children[0]");
        tag.style.fontWeight="bold";
        tag.style.color="#CC0033";
    }

    shiftSelectedToItemSub(keepArrowAt);

}

function keepItemBoldAtoM(keepItem) {
    // Note: KeepItemBold no longer makes stuff bold - well ok it does
    keepArrowAt = keepItem;

    if (isMinIE4 == 1) {
        tag = eval("document.all.M" + keepArrowAt + ".children[0]");
        tag.style.fontWeight="bold";
        tag.style.color="#CC0033";
    }

    shiftSelectedToItemAtoM(keepArrowAt);

}

function keepItemBoldIntro(keepItem) {
    // Note: KeepItemBold no longer makes stuff bold - well ok it does
    
    if ((isMinIE4 == 1) && (keepArrowAt > 0) ) {
        tag = eval("document.all.M" + keepArrowAt + ".children[0]");
        tag.style.fontWeight="normal";
        tag.style.color="white";
    }

    keepArrowAt = keepItem;

    if (isMinIE4 == 1) {
        tag = eval("document.all.M" + keepArrowAt + ".children[0]");
        tag.style.fontWeight="bold";
        tag.style.color="#CC0033";
    }

    shiftSelectedToItem(keepArrowAt);

}


function shiftSelectedToItem(mNo) {
    a = getLayer("M" + mNo);
    l = getLayer("SelectedArrow");
    ay = getPageTop(a);
    ax = 144;

    // Cure frame width problem
    if (isSectionPage) {
        ax += -19;
        if (isMinNS4 == 1) {
            ax += -4;
        }
    }

    // Add offset for NS4
    if (isMinNS4 == 1) {
        ax += -4;
    }

    moveLayerTo(l, ax, ay);

    showLayer(l);
    return true;
}

function shiftSelectedToItemAtoM(mNo) {
    a = getLayer("M" + mNo);
    l = getLayer("SelectedArrow");
    ay = getPageTop(a);
    ax = 110;

    // Cure frame width problem
    if (isSectionPage) {
        ax += -19;
        if (isMinNS4 == 1) {
            ax += -4;
        }
    }

    // Add offset for NS4
    if (isMinNS4 == 1) {
        ax += -4;
    }

    moveLayerTo(l, ax, ay);

    showLayer(l);
    return true;
}

function shiftSelectedToItemSub(sNo) {
    a = getLayer("S" + sNo);
    l = getLayer("SelectedArrow2");
    ay = getPageTop(a);
    ax = 303;

    // Cure frame width problem
    if (isSectionPage) {
        ax += -19;
        if (isMinNS4 == 1) {
            ax += -4;
        }
    }

    // Add offset for NS4
    if (isMinNS4 == 1) {
        ax += -4;
    }

    // On A to Z pages give links a shunt to the left
    if (isAtoZ == 1) {
        // fixed offset for a-z pages
        ax += -2;
        // additional offset for IE4
        if (isMinIE4 == 1) {
            ax += -53;
        }
        if (isMinIE5 == 1) {
            ax += 26;
        }
        if (isMinIE55 == 1) {
            ax += 1;
            ay = (ay / 2) + 29;
        }
        if (isMinIE6 == 1) {
            ax += 26;
            ay = (ay / 2) + 27;
        }

        if ((sNo % 2) > 0) {

            // offset for left hand letters
            ax += -34;
            if (isMinNS4 == 1) {
                // offset for netscape for left hand letters
                ax += -2;
            }
        }
        if (isMinNS4 == 1) {
            // offset for netscape for all letters
            ax += -22;
        }
    }

    moveLayerTo(l, ax, ay);

    showLayer(l);
    return true;
}

var browserOk = false;
var browserName = navigator.appName;           
var browserVer = parseInt(navigator.appVersion); 
if (browserName == "Netscape" && browserVer >= 3) {
    browserOk = true;
}
if (!browserOk){
    var ms = navigator.appVersion.indexOf("MSIE")
    if ((ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4)) browserOk = true;
}
if (browserOk){
navbar1on = new Image();
navbar1on.src = level + "pics/ButtonMenu1_On.gif";
navbar1off = new Image();
navbar1off.src = level + "pics/ButtonMenu1_Off.gif";

navbar2on = new Image();
navbar2on.src = level + "pics/ButtonMenu2_On.gif";
navbar2off = new Image();
navbar2off.src = level + "pics/ButtonMenu2_off.gif";

navbar3on = new Image();
navbar3on.src = level + "pics/ButtonMenu3_On.gif";
navbar3off = new Image();
navbar3off.src = level + "pics/ButtonMenu3_off.gif";

navbar4on = new Image();
navbar4on.src = level + "pics/ButtonMenu4_On.gif";
navbar4off = new Image();
navbar4off.src = level + "pics/ButtonMenu4_off.gif";

navbar5on = new Image();
navbar5on.src = level + "pics/ButtonMenu5_On.gif";
navbar5off = new Image();
navbar5off.src = level + "pics/ButtonMenu5_off.gif";

navbar6on = new Image();
navbar6on.src = level + "pics/ButtonMenu6_On.gif";
navbar6off = new Image();
navbar6off.src = level + "pics/ButtonMenu6_off.gif";

navbar7on = new Image();
navbar7on.src = level + "pics/ButtonMenu7_On.gif";
navbar7off = new Image();
navbar7off.src = level + "pics/ButtonMenu7_off.gif";

navbar8on = new Image();
navbar8on.src = level + "pics/ButtonMenu8_On.gif";
navbar8off = new Image();
navbar8off.src = level + "pics/ButtonMenu8_off.gif";

navbar9on = new Image();
navbar9on.src = level + "pics/ButtonMenu9_On.gif";
navbar9off = new Image();
navbar9off.src = level + "pics/ButtonMenu9_off.gif";
}

function img_act(imgButton){
    if (browserOk){
        imgOn = eval(imgButton + "on.src");
        document [imgButton].src = imgOn;
    }
}

function img_inact(imgButton){
    if (browserOk){
        imgOff = eval(imgButton + "off.src");
        document [imgButton].src = imgOff;
    }
}

function goPopUpWindow(DictionaryID, WindowFunction, WindowName){
    fileUse = dirUse + 'Index.asp?ID=' + DictionaryID + '&Function=' + WindowFunction;
    if (WindowFunction == 'Dictionary')
        window.open(fileUse, WindowName, 'width=250,height=200,scrollbars=0,resizable=0,menubar=0,toolbar0,status=0,location=0,directories=0,screenX=100,screenY=100,left=100,top=100');
    if (WindowFunction == 'Image')
        window.open(fileUse, WindowName, 'width=500,height=385,scrollbars=0,resizable=0,menubar=0,toolbar0,status=0,location=0,directories=0,screenX=100,screenY=100,left=100,top=100');
}