//initialize
var DM_activeMenus = new menuset();
document.onclick = DM_hideMenus;
window.onresize = positionMenus;

window.onload = initPage;


//initPage: initializes a page after it loads
function initPage() 
{
    DM_activeMenus.positionTimer = setInterval("positionAllMenus()",3000);
}


sb_topNavObject.prototype.sb_add = function(sb_topNavImageObject) 
{
    this.imageCollection[this.imageCounter] = sb_topNavImageObject;
    this.imageCounter ++;
}

/*
------------------------------------------
Function name  - sb_topNavObject
Description - used to create a collection of Top Nav Images
------------------------------------------  
*/
function sb_topNavObject()
{
    this.imageCollection = new Array();
    this.imageCounter = 0;
    return this;
}

/*
------------------------------------------
Function name  - sb_topImageObject
Description - used to create top nav image objects and set its properties 
              this is used to highlight the image for the section you are in
------------------------------------------  
*/
function sb_topNavImageObject(dirName, imageId, divId, onSrc)
{
    this.dirName = dirName;
    this.imageId = imageId;
    this.divId = divId;
    this.onSrc = onSrc;
    return this;
}




//***** MENUSET FUNCTIONS *****

//menuset: menuset constructor
function menuset() 
{
    this.menus = new Array();
    this.ready = false;
    this.positioned = false;
    this.timer = null;
    this.positionTimer = null;
    this.positionedMenu = 0;
    this.currLocation = "";

    //public properties 
    this.backgroundColor = "#009999";
    this.hBackgroundColor = "#ffffff";
    this.color = "#ffffff";
    this.hColor = "#006666";
    this.fontFamily = "Arial,Helvetica,Verdana,sans-serif";
    this.padding = 3;
    this.fontSize = 8;
    this.heightSingle = 21;
    this.heightDouble = 36;
    this.heightSingleTextLimit = 22;
	if (mBrowser.isNS6plus) {
		this.heightSingle = 15;
	    this.heightDouble = 30;
		this.heightSingleTextLimit = 25;
	}
    this.width = 130;
    this.spacerURL = "/site_images/s.gif";
    this.subImgURL = "/site_images/s.gif";
    this.subImgWidth = 18;
    this.subImgHeight = 20;
    
    return this;
}
menuset.prototype.addMenu = addMenu;
menuset.prototype.appendMenu = appendMenu;
menuset.prototype.show = showMenusetMenu;
menuset.prototype.hide = DM_hideMenusetMenu;
menuset.prototype.DM_hideMenus = hideDM_activeMenus;
menuset.prototype.getMenu = getMenu;
menuset.prototype.getMenuItem = getMenuItem;
menuset.prototype.highlightOn = highlightMenuItemOn;
menuset.prototype.highlightOff = highlightMenuItemOff;
menuset.prototype.setPosition = setMenusetPosition;
menuset.prototype.writeHTML = writeMenusetHTML;
menuset.prototype.writeStyles = writeMenusetStyles;

//addMenu: adds a menu to a menuset
function addMenu(sId,sParentId,sMenuAnchor,sParentAnchor,sOffImgURL,sOnImgURL,hideFormParam) {
    if (typeof siteUrl == 'undefined') {
        siteUrl = "";
    }
    
    var i = this.menus.length;
    if ((location.hostname.indexOf("webdev") == -1) && (location.hostname.indexOf("wcm.") == -1)) {
        if ((sOffImgURL.indexOf("http") != 0) && (sOffImgURL.indexOf("javascript") != 0)) {
            sOffImgURL = siteUrl + sOffImgURL;
        }
        if ((sOnImgURL.indexOf("http") != 0) && (sOnImgURL.indexOf("javascript") != 0)) {
            sOnImgURL = siteUrl + sOnImgURL;
        }
    }
    var eMenu = new menu(sId,sParentId,this,sMenuAnchor,sParentAnchor,sOffImgURL,sOnImgURL,hideFormParam);
    this.menus[i] = eMenu;
    
    return eMenu;
}

//appendMenu: appends a menu object to the menuset
function appendMenu(eMenu)
{
    var i = this.menus.length;
    this.menus[i] = eMenu;
    
    return eMenu;
}

//showMenusetMenu: shows a menu
function showMenusetMenu(sId,bSetTimeout) 
{
    var eMenu = this.getMenu(sId);
    if (!eMenu)
    {
        //if the menu doesn't exist, fail gracefully
        return;
    }
    //hide all menus except the one to display
    this.DM_hideMenus(sId);
    
    //show the menu
    eMenu.show();
    
    //turn timer on
    clearTimeout(this.timer);
    if (bSetTimeout)
    {
        //turn timer on
        this.timer = setTimeout("DM_hideMenus()",100);
    }
    else
    {
        //turn timer on for a long time
        this.timer = setTimeout("DM_hideMenus()",5000);
    }
    
    return eMenu;
}

//DM_hideMenusetMenu: schedules a menu for removal
function DM_hideMenusetMenu(sId) {
    var eMenu;
    eMenu = this.getMenu(sId);
    if (eMenu) {
        eMenu.hide();
    }
}

//DM_hideMenus: general function that calls DM_hideMenus on the menuset
function DM_hideMenus(sId) {
    if (sId) {
        DM_activeMenus.DM_hideMenus(sId);
    } else {
        DM_activeMenus.DM_hideMenus();
    }
}

//setMenuPosition: general function that calls setPosition on the menuset
function positionAllMenus() {
    if (DM_activeMenus.positionedMenu == DM_activeMenus.menus.length) {
        DM_activeMenus.positioned = true;
        clearInterval(DM_activeMenus.positionTimer);
        return;
    } else {
        DM_activeMenus.setPosition(DM_activeMenus.positionedMenu);
        DM_activeMenus.positionedMenu += 1;
    }
}

//positionMenus: general function that calls setPosition on the menuset
function positionMenus() {
    if (mBrowser.isNS4) {
        window.location.reload();
    } else {
        DM_activeMenus.setPosition();
    }   
}

//hideDM_activeMenus: hides all items
function hideDM_activeMenus(sId,bSubMenuOnly) {
    var eMenu;
    var oMenus = this.menus;
    var iNumMenus = oMenus.length;

    for (var i=0; i < iNumMenus; i++) {
        eMenu = oMenus[i];
        eMenu.hide(sId,bSubMenuOnly);
    }
}

//setMenusetPosition: positions all menus
function setMenusetPosition(iMenu) {
    if (this.positioned){
        return;
    }
    
    var eMenu;
    var oMenus = this.menus;
    var iNumMenus = oMenus.length;
    
    if (!isNaN(iMenu)){
        iNumMenus = iMenu + 1;
    } else {
        iMenu = 0;
    }

    for (var i=iMenu; i < iNumMenus; i++) {
        //window.status = "positioning menus " + i;
        eMenu = oMenus[i];
        eMenu.setPosition();
    }
    //window.status = "";
    
    this.ready = true;
}

//highlightMenuItemOn: highlights a menu item
function highlightMenuItemOn(sId) {
    var eMenuItem = this.getMenuItem(sId);
    eMenuItem.highlightOn();
}

//highlightMenuItemOff: de-highlights a menu item
function highlightMenuItemOff(sId) {
    var eMenuItem = this.getMenuItem(sId);
    eMenuItem.highlightOff();
}


//getMenu: returns the first menu with the specified id
function getMenu(sId) {
    var eMenu;
    var oMenus = this.menus;
    var iNumMenus = oMenus.length;

    for (var i=0; i < iNumMenus; i++) {
        eMenu = oMenus[i];
        if (sId == eMenu.id) {
            return eMenu;
        }
    }
    return null;
}

//getMenuItem: returns the first menuItem with the specified id
function getMenuItem(sId) 
{
    var eMenu;
    var eMenuItem;
    var oMenus = this.menus;
    var iNumMenus = oMenus.length;
    
    for (var i=0; i < iNumMenus; i++) {
        eMenu = oMenus[i];
        eMenuItem = eMenu.getItem(sId);
        if (eMenuItem) {
            return eMenuItem;
        }
    }
    return null;
}

//writeMenusetHTML: writes each menu's HTML to the page
function writeMenusetHTML()
{
    var sHTML = "";

    var eMenu;
    var oMenus = this.menus;
    var iNumMenus = oMenus.length;
    
    for (var i=0; i<iNumMenus; i++)
    {
        eMenu = oMenus[i];
        sHTML += eMenu.getHTML();
    }
    //alert(sHTML);
    document.write(sHTML);
}

//writeMenusetStyles: writes each menu's styles to the page
function writeMenusetStyles()
{
    var sHTML = "<style>\nDIV.Menu {visibility:hidden; position:absolute; background-color:#000000; layer-background-color: #000000; width:200px; z-index:70; clip:rect(0px, 200px, 500px, 0px);}";

    sHTML += "\nDIV.MenuEmpty {visibility:hidden; position:absolute; background-color:#000000; layer-background-color: #000000; width:0px; z-index:70; clip:rect(0px, 0px, 0px, 0px);}";
    sHTML += "TABLE.MenuItem {width:100%;}";
    sHTML += "TD.MenuItemText {padding:" + this.padding + "px;}";
    
    var eMenu;
    var oMenus = this.menus;
    var iNumMenus = oMenus.length;
    
    for (var i=0; i<iNumMenus; i++)
    {
        eMenu = oMenus[i];
        sHTML += eMenu.styles;
    }
    
    sHTML += "DIV.MenuItemCover {visibility: hidden; position:absolute; cursor:hand; color:#000000; width:" + this.width + "px; height:50px; clip:rect(0px," + this.width + "px,51px,0px); vertical-align:middle; padding:0px; z-index:100;}</style>";

    //alert(sHTML);
    document.write(sHTML);
}



//***** MENU FUNCTIONS *****

//menu: menu object constructor
function menu(sId,sParentId,oMenuset,sAnchor,sParentAnchor,sOffImgURL,sOnImgURL,hideFormParam) {
    this.id = sId;
    this.menuImg = sId + "_img";
    this.menuset = oMenuset;
    this.html = null;
    this.styles = null;
    this.positioned = false;
    this.ready = false;
    this.menuAnchor = sAnchor;
    this.parentAnchor = sParentAnchor;
    this.menuItems = new Array();
    this.parentId = sParentId;
    this.spacerURL = oMenuset.spacerURL;
    this.hideForm = false;
        
    if (sOnImgURL) {
        var imgOff = new Image();
        imgOff.src = sOffImgURL;
        this.imgOff = imgOff;
        
        var imgOn = new Image();
        imgOn.src = sOnImgURL;
        this.imgOn = imgOn;
    } else {
        this.imgOn = null;
        this.imgOff = null;
    }
    
    if ((typeof hideFormParam != 'undefined') && (hideFormParam == "hideForm")){
        this.hideForm = true;
    }
    //public properties
    this.backgroundColor = oMenuset.backgroundColor;
    this.hBackgroundColor = oMenuset.hBackgroundColor;
    this.color = oMenuset.color;
    this.hColor = oMenuset.hColor;
    this.fontSize = oMenuset.fontSize;
    this.width = oMenuset.width;
    
    this.createHTML();

    if (typeof sParentId == "string") {
        //set references to the menu's parent
        var eParent = this.menuset.getMenuItem(sParentId);
        this.parent = eParent;
        eParent.subMenu = this;
    }
    return this;
}
menu.prototype.addItem = addMenuItem;
menu.prototype.show = showMenu;
menu.prototype.hide = hideMenu;
menu.prototype.hideMenuItems = hideMenuItems;
menu.prototype.getItem = getItem;
menu.prototype.createHTML = createMenuHTML;
menu.prototype.getHTML = getMenuHTML;
menu.prototype.setPosition = setMenuPosition;
menu.prototype.createObjects = createMenuObjects;


//addMenuItem: adds a new menu item to a menu
function addMenuItem(sText,sURL,newWindow,iHeight) {
    if (typeof siteUrl == 'undefined') {
        siteUrl = "";
    }
    
    var i = this.menuItems.length;
    var sId = this.id + "Item" + (i + 1);
    itemUrl = sURL;
    if ((location.hostname.indexOf("webdev") == -1) && (location.hostname.indexOf("wcm.") == -1)) {
        if ((itemUrl.indexOf("http") != 0) && (itemUrl.indexOf("javascript") != 0)) {
            itemUrl = siteUrl + itemUrl;
        }
    }
    var eMenuItem = new menuItem(sId,sText,itemUrl,this,newWindow,iHeight);
    this.menuItems[i] = eMenuItem;
    
    return eMenuItem;
}

function setMenuPosition(){ 
    if (this.positioned) {
        return;
    }
    
    if (!this.ready){
        this.createObjects();
    }
    
    var oThis = this.object;
    var oMenuItems = this.menuItems;
    var iNumMenuItems = oMenuItems.length;
    var iLeft = 0;
    var iTop = 0;
    var iMenuHeight = 0;
    var iMenuWidth = 0;
    
    //calculate the height of the menu
    var eMenuItem;
    var iTotalHeight = 0;

    for (var i=0; i < iNumMenuItems; i++){
        eMenuItem = oMenuItems[i];
        if (!eMenuItem.ready){
            eMenuItem.createObjects();
        }
        iTotalHeight += getHeight(eMenuItem.object);
    }
    
    //set the menu's height
    iMenuHeight = iTotalHeight + iNumMenuItems + 1;
    this.height = iMenuHeight;
    setHeight(oThis,iMenuHeight);
    
    //set the menu's width
    if (eMenuItem){
        iMenuWidth = eMenuItem.getWidth() + 2;
        this.width = iMenuWidth;
        setWidth(oThis,iMenuWidth);
    }
    
    //get a reference to the object that the menu should be positioned against
    var eAttach = getObj(this.menuImg);

    if (mBrowser.isMac && mBrowser.isIE){
        var iLeftIncrement = 3;
        var iTopIncrement = 2;
    } else {
        var iLeftIncrement = 0;
        var iTopIncrement = 2;  
    }
    //position the menu relative to an item on the page
    if (eAttach) {
        switch (this.menuAnchor) {
            case "topLeft":
                switch (this.parentAnchor) {
                    case "topLeft":
                        break;
                    case "topRight":
                        iLeft = getOffset(eAttach,"left") + getWidth(eAttach,"Img") + iLeftIncrement;
                        iTop = getOffset(eAttach,"top") + iTopIncrement - 1;
                        break;
                    case "bottomLeft":
                        iLeft = getOffset(eAttach,"left") + iLeftIncrement;
                        iTop = getOffset(eAttach,"top") + getHeight(eAttach,"Img") - 1 + iTopIncrement;
                        break;
                    case "bottomRight":
                        break;
                    default:
                        break;
                }
                break;
            case "topRight":
                switch (this.parentAnchor) {
                    case "topLeft":
                        break;
                    case "topRight":
                        break;
                    case "bottomLeft":
                        break;
                    case "bottomRight":
                        iLeft = getOffset(eAttach,"left") + getWidth(eAttach,"Img") - iMenuWidth + 1 + iLeftIncrement;
                        iTop = getOffset(eAttach,"top") + getHeight(eAttach,"Img") - 1 + iTopIncrement;
                        break;
                    default:
                        break;
                }
                break;
            case "bottomLeft":
                switch (this.parentAnchor) {
                    case "topLeft":
                        iLeft = getOffset(eAttach,"left") + iLeftIncrement;
                        iTop = getOffset(eAttach,"top") - iMenuHeight + iTopIncrement;
                        break;
                    case "topRight":
                        break;
                    case "bottomLeft":
                        break;
                    case "bottomRight":
                        break;
                    default:
                        break;
                }
                break;
            case "bottomRight":
            default:
                switch (this.parentAnchor) {
                    case "topLeft":
                        break;
                    case "topRight":
                        iLeft = getOffset(eAttach,"left") + getWidth(eAttach,"Img") - iMenuWidth + iLeftIncrement;
                        iTop = getOffset(eAttach,"top") - iMenuHeight + iTopIncrement;
                        break;
                    case "bottomLeft":
                        break;
                    case "bottomRight":
                        break;
                    default:
                        break;
                }
                break;
        }
        
        var oStyleObj = this.styleObj;
        if (mBrowser.isIE) {
            oStyleObj.posLeft = iLeft;
            oStyleObj.posTop = iTop;
        } else {
            oStyleObj.left = iLeft;
            oStyleObj.top = iTop;
        }
    }
    //initialize the menu's left and top
    this.menuItemLeft = iLeft + 1;
    this.menuItemTop = iTop + 1;

    //position the menu items
    for (var i=0; i < iNumMenuItems; i++) {
        eMenuItem = oMenuItems[i];
        eMenuItem.setPosition();
        
        //update the menu's menuItemTop property
        this.menuItemTop += eMenuItem.height + 1;
    }
    this.positioned = true;
}

function showMenu(){
    //if this menu is already visible, return
    if (this.visibility){
        return;
    }
    
    //position the menu if necessary
    if (!this.positioned){
        this.setPosition();
    }
    
    //if the menu html object references don't exist, return
    if (!this.ready){
        return;
    }

    //highlight the menu's title image
    var eImgOn = this.imgOn;
    if (eImgOn) {
        var eMenuImg = getObj(this.menuImg);
        eMenuImg.src = eImgOn.src;
    }
    
    if (this.hideForm) { // hide conflicting form field
        MM_showHideLayers('specDiv','','hide');
    }
    
    //show the menu's parent
    var oParent = this.parent;
    if (oParent){
        if (oParent.visibility == false){
            oParent.show();
        }
    }
    
    //show the menu items
    var oMenuItems = this.menuItems;
    var iNumMenuItems = oMenuItems.length;
    for (var i=0; i < iNumMenuItems; i++){
        eMenuItem = oMenuItems[i];
        eMenuItem.show();
    }

    // Show the menu if there is at least one item
    if (iNumMenuItems > 0 ) {
        //show the menu
        this.styleObj.visibility = "visible";
    }
    
    //this.styleObj.display = "block";
    this.visibility = true;
}

function hideMenu(sId,bSubMenuOnly){
    var bHide = false;
    
    //if this menu is not visible, return
    if (!this.visibility){
        return;
    }
    
    //check whether to hide only submenus
    if (bSubMenuOnly){
        if (this.parent){
            //hide the menu
            if (sId){
                if (this.id != sId) {
                    bHide = true;
                }
            } else {
                bHide = true;
            }
        }
    } else {
        //hide the menu
        if (sId){
            if (this.id != sId){
                bHide = true;
            }
        } else {
            bHide = true;
        }
    }
    if (bHide){
        //un-highlight the menu's title image
        var eImgOff;
        
        // if this is the image for the current section, don't turn it off
        if (DM_activeMenus.currLocation == this.id) {
            eImgOff = this.imgOn;
        } else {
            eImgOff = this.imgOff;
        }
        
        if (eImgOff) {
            var eMenuImg = getObj(this.menuImg);
            eMenuImg.src = eImgOff.src;
        }
        
        if (this.hideForm) { // show conflicting form field
            MM_showHideLayers('specDiv','','show');
        }
        
        //hide the menu
        this.styleObj.visibility = "hidden";
        //this.styleObj.display = "none";
        this.visibility = false;
        
        this.hideMenuItems();
    }
}

//hideMenuItems: hides all the menu items in this menu
function hideMenuItems() {
    var eMenuItem;
    var oMenuItems = this.menuItems;
    var iNumMenuItems = oMenuItems.length;
    
    //hide the menu items
    for (var i=0; i < iNumMenuItems; i++) {
        eMenuItem = oMenuItems[i];
        eMenuItem.hide();
    }
}

//getItem: returns the first menu item with the specified id
function getItem(sId) {
    var eMenuItem;
    var oMenuItems = this.menuItems;
    var iNumMenuItems = oMenuItems.length;

    for (var i=0; i < iNumMenuItems; i++) {
        eMenuItem = oMenuItems[i];
        if (sId == eMenuItem.id)  {
            return eMenuItem;
        }
    }
    return null;
}

function createMenuHTML() {
    
    //create the menu
    var sMenu = "";
    
    if (typeof siteUrl == 'undefined') {
        siteUrl = "";
    }
    
    sMenu = "\n\n<div id='" + this.id + "' class='Menu'><img src='" + siteUrl + this.spacerURL + "' height='100%' width='100%' border='0'></div>";
    
    //create styles
    var sFontSize = this.fontSize;
    if (mBrowser.isWin && mBrowser.isNS4){
        sFontSize += 1;
    }
    if (mBrowser.isMac && mBrowser.isNS4){
        sFontSize += 2;
    }
    var iWidth = this.width;
    var sBackgroundColor = this.backgroundColor;
    var sColor = this.color;
    var sHBackgroundColor = this.hBackgroundColor;
    var sHColor = this.hColor;
    var oMenuset = this.menuset;
    var iPadding = oMenuset.padding;
    var sFontFamilyCSS = "";
    var sFontFamily = oMenuset.fontFamily;
    if (sFontFamily){
        sFontFamilyCSS = " font-family: " + sFontFamily + ";";
    }
    
    var sClassName = this.id + "MenuItem";      
    
    var sStyle = "DIV." + sClassName + ", DIV." + sClassName + "Highlight, DIV." + sClassName + "Parent, DIV." + sClassName + "HighlightParent {visibility:hidden; position:absolute; color:" +  sColor + "; background-color:" + sBackgroundColor + "; layer-background-color:" + sBackgroundColor + "; " + sFontFamilyCSS + " font-size:" + sFontSize + "pt; width:" + iWidth + "px; height: 50px; padding: " + iPadding + "px; clip:rect(0px," + iWidth + "px, 51px, 0px); vertical-align:middle; cursor: hand; z-index: 80;}";
    sStyle += "DIV." + sClassName + "Highlight, DIV." + sClassName + "HighlightParent {color:" +  sHColor + "; background-color:" + sHBackgroundColor + "; layer-background-color:" + sHBackgroundColor + "; " + sFontFamilyCSS + " font-size:" + sFontSize + "pt; z-index: 90;}";
    sStyle += "DIV." + sClassName + "Parent, DIV." + sClassName + "HighlightParent {padding:0px;}";
    sStyle += "DIV." + sClassName + "Parent TD, DIV." + sClassName + "HighlightParent TD {color:" +  sColor + "; " + sFontFamilyCSS + " font-size:" + sFontSize + "pt;}";
    sStyle += "DIV." + sClassName + "HighlightParent TD {color:" +  sHColor + ";}";

    this.html = sMenu;
    this.styles = sStyle;
}

//getMenuHTML: returns the html for the menu and its menu items
function getMenuHTML(){
    var sHTML = this.html;
    var eMenuItem;
    var oMenuItems = this.menuItems;
    var iNumMenuItems = oMenuItems.length;
        
    for (var i=0; i<iNumMenuItems; i++){
        eMenuItem = oMenuItems[i];
        sHTML += eMenuItem.html;
    }
    return sHTML;
}

//createMenuObjects: creates references to the menu's html objects
function createMenuObjects(){
    var sId = this.id;
    
    if (this.ready){
        return;
    }
    this.object = getObj(sId);
    this.styleObj = getStyleObj(sId);
    this.ready = true;
}

//***** MENUITEM FUNCTIONS *****
//menuItem: menuItem object constructor
function menuItem(sId,sText,sURL,oMenu,newWindow,iHeight) {
    var sHighlightId = sId + "Highlight";
    var sCoverId = sId + "Cover";
    
    this.id = sId;
    this.highlightStyleObjId = sHighlightId;
    this.coverStyleObjId = sCoverId;
    this.menu = oMenu;
    this.hasSubMenu = false;
    this.subMenu = null;
    this.text = sText;
    this.url = sURL;
    this.visibility = false;
    this.width = oMenu.width;
    this.positioned = false;
    this.ready = false;
    this.newWindow = newWindow;
    this.iHeight = iHeight;
    this.html = null;
    this.styleObj = null;
    this.highlightStyleObjStyleObj = null;
    this.coverStyleObjStyleObj = null;
    this.spacerURL = oMenu.spacerURL;
    
    var oMenuset = oMenu.menuset;
    this.subImgURL = oMenuset.subImgURL;
    this.subImgHeight = oMenuset.subImgHeight;
    this.subImgWidth = oMenuset.subImgWidth;
    this.heightSingleTextLimit = oMenuset.heightSingleTextLimit;
    this.heightSingle = oMenuset.heightSingle;
    this.heightDouble = oMenuset.heightDouble;
    
    this.createHTML();  
    
    return this;
}
menuItem.prototype.show = showMenuItem;
menuItem.prototype.hide = hideMenuItem;
menuItem.prototype.highlightOn = highlightItemOn;
menuItem.prototype.highlightOff = highlightItemOff;
menuItem.prototype.createHTML = createMenuItemHTML;
menuItem.prototype.setPosition = setMenuItemPosition;
menuItem.prototype.getWidth = getMenuItemWidth;
menuItem.prototype.createObjects = createMenuItemObjects;
menuItem.prototype.addSubmenu = addSubmenu;

//setMenuItemPosition: positions the menu item relative to other items in its menu
function setMenuItemPosition(){
    if (this.positioned){
        return;
    }
    if (!this.ready){
        this.createObjects();
    }
    
    var eMenu = this.menu;
    var iMenuItemLeft = eMenu.menuItemLeft;
    var iMenuItemTop = eMenu.menuItemTop;

    var oThis = this.styleObj;
    var oHighlight = this.highlightStyleObj;
    var oCover = this.coverStyleObj;
    
    if (mBrowser.isNS4){
        oThis.left = iMenuItemLeft;
        oThis.top = iMenuItemTop;
        oHighlight.left = iMenuItemLeft;
        oHighlight.top = iMenuItemTop;
        oCover.left = iMenuItemLeft;
        oCover.top = iMenuItemTop;
    } else {
        if (mBrowser.isIE){
            oThis.posLeft = iMenuItemLeft;
            oThis.posTop = iMenuItemTop;
            
            if (mBrowser.isMac){
                oHighlight.posLeft = iMenuItemLeft;
                oHighlight.posTop = iMenuItemTop;
                oCover.posLeft = iMenuItemLeft;
                oCover.posTop = iMenuItemTop;
            }
        } else {
            oThis.left = iMenuItemLeft;
            oThis.top = iMenuItemTop;
            
            if (mBrowser.isMac) {
                oHighlight.left = iMenuItemLeft;
                oHighlight.top = iMenuItemTop;
                oCover.left = iMenuItemLeft;
                oCover.top = iMenuItemTop;
            }       
        }
    }
    this.positioned = true;
}

//showMenuItem: shows a menu item
function showMenuItem(){
    this.styleObj.visibility = "visible";
    
    if (mBrowser.isNS4 || mBrowser.isMac){
        this.highlightStyleObj.visibility = "hidden";
        this.coverStyleObj.visibility = "visible";
    }
    this.visibility = true;
}

//hideMenuItem: hides a menu item
function hideMenuItem(){
    this.styleObj.visibility = "hidden";
    
    if (mBrowser.isNS4 || mBrowser.isMac){
        this.highlightStyleObj.visibility = "hidden";
        this.coverStyleObj.visibility = "hidden";
    }
    this.visibility = false;
}

//highlightItemOn: turns on highlighting for a menu item
//shows submenu if necessary
function highlightItemOn(){
    var oSubMenu = this.subMenu;

    if (mBrowser.isNS4 || mBrowser.isMac){
        this.highlightStyleObj.visibility = "visible";
    }else{
        if (oSubMenu){
            this.object.className = this.menu.id + "MenuItemHighlightParent";
        }else{
            this.object.className = this.menu.id + "MenuItemHighlight";
        }
    }
    
    //hide other menus
    var oMenu = this.menu;
    oMenu.menuset.DM_hideMenus(oMenu.id,true);
    
    //show the submenu if necessary
    if (oSubMenu){
        oSubMenu.show();
    }
    clearTimeout(this.menu.menuset.timer);
}

//highlightItemOff: turns off highlighting for a menu item
function highlightItemOff(){
    var oSubMenu = this.subMenu;

    if (mBrowser.isNS4 || mBrowser.isMac){
        this.highlightStyleObj.visibility = "hidden";
    }else{
        if (oSubMenu){
            this.object.className = this.menu.id + "MenuItemParent";
        }else{
            this.object.className = this.menu.id + "MenuItem";
        }
    }

    var iWhen = 1000;
    if (oSubMenu){
        if (oSubMenu.visibility){
            iWhen = 10000;
        }
    }
    this.menu.menuset.timer = setTimeout("DM_hideMenus()",iWhen);//turn timer on
}

//createMenuItemHTML: writes the menu item to the page
function createMenuItemHTML(){
    var sClassPrefix = this.menu.id;
    var sId = this.id;
    var sText = this.text;
    var bIsNS4 = mBrowser.isNS4;
    var bIsMac = mBrowser.isMac;
    var sStyle = "";
    var sURL = this.url;
    var surl = sURL.toLowerCase();
    var sOnclick;
    
    if (typeof siteUrl == 'undefined') {
        siteUrl = "";
    }
    
    if (surl.indexOf("javascript:")>=0) {
        sOnclick = sURL.substring(11,sURL.length-1);
    } else {
        if (this.newWindow == 1) {
            sOnclick =  '"window.open(\'' + sURL + '\');return false;"';
        } else {
            sOnclick = "\"window.location.href='" + sURL + "';\"";
        }
    }
    
    sTarget = "";
    if (this.newWindow == 1) {
        sTarget = ' target="_blank"';
    }
    
    if (this.hasSubMenu){
        var sSubImgURL = this.subImgURL;
        var iSubImgWidth = this.subImgWidth;
        var iSubImgHeight = this.subImgHeight;
        var iWidth = this.menu.width;
        var iTextWidth = iWidth - iSubImgWidth;

        if (bIsNS4 || bIsMac){  
            //create the menu item
            var sMenuItem = "\n<div id='" + sId + "' class='" + sClassPrefix + "MenuItemParent'><table width='" + iWidth + "px' cellpadding='0' cellspacing='0' border='0' class='MenuItem'><tr><td class='MenuItemText' width='" + iTextWidth + "'>" + sText + "&nbsp;</td><td valign='top' width='" + iSubImgWidth + "'><img src='" + sSubImgURL + "' width='" + iSubImgWidth + "' height='" + iSubImgHeight + "' border='0' id='" + sId + "SMImg' name='" + sId + "SMImg'></td></tr></table></div>";
            
            //create the highlighted version
            sMenuItem += "\n<div id='" + sId + "Highlight' class='" + sClassPrefix + "MenuItemHighlightParent'><table width='" + iWidth + "px' cellpadding='0' cellspacing='0' border='0' class='MenuItem'><tr><td class='MenuItemText' width='" + iTextWidth + "'>" + sText + "&nbsp;</td><td valign='top' width='" + iSubImgWidth + "'><img src='" + sSubImgURL + "' width='" + iSubImgWidth + "' height='" + iSubImgHeight + "' border='0'></td></tr></table></div>";
        }else{
            //create the menu item
            var sMenuItem = "\n<div id='" + sId + "' class='" + sClassPrefix + "MenuItemParent'><table cellpadding='0' cellspacing='0' border='0' class='MenuItem'><tr><td " +  "onMouseover=\"DM_activeMenus.highlightOn('" + sId + "');\"  onMouseout=\"DM_activeMenus.highlightOff('" + sId + "');\" onclick=" + sOnclick + " class='MenuItemText'>" + sText + "&nbsp;</td><td " +  "onMouseover=\"DM_activeMenus.highlightOn('" + sId + "');\"  onMouseout=\"DM_activeMenus.highlightOff('" + sId + "');\" onclick=" + sOnclick + " valign='top' width='" + iSubImgWidth + "'><img src='" + sSubImgURL + "' width='" + iSubImgWidth + "' height='" + iSubImgHeight + "' border='0' id='" + sId + "SMImg' name='" + sId + "SMImg'></td></tr></table></div>";
        }
    }else{
        if (bIsNS4 || bIsMac){  
            //create the menu item
            var sMenuItem = "\n<div id='" + sId + "' class='" + sClassPrefix + "MenuItem'>" + sText + "</div>";
            
            //create the highlighted version
            sMenuItem += "\n<div id='" + sId + "Highlight' class='" + sClassPrefix + "MenuItemHighlight'>" + sText + "</div>";
        }else{
            //create the menu item
            var sMenuItem = "\n<div id='" + sId + "' class='" + sClassPrefix + "MenuItem' onMouseover=\"DM_activeMenus.highlightOn('" + sId + "');\" onMouseout=\"DM_activeMenus.highlightOff('" + sId + "');\" onclick=" + sOnclick + ">" + sText + "</div>";
        }
    }
    
    if (bIsNS4 || bIsMac){
        //create the cover
        sMenuItem += "\n<div id='" + sId + "Cover' class='MenuItemCover'><a href=\"" + sURL + "\""+sTarget+" onMouseover=\"DM_activeMenus.highlightOn('" + sId + "');\" onMouseout=\"DM_activeMenus.highlightOff('" + sId + "');\"><img src='" + siteUrl + this.spacerURL + "' height='100%' width='100%' border='0'></a></div>";
    }
    this.html = sMenuItem;//write the menu to the page
}

function getMenuItemWidth(){
    var iWidth = this.width;
    
    if (!iWidth){
        iWidth = getWidth(this.object);
    }
    return iWidth;
}

function createMenuItemObjects(){
    var bIsIE = mBrowser.isIE;
    var bIsIE4 = mBrowser.isIE4;
    var bIsNS = mBrowser.isNS;
    var bIsNS4 = mBrowser.isNS4;
    var bIsMac = mBrowser.isMac;
    
    if (this.ready){
        return;
    }
    
    var sId = this.id;
    var iHeight = this.iHeight;
    var newWindow = this.newWindow;
    
    var oThis = getObj(sId);
    this.object = oThis;
    this.styleObj = getStyleObj(sId);
    if (bIsNS4 || bIsMac){  
        var sHighlightId = sId + "Highlight";
        var sCoverId = sId + "Cover";
        var oHighlight = getObj(sHighlightId);
        var oCover = getObj(sCoverId);
        this.highlightStyleObj = getStyleObj(sHighlightId);
        this.coverStyleObj = getStyleObj(sCoverId);
    }
    
    var iHeightSingle = this.heightSingle;
    var iHeightSingleTextLimit = this.heightSingleTextLimit;
    if (this.text.length > iHeightSingleTextLimit){
        iHeight = 2;
    }
    if (bIsNS || bIsMac || bIsIE4){
        switch (iHeight){
            case 2:
                var iHeightDouble = this.heightDouble;
                setHeight(this.object,iHeightDouble);
                if (bIsNS4 || bIsMac){
                    setHeight(oHighlight,iHeightDouble);
                    setHeight(oCover,iHeightDouble);
                }
                //this.height = iHeightDouble;
                this.height = getHeight(this.object);
                break;
            default:
                setHeight(this.object,iHeightSingle);
                if (bIsNS4 || bIsMac){
                    setHeight(oHighlight,iHeightSingle);
                    setHeight(oCover,iHeightSingle);
                }
                //this.height = iHeightSingle;
                this.height = getHeight(this.object);
                break;
        }
    }else{
        setHeight(oThis,iHeightSingle);
        this.height = getHeight(oThis);
    }
    this.ready = true;
}

//addSubMenu: creates a submenu and associates it with a menu item
function addSubmenu(sMenuAnchor,sParentAnchor){
    var sId = this.id;
    var oMenuset = this.menu.menuset;
    
    var oSubmenu = new menu(sId+"SM",sId,oMenuset,sMenuAnchor,sParentAnchor);
    oMenuset.appendMenu(oSubmenu);
    this.subMenu = oSubmenu;
    this.hasSubMenu = true;
    this.createHTML();
    
    return oSubmenu;
}

/* ------------------------------------------
Function name  - sb_setTopNav
Description - Initializes the top nav
------------------------------------------  */
function sb_setTopNav(showHome) {
    var topNavMappings = getTopNavMappings();
    var currentPage = window.locationOverride ? locationOverride:new String(document.location);
    var topNavIndex = -1;   
    // Search through the topNavMappings for the current area
    // Highlight the correct Top Nav Image if the current area is found
    for (c=0;c<topNavMappings.imageCollection.length;c++) {
        var dirName = new String(topNavMappings.imageCollection[c].dirName);
        //alert("cp:"+currentPage+" dn:"+dirName+" c:"+c+" sh:"+showHome);
        if ((currentPage.indexOf(dirName) != -1) && !((c == 0) && (showHome))){
            section = topNavMappings.imageCollection[c].divId;
            topNavIndex = c;
            break;
            //return;
        } else if ((c == 0) && (showHome)){
            var dirFolder = dirName.substring(0, dirName.lastIndexOf("/"));
            if (dirFolder.indexOf("/") ==  0) {
                dirFolder = dirFolder.substring(1);
            }
            
            var currentFolder = currentPage.substring(0, currentPage.lastIndexOf("/"));
            if (currentFolder.indexOf("http://") >  -1) {
                currentFolder = currentFolder.substring(currentFolder.indexOf("http://")+7);
                if (currentFolder.indexOf("/") >  -1) {
                    currentFolder = currentFolder.substring(currentFolder.indexOf("/")+1);
                } else {
                    currentFolder = "";
                }
            }   
            if (currentFolder.indexOf("htdocs/") >  -1) {
                currentFolder = currentFolder.substring(currentFolder.indexOf("htdocs/")+6);
            }   
            
            if (currentFolder == dirFolder) {   
                section = topNavMappings.imageCollection[c].divId;
                topNavIndex = c;
                break;
                //return;
            }
        }
    }
    
    if (topNavIndex > -1) {
        DM_activeMenus.currLocation = topNavMappings.imageCollection[topNavIndex].divId;
        topNavImage = getObj(topNavMappings.imageCollection[topNavIndex].imageId);
        oldSrc = topNavImage.src;
        topNavImage.src = topNavMappings.imageCollection[topNavIndex].onSrc;
        
        // Reset and MM_swapImgRestore image src
        a=document.MM_sr; 
        
        for(i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) {
        //  alert("i = "+i+"\nx.oSrc = "+x.oSrc);
            if (x.oSrc == oldSrc) {
                x.oSrc = topNavMappings.imageCollection[topNavIndex].onSrc;
            }
        }
    }
}

