//==============================================================================
// Main Routine
//==============================================================================
var goBPHS;

if (goBPHS == null) {
    var newLineChar = String.fromCharCode(10);
    var ie4 = document.all&&navigator.userAgent.indexOf("Opera")==-1;
    var ns6 = (document.getElementById && !document.all) || (navigator.userAgent.indexOf("Opera") != -1);
    var ToolBar_Supported = (ie4 || ns6)? true : false;
    var goBPSearchMenu;
    var goBPMenu;
    var goNav;
    var oNav2Menu = null;
    var oNav1Menu = null;
    var g_Host = "www.prioryhigh.lancs.sch.uk";  // Host for templates
    var g_Path = "/"; // Path from root to header2.js
    var g_Build = "Version 5.5.0";

    var arrBreadCrumbMapItem = null;
    
    //Change This URL to the URL of the website
	var pageIndex = "http://www.prioryhigh.lancs.sch.uk/";
	var pageURL = "http://www.prioryhigh.lancs.sch.uk/pages/";
	

    _BPHSInitBPMenu();
    _BPHSInitBPSearchMenu();
    _BPHSInitGlobals();
    _BPHSInitHorizontalNav();
    _BPHSInitLeftNav();
}
//==============================================================================
// Internal APIs
//==============================================================================

//==============================================================================
// Function: _BPHSInitBPMenu()
// Description: Initialize the BP menu object
// Inputs: None
// Return: None
//==============================================================================
function _BPHSInitBPMenu() {
    goBPMenu = new Array();
    goBPMenu.menuString = "<div id='idMenuPane' style='position:absolute;top:0;left:0;height:0;' nowrap><!--BP_MENU_TITLES--></div>";
}

//==============================================================================
// Function: _BPHSInitBPSearchMenu()
// Description: Initialize the Stafffinder/Search object
// Inputs: None
// Return: None
//==============================================================================
function _BPHSInitBPSearchMenu() {
    goBPSearchMenu = new Array();
    goBPSearchMenu.searchStaffFinderPage = "http://www.prioryhigh.lancs.sch.uk";
    goBPSearchMenu.searchBPPage = "http://www.prioryhigh.lancs.sch.uk";
    goBPSearchMenu.siteSearchEnabled = false;
    goBPSearchMenu.siteSearchSID = "";
    goBPSearchMenu.siteSearchPage = "http://www.prioryhigh.lancs.sch.uk";
    goBPSearchMenu.siteSearchCaption = "This Site";
}

//==============================================================================
// Function: _BPHSInitGlobals()
// Description: Initialize the Global object
// Inputs: None
// Return: None
// Notes: sets up information wrt to banner and footer
//==============================================================================
function _BPHSInitGlobals() {
    goBPHS = new Array();
    goBPHS.enableNav1Menu = false;
    goBPHS.enableLeftNavMenu = true;
    goBPHS.menuDropDown = true;
    goBPHS.lockMenu = false;
    goBPHS.versionNumber = "";
    goBPHS.pageRevision = "";
    goBPHS.bannerName = "Burscough Priory Science College";
    goBPHS.bannerDrawn = false;
    goBPHS.homePage = "http://www.prioryhigh.lancs.sch.uk";
	goBPHS.pagesDir = "http://www.prioryhigh.lancs.sch.uk/pages/";
    goBPHS.BPComPage = "http://www.prioryhigh.lancs.sch.uk/images/";
    goBPHS.loginEnabled = false;
    goBPHS.loggedIn = _BPHSIsLoggedIn();
    goBPHS.enablePortalImage = false;
    goBPHS.enableMyLinks = true;
    goBPHS.enableFullCSS = true;

    if (location.protocol == "file:")
        {goBPHS.pageProtocol = "http://";}
    else
        {goBPHS.pageProtocol = location.protocol + "//";}

    goBPHS.libPath = goBPHS.pageProtocol + g_Host + g_Path;
    goBPHS.images = goBPHS.libPath + "images/";
	goBPHS.flash = goBPHS.libPath + "flash/";
    goBPHS.warningMsg = "";
    goBPHS.warningMsgGlobal = ""; 
    goBPHS.greetingMsg = "";

    if (ie4)
        {document.write("<link rel='stylesheet' type='text/css' href='" + goBPHS.libPath + "css/header.css'>");}
    else
        {document.write("<link rel='stylesheet' type='text/css' href='" + goBPHS.libPath + "css/header_mozilla.css'>");}

    document.write("<link rel='stylesheet' type='text/css' href='" + goBPHS.libPath + "css/banner_color.css'>");

 
    //Footer info
    goBPHS.footerDrawn = false;
    goBPHS.privacyLabel = "Privacy Statement";
    goBPHS.privacyPage = "javascript:_BPHSOpenWindow(\"http://www.prioryhigh.lancs.sch.uk/pages/legal_stuff/privacy_statement.htm\", \"Privacy Statement\");";
    goBPHS.feedbackLabel = "Feedback";
    goBPHS.feedbackTarget = "";
    goBPHS.copyright = "Copyright &copy; " + new Date().getFullYear() + " Burscough Priory Science College";
    goBPHS.securityLabel = "";
    goBPHS.supportLabel = "Webmaster";
    goBPHS.supportTarget = "";
    goBPHS.webMetrics = false;

    goNav = new Array();
    goNav.breadCrumbLinkMenuID = ""
    goNav.breadCrumbMenuID = ""
    goNav.breadCrumbNav1 = "";
    goNav.breadCrumbNav2 = "";
    goNav.breadCrumbNav3 = "";
    goNav.breadCrumbLabel = "";
    goMenu = new Array();
}

//==============================================================================
// Function: _BPHSInitHorizontalNav()
// Description: Initialize the horizontal navigation
// Inputs: None
// Return: None
// Notes: sets up object to display and organize top
//              navigation
//==============================================================================
function _BPHSInitHorizontalNav() {
    goNav.menuString1 = "<table border=0 cellpadding=0 cellspacing=0 width='100%'> " +
                                    "<tr>" +
                                        "<td width=5><img src='" + goBPHS.images + "spacer.gif' height=20 width=5 border=0></td>" +
                                        "<!--LD_MENU_TITLES-->" +
                                        "<td class='nav1Filler' width='100%'></td>" +
                                        "<td width=5><img src='" + goBPHS.images + "spacer.gif' height=20 width=5 border=0></td>" +
                                    "</tr>" +
                                "</table>";

    goNav.menuString = "";
}

//==============================================================================
// Function: _BPHSInitLeftNav()
// Description: Initialize the Left Navigation
// Inputs: None
// Return: None
// Notes: sets up object to display and organize left
//              hand navigation
//==============================================================================
function _BPHSInitLeftNav() {
    var aLeftNav = new Array();
    var aOpenLeftItems = new Array();

    aLeftNav.width = 151;
    aLeftNav.enabled = true;

    aLeftNav.openItems = aOpenLeftItems;
    goNav.leftNav = aLeftNav;
    goNav.leftNavString = "";

    plus = new Image();
    plus.src = goBPHS.images + "/Icons_Bits/plus.gif";

    minus = new Image();
    minus.src = goBPHS.images + "/Icons_Bits/minus.gif";
}

//==============================================================================
// Function: _BPHSGetCookieVal(iOffset)
// Description: returns the value of a cookie starting at a
//                      specified offset
// Inputs: iOffset - The starting position to read the value
//                          from the cookie string
// Return: Value of requested attribute
//==============================================================================
function _BPHSGetCookieVal(iOffset) {
    var iEnd = document.cookie.indexOf (";", iOffset);

    if (iEnd == -1) {
        iEnd = document.cookie.length;
    }
    return unescape(document.cookie.substring(iOffset, iEnd));
}

//==============================================================================
// Function: _BPHSGetCookie(sCookieName)
// Description: return the value of a cookie
// Inputs: sCookieName - name of cookie attribute
// Return: Value of requested attribute or NULL, if attribute
//              does not exist
//==============================================================================
function _BPHSGetCookie(sCookieName) {
    var sArg = sCookieName + "=";
    var iArgLen = sArg.length;
    var iCookieLen = document.cookie.length;
    var iCookieIndx = 0;
    var iCookie = null;

    while (iCookieIndx < iCookieLen) {
        iCookie = iCookieIndx + iArgLen;
        if (document.cookie.substring(iCookieIndx, iCookie) == sArg) {
            return _BPHSGetCookieVal(iCookie);
        }

        iCookieIndx = document.cookie.indexOf(" ", iCookieIndx) + 1;
        if (iCookieIndx == 0)
            break;
    }
    return null;
}


//==============================================================================
// Function: _BPHSSetSessionCookie(sCookieName, sValue)
// Description: Sets the named cookie to the named value for the life of the session
// Inputs: sCookieName - name of cookie attribute
//         sValue - value of the cookie attribute
// Return: None
//==============================================================================
//function _BPHSSetSessionCookie(sCookieName, sValue) {
//   document.cookie = sCookieName + "=" + sValue;
//}


//==============================================================================
// Function: _BPHSIsLoggedIn()
// Description: Checks to see if a user is logged in
// Inputs: None
// Return: true if user is logged into the portal
//            otherwise false
//==============================================================================
function _BPHSIsLoggedIn() {
    var sCode = _BPHSGetCookie("SMSESSION");

    if (sCode != null && sCode != "LOGGEDOFF") {
        return true;
    }
    return false;
}

//==============================================================================
// Function: _BPHSOpenWindow(sURL, sName)
// Description: Opens a new browser window with the requested
//                      content
// Inputs: sURL - URL of the page you want displayed in the new
//                      window
//            sName - Name of the window
// Return: None
//==============================================================================
function _BPHSOpenWindow(sURL, sName) {
    var sLoc = "width=600,height=500,left=350,top=0";
    var sOpts;
    var oRemote;

    if (_BPHSOpenWindow.arguments.length > 2) {
        sLoc = _BPHSOpenWindow.arguments[2];
    }

    sOpts= sLoc + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1";
    oRemote = window.open('','sName', '', sOpts);
    oRemote.location.href = sURL;
    if (!oRemote.opener) {
        oRemote.opener = self;
    }
}

//==============================================================================
// Function: _BPHSGoButton()
// Description: Submit appropriate form
// Inputs: None
// Return: None
// Notes: User has pressed GO button for site search or BP intranet
//==============================================================================
function _BPHSGoButton(sSearchType) {

    if (sSearchType == "frmSiteSearch") {
        // Check if site search is enabled.
        if (goBPSearchMenu.siteSearchEnabled) {
            // Check if we are doing a site search or BP intranet search
            if (document.frmSiteSearch.siteSearch1.checked) {
                // Site search
                document.frmSiteSearch.action = goBPSearchMenu.siteSearchPage;
            } else {
                // BP search
                document.frmSiteSearch.action = goBPSearchMenu.searchBPPage;
            }
        }
    }
    return true;
}

//==============================================================================
// Function: _BPHSCreateMenu(sMenuID, sMenuDefObject, sMenuDisplay, sMenuURL, sTarget)
// Description: Internal Call - Create Top Level Menu (Level 1)
// Inputs: sMenuID - ID of menu to link 2nd level items
//            sMenuDefObject - Menu Definition Object (goNav)
//            sMenuDisplay - Title of menu item
//            sMenuURL - link for the menu item
//            sTarget - target location for document to be displayed
// Return: None
//==============================================================================
function _BPHSCreateMenu(sMenuID, sMenuDefObject, sMenuDisplay, sMenuURL, sTarget) {
    var obj = eval(sMenuDefObject);
    var sTag  = "<!--LD_MENU_TITLES-->";
    var sMenu = newLineChar;
    var sLinkMenuID = "AM_" + sMenuID;
    var sClassName;

    goBPHS.enableNav1Menu = true;

    // Find out if the menu matches the bread crumb.
    if (sMenuDisplay == goNav.breadCrumbNav1) {
        goNav.breadCrumbMenuID = sMenuID;
        goNav.breadCrumbLinkMenuID = sLinkMenuID;
        sClassName = "nav1Down";
    } else {
        if (sMenuDisplay == "Help") {
            sClassName = "nav1UpHelp";
        } else {
            sClassName = "nav1Up";
        }
    }

//  sMenu += "<td><div style='position:relative' onmouseout=\"_BPHSDelayHideMenu();\" " +
//              "onmouseover=\"_BPHSDoMenu(event, '" + sLinkMenuID + "', '" + sMenuID +
//              "');\"><table border=0 cellspacing=0 cellpadding=0 height=20><tr><td class='" +
//              sClassName + "' ID='" + sLinkMenuID + "' nowrap valign='middle'><a id='idLocalNav'";


    sMenu += "<td><div style='position:relative' ><table border=0 cellspacing=0 cellpadding=0 height=20><tr><td  class='" +
                sClassName + "' ID='" + sLinkMenuID + "' nowrap valign='middle'><a id='idLocalNav' onmouseout=\"_BPHSDelayHideMenu();\" " +
                "onmouseover=\"_BPHSDoMenu(event, '" + sLinkMenuID + "', '" + sMenuID +
                "');\"";

    if (sMenuURL != "") {
        sMenu += " target=''" + " href='" + sMenuURL + "'>";
    }else {
        sMenu += " style='cursor:default' href=\"javascript:void();\" onclick=\"window.event.returnValue=false;\">";
    }

    sMenu += "&nbsp;&nbsp;" + sMenuDisplay + "&nbsp;&nbsp;</a></td></tr></table></div></td>" +
            "<td><img src='" + goBPHS.images + "spacer.gif' height=20 width=2 border=0></td>" +
            sTag;

    obj.menuString1 = obj.menuString1.replace(sTag, sMenu);
}

//==============================================================================
// Function: _BPHSHideMenu
// Description: hide the dropdown menu
// Inputs: None
// Return: None
//==============================================================================
function _BPHSHideMenu() {
    var oBreadCrumbNav2Menu;


    // Check if we have a nav2 menu.
    if (oNav2Menu) {
        oBreadCrumbNav2Menu = document.getElementById(goNav.breadCrumbMenuID);

        // Check if this a vertical dropdown nav
        if (goBPHS.menuDropDown) {
            // It is, set the bread crum nav2 object to null.
            oBreadCrumbNav2Menu = null;
            if (ie4) {
                _BPHSShowElement("SELECT");
                _BPHSShowElement("OBJECT");
                _BPHSShowElement("IFRAME");
            }
        }

        if (oBreadCrumbNav2Menu == null) {
            oNav2Menu.thestyle.visibility = (ie4||ns6)? "hidden" : "hide";
            oNav2Menu.innerHTML = "";
        } else {
            oNav2Menu.innerHTML = oBreadCrumbNav2Menu.innerHTML;
        }


        // Reset the nav1 to up.
        if (oNav1Menu) {
            // Do not change the class setting if this matches the nav1 bread crumb.
            var oBreadCrumbNav1Menu = document.getElementById(goNav.breadCrumbLinkMenuID);

            if (oNav1Menu != oBreadCrumbNav1Menu) {
                if (oNav1Menu.innerText == "  Help  ")
                    oNav1Menu.className = "nav1UpHelp";
                else
                    oNav1Menu.className = "nav1Up";
            }
        }
    }
}

//==============================================================================
// Function: _BPHSContainsNS6
// Description: Determines if 1 element in contained in another
// Inputs: a - element
//         b - element
// Return: None
//==============================================================================
function _BPHSContainsNS6(a, b) {
    while (b.parentNode)
    {
        if ((b = b.parentNode) == a) {
            return true;
        }
    }
    return false;
}

//==============================================================================
// Function: _BPHSDynamicHide
// Description: Sets the delay for the hiding of the menu.
// Inputs: e - event
// Return: None
//==============================================================================
function _BPHSDynamicHide(e){
    if (ie4&&!oNav2Menu.contains(e.toElement))
        _BPHSDelayHideMenu();
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !_BPHSContainsNS6(e.currentTarget, e.relatedTarget))
        _BPHSDelayHideMenu();

}

//==============================================================================
// Function: _BPHSDelayHideMenu
// Description: Sets the timeout to hide the menu.
// Inputs: None
// Return: None
//==============================================================================
function _BPHSDelayHideMenu(){
	var iDelay = 1500;

	if (goBPHS.menuDropDown)
		iDelay = 250;

   if (ie4||ns6)
		delayhide=setTimeout("_BPHSHideMenu()", iDelay);
}

//==============================================================================
// Function: _BPHSClearHideMenuTimeout
// Description: Clears the timeout to hide the menu.
// Inputs: None
// Return: None
//==============================================================================
function _BPHSClearHideMenuTimeout(){
    if (window.delayhide)
        clearTimeout(delayhide);
}

//==============================================================================
// Function: _BPHSHighlightNav2Menu
// Description: Highlights a link within the nav2 menu.
// Inputs: e - event element
//         state - state of the element
// Return: None
//==============================================================================
function _BPHSHighlightNav2Menu(e, state){
    var source_el;

    if (document.all)
        source_el=event.srcElement;
    else if (document.getElementById)
        source_el=e.target;

    if (source_el.className=="nav2menuitem"){
        //source_el.id=(state=="on")? "nav2Down" : "";
        if (state=="on") {
            source_el.id = "nav2DownHover";
        } else {
            if (source_el.innerText == "  " + goNav.breadCrumbNav2 + "  ") {
                source_el.id = "nav2Down";
            } else {
                source_el.id = "";
            }
        }
    }
    else{
        while(source_el.id!="popmenu"){
            source_el=document.getElementById? source_el.parentNode : source_el.parentElement;

            if (source_el.className=="nav2menuitem"){
                //source_el.id=(state=="on")? "nav2Down" : "";
                if (state=="on") {
                    source_el.id = "nav2DownHover";
                } else {
                    if (source_el.innerText == "  " + goNav.breadCrumbNav2 + "  ") {
                        source_el.id = "nav2Down";
                    } else {
                        source_el.id = "";
                    }
                }
            }
        }
    }
}

//==============================================================================
// Function: _BPHSClickDoMenu(e, sMenuID)
// Description: Build 2nd level of Navigation (DropDown)
// Inputs: sMenuID - ID of menu
// Return: True if built correctly otherwise false
//==============================================================================
function _BPHSClickDoMenu(e, sLinkMenuID, sMenuID) {

    _BPHSDoMenu(e, sLinkMenuID, sMenuID, true);
    goBPHS.lockMenu = true;
}

//============================================================================
// Function: _BPHSDoMenu(e, sMenuID)
// Description: Build 2nd level of Navigation (DropDown)
// Inputs: sMenuID - ID of menu
// Return: True if built correctly otherwise false
//==============================================================================
function _BPHSDoMenu(e, sLinkMenuID, sMenuID) {
    var eventX;
    var eventY;
    var nav1Height = 20;

    var oMenu = document.getElementById(sMenuID);
    var oSelectedNav1Menu = document.getElementById(sLinkMenuID);
    var oBreadCrumbNav1Menu = document.getElementById(goNav.breadCrumbLinkMenuID);

    // Set the selected menu as down.
    oSelectedNav1Menu.className = "nav1DownHover";
    //oSelectedNav1Menu.className = "nav1Down";

    // Check if we have an old nav 1 menu.
    if (oNav1Menu) {
        // Make sure that it doesn't match the selected one.
        if (oNav1Menu != oSelectedNav1Menu) {
            // Do not change the class setting if this matches the nav1 bread crumb.
            if (oNav1Menu != oBreadCrumbNav1Menu) {
                // Change it to nav1up.
                if (oNav1Menu.innerText == "  Help  ")
                    oNav1Menu.className = "nav1UpHelp";
                else
                    oNav1Menu.className = "nav1Up";
            } else {
                oNav1Menu.className = "nav1Down";
            }
        }
    }


    // Now remember the menu we just set down.
    oNav1Menu = oSelectedNav1Menu;

    if (oMenu == null) {
        window.event.cancelBubble = true;
        //HG force the 2nd row to be blank without the delay associated with 2nd level
        oMenu = new Array();
        oMenu.innerHTML = "<table></table>";
//      return false;
    }

    if (!document.all&&!document.getElementById&&!document.layers)
        return;


    _BPHSClearHideMenuTimeout();


    oNav2Menu=ie4? document.all.popmenu : document.getElementById("popmenu");
    oNav2Menu.thestyle=oNav2Menu.style;
    oNav2Menu.innerHTML=oMenu.innerHTML;

    if (goBPHS.menuDropDown) {
        if (ie4) {
            _BPHSShowElement("SELECT");
            _BPHSShowElement("OBJECT");
            _BPHSShowElement("IFRAME");
        }

        oNav2Menu.contentwidth=oNav2Menu.offsetWidth;
        oNav2Menu.contentheight=oNav2Menu.offsetHeight;

        if (ie4) {
            eventX = event.clientX - event.offsetX - 2;
            eventY = (event.clientY + nav1Height) - event.offsetY - 1;
        } else if (ns6) {
            eventX = e.pageX - e.layerX;
            eventY = e.pageY - e.layerY + 21;
        }

        //Find out how close the mouse is to the corner of the window
        var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX;
        var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY;

        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge < oNav2Menu.contentwidth) {
            //move the horizontal position of the menu to the left by it's width
            oNav2Menu.thestyle.left=ie4? document.body.scrollLeft+eventX+event.srcElement.offsetWidth-oNav2Menu.contentwidth : window.pageXOffset+eventX+e.currentTarget.offsetWidth-oNav2Menu.contentwidth;
        } else {
            //position the horizontal position of the menu where the mouse was clicked
            oNav2Menu.thestyle.left=ie4? document.body.scrollLeft+eventX : window.pageXOffset+eventX;
        }

        //same concept with the vertical position
        if (bottomedge < oNav2Menu.contentheight) {
            oNav2Menu.thestyle.top=ie4? document.body.scrollTop+eventY-oNav2Menu.contentheight : window.pageYOffset+eventY-oNav2Menu.contentheight;
        } else {
            oNav2Menu.thestyle.top=ie4? document.body.scrollTop+eventY : window.pageYOffset+eventY;
        }

        if (ie4) {
            _BPHSHideElement(oNav2Menu, "SELECT");
            _BPHSHideElement(oNav2Menu, "OBJECT");
            _BPHSHideElement(oNav2Menu, "IFRAME");
        }
    }

    if ((oNav2Menu.innerText == "") && (goBPHS.menuDropDown))
        oNav2Menu.thestyle.visibility = (ie4||ns6)? "hidden" : "hide";
    else
        oNav2Menu.thestyle.visibility="visible";

    return false;
}

//============================================================================
// Function: _BPHSHideElement(elmID)
// Description: Hide Elements on screen when displaying vertical dropdown
// Inputs: elmID - Element Type to hide
// Return:
//==============================================================================
function _BPHSHideElement(oNav2Menu, elmID) {
	var i=0, obj, objLeft, objTop, objParent;
	var iNavTop, iNavLeft;

	iNavTop = oNav2Menu.thestyle.pixelTop;
	iNavLeft = oNav2Menu.thestyle.pixelLeft;

	for (i = 0; i < document.all.tags(elmID).length; i++) {
		obj = document.all.tags(elmID)[i];
		if (!obj || !obj.offsetParent) {
			continue;
		}

		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;

		if( (objLeft==0) || (objTop==0))
			{
		while (objParent.tagName.toUpperCase() != "BODY") {
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}

		if ((objTop < (iNavTop + oNav2Menu.contentheight)) &&
			(objLeft > iNavLeft) ||
			(objLeft > (iNavLeft + oNav2Menu.contentwidth))) {
				obj.style.visibility = (ie4||ns6)? "hidden" : "hide";
				// Set BPHSHide = false to fix bug #4
				obj.style.visibility="visible"
				obj.style.BPHSHide =false;
			}
			else
			//  COMMENTED if condition to hide content when submentu exists
			//if((oNav2Menu.contentheight > oNav2Menu.contentwidth) &&
			//	(objLeft < iNavLeft) ||
			//        (objLeft > (iNavLeft + oNav2Menu.contentwidth)))
			{
				obj.style.visibility = (ie4||ns6)? "hidden" : "hide";
				obj.style.BPHSHide = true;
			}

			if ((objTop < (iNavTop + oNav2Menu.contentheight)) &&
			    ((objLeft + obj.clientWidth) > iNavLeft) &&
			    ((objLeft + obj.clientWidth) < (iNavLeft + oNav2Menu.contentwidth))) {
				obj.style.visibility = (ie4||ns6)? "hidden" : "hide";
				obj.style.BPHSHide = true;
			} else if (objTop > (iNavTop + oNav2Menu.contentheight)) {
				return ;
			}

		}
		// For select statement
		if( (objLeft==1) || (objTop==1))
		{
			while (objParent.tagName.toUpperCase() != "BODY") {
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}

			if ((objTop < (iNavTop + oNav2Menu.contentheight)) &&
			    (objLeft > iNavLeft) &&
			    (objLeft < (iNavLeft + oNav2Menu.contentwidth))) {
				obj.style.visibility = (ie4||ns6)? "hidden" : "hide";
				obj.style.BPHSHide = true;
			} else if ((objTop < (iNavTop + oNav2Menu.contentheight)) &&
			    ((objLeft + obj.clientWidth) > iNavLeft) &&
			    ((objLeft + obj.clientWidth) < (iNavLeft + oNav2Menu.contentwidth))) {
			    	obj.style.visibility = (ie4||ns6)? "hidden" : "hide";
				obj.style.BPHSHide = true;
			} else if (objTop > (iNavTop + oNav2Menu.contentheight)) {
				return ;
			}
		}
	}
}


//============================================================================
// Function: _BPHSShowElement(elmID)
// Description: Show Elements on screen when removing the vertical dropdown
// Inputs: elmID - Element Type to show
// Return:
//==============================================================================
function _BPHSShowElement(elmID) {
    var i=0, obj;

    for (i = 0; i < document.all.tags(elmID).length; i++) {
        obj = document.all.tags(elmID)[i];
        if (!obj)
            continue;

        if (obj.style.BPHSHide) {
            obj.style.visibility = "visible";
            obj.style.BPHSHide = false;
        }
    }
}


//==============================================================================
// Function: _BPHSAddMenuItem(sMenuID, sMenuDefObject, sSubMenu, sSubMenuURL, sTarget)
// Description: Associates this "sub-menu" item to the specified menu item for
//                   the top horizontal navigation
// Inputs:  sMenuID - ID of menu item
//              sMenuDefObject - Object to add item to (global top nav obj - goNav)
//              sSubMenu - Label
//              sSubMenuURL - URL
//              sTarget - target location for document to be displayed
// Return:  None
//==============================================================================
function _BPHSAddMenuItem(sMenuID, sMenuDefObject, sSubMenu, sSubMenuURL, sTarget) {
    var obj = eval(sMenuDefObject);
    var sMenuString = obj.menuString;
    var sURL = sSubMenuURL;
    var sMenuType = "idLocalNav";
    var sLookUpTag  = "<!--" + sMenuID + "-->";
    var iPos = sMenuString.indexOf(sLookUpTag);
    var sTemp = newLineChar;

    if (iPos <= 0) {
        sMenuString += newLineChar +
                newLineChar +
                "<div id='" + sMenuID + "' " +  " style='display:none;'>";
    }

    if (sURL) {
        sTemp += "<div class='nav2menuitem'><a id=\"" + sMenuType + "\" target=\"" + sTarget + "\" ";

        if (sMenuType == "idSearchMenu")
            sTemp += " onclick=\"" + sURL + "\" ";
        else
            sTemp += " href='" + sURL + "' ";

        sTemp += ">" + sSubMenu + "</a></div>";
    } else {
        sTemp += "<label>" + sSubMenu + "</label>";
    }

    sTemp += sLookUpTag;

    if (iPos <= 0) {
        sMenuString += sTemp + "</div>";
    }
    else {
        sMenuString = sMenuString.replace(sLookUpTag, sTemp);
    }

    if (sMenuType == "idLocalNav")
        goNav.menuString = sMenuString;
    else
        goBPMenu.menuString = sMenuString;
}

//==============================================================================
// Function: _BPHSAddHorMenuItem(sMenuID, sMenuDefObject, sSubMenu, sSubMenuURL, sTarget)
// Description: Associates this "sub-menu" item to the specified menu item for
//                   the top horizontal navigation
// Inputs:  sMenuID - ID of menu item
//              sMenuDefObject - Object to add item to (global top nav obj - goNav)
//              sSubMenu - Label
//              sSubMenuURL - URL
//              sTarget - target location for document to be displayed
// Return:  None
// Notes: Builds 2nd horizontal menu items
//==============================================================================
function _BPHSAddHorMenuItem(sMenuID, sMenuDefObject, sSubMenu, sSubMenuURL, sTarget) {
    var obj = eval(sMenuDefObject);
    var sMenuString = obj.menuString;
    var sURL = sSubMenuURL;
    var sMenuType = "idLocalNav";
    var sLookUpTag  = "<!--" + sMenuID + "-->";
    var iPos = sMenuString.indexOf(sLookUpTag);
    var sTemp = newLineChar;

    if (sURL) {
        if (iPos <= 0) {
            sMenuString += newLineChar +
                    newLineChar +
                    "<div id='" + sMenuID + "' " +  " style='display:none;'>" +
                    "<table border=0 width='100%' cellspacing=0 cellpadding=0><tr>";
        }

        // Check if this is bread crumb nav2.
        if ((sMenuID == goNav.breadCrumbMenuID) & (sSubMenu == goNav.breadCrumbNav2)){
            sTemp += "<td><div class='nav2menuitem' id='nav2Down'><table border=0 cellpadding=0 cellspacing=0><tr><td nowrap height=20><a id='" + sMenuType + "' target=\"" + sTarget + "\" ";
        } else {
            //if (sMenuID == goNav.breadCrumbMenuID) {
                sTemp += "<td><div class='nav2menuitem'><table border=0 cellpadding=0 cellspacing=0><tr><td nowrap height=20><a id='" + sMenuType + "' target=\"" + sTarget + "\" ";
            //} else {
            //  sTemp += "<td><div class='nav2menuitem' id='nav2DownHover'><table border=0 cellpadding=0 cellspacing=0><tr><td nowrap height=20><a id='" + sMenuType + "' target=\"" + sTarget + "\" ";
            //}
        }

        if (sMenuType == "idSearchMenu")
            sTemp += " onclick=\"" + sURL + "\" ";
        else
            sTemp += " href='" + sURL + "' ";

        sTemp += ">&nbsp;&nbsp;" + sSubMenu + "&nbsp;&nbsp;</a></td></tr></table></div></td>" +
        "<td bgcolor='#FFFFFF'><img src='" + goBPHS.images + "spacer.gif' height=0 width=2 border=0></td>" +
        sLookUpTag;

        if (iPos <= 0) {
            sMenuString += sTemp + "<td width='100%'>&nbsp;</td></tr></table></div>";
        }
        else {
            sMenuString = sMenuString.replace(sLookUpTag, sTemp);
        }

        if (sMenuType == "idLocalNav") {
            goNav.menuString = sMenuString;
        } else {
            goBPMenu.menuString = sMenuString;
        }
    }
}

//==============================================================================
// Function: _BPHSAddMenuSeparator(sMenuID, sMenuDefObject)
// Description: Associates the separator of this "sub-menu" item to the specified
//                   menu item for the top horizontal navigation
// Inputs: sMenuID - ID of Menu to place separator in
//            sMenuDefObject - Object to add item to (goNav)
// Return: None
//==============================================================================
function _BPHSAddMenuSeparator(sMenuID, sMenuDefObject) {
    var obj = eval(sMenuDefObject);
    var sLookUpTag = "<!--" + sMenuID + "-->";
    var sMenuString, sTemp;

    sMenuString = obj.menuString

    var iPos = sMenuString.indexOf(sLookUpTag);
    if (iPos > 0) {
        sTemp = newLineChar +
                    "<div style='margin-top:4px;margin-bottom:4px;width:100%;height:1px;background-color:white'><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></div>" + sLookUpTag;

        sMenuString = sMenuString.replace(sLookUpTag, sTemp);
    }

    obj.menuString = sMenuString;
}

//==============================================================================
// Function: _BPHSAddNavLink(sSubMenu, sSubMenuURL, sTarget)
// Description: Add NavLinks to the Left Nav Menu (Level 3)
// Inputs: sSubMenu - Left hand menu name
//            sSubMenuURL - URL of menu item
//            Optional sTarget - target location for document to be displayed
// Return: None
//==============================================================================
function _BPHSAddNavLink(sSubMenu, sSubMenuURL, sTarget) {
    var bSelected;

    if (unescape(location.href) == sSubMenuURL || unescape(location.pathname) == sSubMenuURL || sSubMenu == goNav.breadCrumbNav3)
        bSelected = true;

    goNav.leftNavString +=
            "<tr>" +
                "<td align=center valign=top width=16 nowrap>" +
                    "<img align=center src='" + goBPHS.images + "bullet.gif'  vspace=3 height=4 width=4 hspace=3 border=0></td>" +
                "<td valign=top width=100%>";

    if (bSelected) {
        goNav.leftNavString += "<div ID=listItemSelected class='leftNavDownSelected'>" + sSubMenu + "</div>";
    } else {
        goNav.leftNavString += "<a class='leftNavDown' target='" + sTarget +"' href='" + sSubMenuURL + "'>" + sSubMenu + "</a>";
    }
    goNav.leftNavString += "</td></tr>";
}

//==============================================================================
// Function: _BPHSCreateNavExpandingList(sMenuID, sSubMenu, sSubMenuURL, bDefOpen, sTarget)
// Description: Creates a menu item with the ability to expand.
// Inputs: sMenuID - Unique ID for Menu item
//            sSubMenu - String to display for menu Item
//            sSubMenuURL - URL for the link
//              bDefOpen - Flags whether to open or close the list. True - Open List
// Return: None
//==============================================================================
function _BPHSCreateNavExpandingList(sMenuID, sSubMenu, sSubMenuURL, bDefOpen, sTarget) {
    var sLookUpTag  = "<!--" + sMenuID + "-->";
    var sPos = goNav.leftNavString.indexOf(sLookUpTag);

    if (sPos <= 0) {
        goNav.leftNavString +=
                "<tr><td align=center valign=top width=16 nowrap><img src='" + goBPHS.images + (bDefOpen? 'minus.gif':'plus.gif') + "' align='center' height='9' width='9' border=0 id='BTN_" + sMenuID + "' vspace=3 style='cursor:hand;' onclick=\"return _BPHSToggleNavExpandingList('BTN_" + sMenuID + "', 'ITEMS_" + sMenuID + "');\"></td><td valign=top width=100%>";

        if (sSubMenuURL) {
            var bSelected = false;

            if (unescape(location.href) == sSubMenuURL || unescape(location.pathname) == sSubMenuURL || sSubMenu == goNav.breadCrumbNav3)   {
                bSelected = true;
            }

            if(bSelected) {
                goNav.leftNavString +=
                    "<div id=listItemSelected><div class='leftNavDownSelected'>" + sSubMenu + "</div></div>"
            } else {
                goNav.leftNavString +=
                    "<a class='leftNavDown' target='" + sTarget + "' href='" + sSubMenuURL + "' id='" + sMenuID +"' class=clsTocHead >" + sSubMenu + "</a>";
            }
        } else {
            goNav.leftNavString +=  "<div class='leftNavDown' id='idNotALink' >" + sSubMenu + "</div>";
        }

        goNav.leftNavString += "<div id=ITEMS_" + sMenuID + " style='display:" + (bDefOpen? 'block':'none') + "';'><!--" + sMenuID + "--></div></td></tr>";

        if (_BPHSCreateNavExpandingList.arguments.length > 3) {
            if (bDefOpen) {
                goNav.leftNav.openItems[goNav.leftNav.openItems.length] = sMenuID;
            }
        }
    }
}

//==============================================================================
// Function: _BPHSAddNavExpandingListItem(sMenuID, sSubMenu, sSubMenuURL, sTarget, bSubItem)
// Description: Actual association of sub-menu item to an existing left nav menu item (level 4)
// Inputs: sMenuID - Unique ID for Menu item
//            sSubMenu - String to display for menu Item
//            sSubMenuURL - URL for the link
//            sTarget - location to display the
// Return: None
//==============================================================================
function _BPHSAddNavExpandingListItem(sMenuID, sSubMenu, sSubMenuURL, sTarget) {
    var bSelected;

    if (unescape(location.href) == sSubMenuURL || unescape(location.pathname + location.search) == sSubMenuURL || sSubMenu == goNav.breadCrumbNav3) {
        bSelected = true;

        var i=0, bFound=false;
        for (i = 0; i < goNav.leftNav.openItems.length; i++) {
            if (goNav.leftNav.openItems[i] == sMenuID) {
                bFound = true;
                break;
            }
        }

        if (!bFound)
            goNav.leftNav.openItems[goNav.leftNav.openItems.length] = sMenuID;
    }

    var sLookUpTag  = "<!--" + sMenuID + "-->";
    var sTemp = newLineChar + "<div " + (bSelected? ' id=listItemSelected':'') + " >";

    if (bSelected) {
        sTemp += "<div class='leftNavSelected'>" + sSubMenu + "</div></div>" + sLookUpTag;
    } else {
        sTemp += "<a class='leftNav' target='" + sTarget +"' href='" + sSubMenuURL +"'>" + sSubMenu + "</a></div>" + sLookUpTag;
    }

    goNav.leftNavString = goNav.leftNavString.replace(sLookUpTag, sTemp);
}

//==============================================================================
// Function: _BPHSOpenNavExpandingLists()
// Description: Expand Left Nav items
// Inputs: None
// Return: None
//==============================================================================
function _BPHSOpenNavExpandingLists() {
    var iCntr;
    var oList;
    var oBtn;

    for (iCntr = 0; iCntr < goNav.leftNav.openItems.length; iCntr++) {
        oList = document.getElementById("ITEMS_" + goNav.leftNav.openItems[iCntr]);
        oBtn = document.getElementById("BTN_" + goNav.leftNav.openItems[iCntr]);
        oList.style.display = "block";
        oBtn.src = eval("minus.src");
    }
}

//==============================================================================
// Function: _BPHSAddNavImageLink(sSubImage, sSubMenuURL, sSubMenu, sTarget)
// Description: Actual creation of a link that is preceeded by an image
// Inputs: sSubImage - URL of image
//            sSubMenuURL - URL for link
//            sSubMenu - Label for alt tag
//            sTarget - Location to display document
// Return: None
//==============================================================================
function _BPHSAddNavImageLink(sSubImage, sSubMenuURL, sSubMenu, sTarget) {
    var bSelected;

    if (unescape(location.href) == sSubMenuURL || unescape(location.pathname) == sSubMenuURL || sSubMenu == goNav.breadCrumbNav3) {
        bSelected = true;
    }

    goNav.leftNavString += "<tr><td colspan=2><table border=0 cellpadding=0 cellspacing=0><tr>";

    if (bSelected) {
        goNav.leftNavString += "<td><img align=left src='" + sSubImage +"' height=16 width=16 border=0></td><td id=\"listItemSelected\" width=100% class=\"clsTocHead\" id=\"listItemSelected\" style='font-family:Verdana;font-size:10px;font-weight:bold;'>" + sSubMenu + "</td>";
    } else {
        goNav.leftNavString += "<td><a target='" + sTarget +"' href='" + sSubMenuURL + "' ><img align=left src='" + sSubImage +"' height=16 width=16 border=0></a></td><td class=\"leftNavMenuItem\" width=100%><a style='font-family:Verdana;font-size:10px;font-weight:bold;text-decoration:none;' target='" + sTarget +"' href='" + sSubMenuURL + "' class=clsTocHead>" + sSubMenu + "</a></td>";
    }

    goNav.leftNavString += "</tr></table></td></tr>";
}

//==============================================================================
// Function: _BPHSAddNavImage(sSubImage, sSubMenuURL, sSubMenu, sTarget)
// Description: Creates a centered image in the local left vertical
// Inputs: sSubImage - Image URL
//            sSubMenuURL - URL for link
//            sSubMenu - Label for alt tag.
//            sTarget - location to display document
// Return: None
//==============================================================================
function _BPHSAddNavImage(sSubImage, sSubMenuURL, sSubMenu, sTarget) {
    goNav.leftNavString +=
            "<tr><td style=margin-left-width=10px; colspan=2 align=center><a target='" + sTarget +"' href='" + sSubMenuURL + "'><img src='" + sSubImage +"' border=0 ALT='" + sSubMenu + "'></td></a></td></tr>";
}

//==============================================================================
// Function: _BPHSCreateFooter()
// Description: Draws the actual footer
// Inputs: None
// Return: None
//==============================================================================
function _BPHSCreateFooter() {
    var sFooter = "<table width='100%' border=0 cellspacing=0 cellpadding=2>" +
                    "<tr>" +
                        "<td><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
                        "<td width='100%'><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
                        "<td><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
                    "</tr>" +
                    "<tr>" +
                        "<td><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
                        "<td class='footerSkin' width='100%' valign='top' align='middle'>";

    sFooter += "" +
        "<a href='" + goBPHS.privacyPage + "'>" + goBPHS.privacyLabel + "</a>" +
        "&nbsp;|&nbsp;" +
        "<a href='javascript:_BPHSOpenWindow(\"http://www.prioryhigh.lancs.sch.uk/pages/legal_stuff/terms_of_use.htm\", \"Terms of Use\");'>Terms of Use</a>" +
        "&nbsp;|&nbsp;";

  
    // Add the feedback link
    if (goBPHS.feedbackPage.length > 0) {
        sFooter += "<a href='" + goBPHS.feedbackPage + "'";
        if(goBPHS.feedbackTarget.length > 0) {
            sFooter += " target='" + goBPHS.feedbackTarget + "'";
        }

        sFooter += ">" + goBPHS.feedbackLabel + "</a>&nbsp;|&nbsp;";
    }

    // Add the support link
    if (goBPHS.supportPage.length > 0) {
        sFooter += "<a href='" + goBPHS.supportPage + "'";
        if(goBPHS.supportTarget.length > 0) {
            sFooter += " target='" + goBPHS.supportTarget + "'";
        }

        sFooter += ">" + goBPHS.supportLabel + "</a>&nbsp; &nbsp;";
    }

    if (goBPHS.versionNumber != "" )
        sFooter += goBPHS.versionNumber + "&nbsp;|&nbsp;"

    //Add Page Revision to footer
    if (goBPHS.pageRevision != "" )
        sFooter += goBPHS.pageRevision + "&nbsp;|&nbsp;"

    //Display Page security level and Copyright info
    sFooter += goBPHS.securityLabel + "<br><div class='copyright'>" + goBPHS.copyright + "</div>";

//    sFooter += "</td>" +
//            "<td><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
//        "</tr>" +
//        "<tr>" +
//            "<td><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
//            "<td width='100%'><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
//            "<td><img src='" + goBPHS.images + "spacer.gif' width=1 height=1></td>" +
//        "</tr>" +
        "</table>";

    document.writeln(sFooter);
}

//==============================================================================
// Function: _BPHSToggleNavExpandingList(oButton, oItems)
// Description: Open/Closes the specified expanding list from the left nav.
// Inputs: oButton - handle to the image
//            oItems - handle to area that is to be hidden/displayed.
// Return: None
// Notes: returns false (not sure why)
//==============================================================================
function _BPHSToggleNavExpandingList(sButton, sItem) {
    var oButton = document.getElementById(sButton);
    var oItem = document.getElementById(sItem);

    if ((oItem.style.display == "") || (oItem.style.display == "none")) {
        oItem.style.display = "block";
        oButton.src = eval("minus.src");
    } else {
        oItem.style.display = "none";
        oButton.src = eval("plus.src");
    }

    return false;
}


//==============================================================================
// Function: _BPHSBuildMenus()
// Description: Builds HTML for all menus
// Inputs: None
// Return: None
//==============================================================================
function _BPHSBuildMenus() {
    var aMenu;

    for(var i=0; i < goMenu.length; i++) {
        aMenu = goMenu[i];
        switch (aMenu[0]) {
            case "Level1":
                _BPHSCreateMenu(aMenu[1], aMenu[2], aMenu[3], aMenu[4], aMenu[5]);
                break;

            case "Level2":
                if (goBPHS.menuDropDown)
                    _BPHSAddMenuItem(aMenu[1], aMenu[2], aMenu[3], aMenu[4], aMenu[5]);
                else
                    _BPHSAddHorMenuItem(aMenu[1], aMenu[2], aMenu[3], aMenu[4], aMenu[5]);
                break;

            case "Separator":
                if (goBPHS.menuDropDown)
                    _BPHSAddMenuSeparator(aMenu[1], aMenu[2]);
                break;

            case "Level3 - AddNavLink":
                _BPHSAddNavLink(aMenu[1], aMenu[2], aMenu[3]);
                break;

            case "Level3 - AddNavSpacer":
                goNav.leftNavString += "<tr><td colspan=2 height=" + aMenu[1] + ">&nbsp;</td></tr>";
                break;

            case "Level3 - AddNavImage":
                _BPHSAddNavImage(aMenu[1], aMenu[2], aMenu[3], aMenu[4]);
                break;

            case "Level3 - addNavExpandingListSubItem":
                _BPHSAddNavExpandingListItem(aMenu[1], aMenu[2], aMenu[3], aMenu[4], aMenu[5]);
                break;

            case "Level3 - addNavExpandingListItem":
                _BPHSAddNavExpandingListItem(aMenu[1], aMenu[2], aMenu[3], aMenu[4]);
                break;

            case "Level3 - addNavLabel":
                goNav.leftNavString +=
                    "<tr><td valign=top width=100% colspan=2>" +
                    "<div class=clsTocHead style='cursor:default;color:" + goNav.foreground + ";margin-left:2px;margin-right:2px;font-family:Verdana;font-size:10px;font-weight:bold;'>" + aMenu[1] + "</div>" +
                    "</td></tr>";
                break;

            case "Level3 - addNavImageLink":
                _BPHSAddNavImageLink(aMenu[1], aMenu[2], aMenu[3], aMenu[4]);
                break;

            case "Level3 - addNavSeparator":
                goNav.leftNavString += newLineChar + "<tr><td colspan=2><hr style='margin-left:1px;margin-right:1px;width:100%;height:2px;border-style:outset;border-right-width:0px;border-left-width:0px;background-color:" + goNav.hiliteBackground + ";color:" + goNav.foreground + "'></td></tr>";
                break;

            case "Level3 - createNavExpandingList":
                _BPHSCreateNavExpandingList(aMenu[1], aMenu[2], aMenu[3], aMenu[4], aMenu[5]);
                break;
        }
    }
    //clear out the array
    goMenu = new Array();
}

//==============================================================================
// Function: _BPHSDrawHorizontalNavigation()
// Description: Draw Top Level Menu (Level 1)
// Inputs: None
// Return: None
//==============================================================================
function _BPHSDrawHorizontalNavigation() {
    var sHTML;


    sHTML = goNav.menuString1;

    if (goBPHS.menuDropDown) {
        sHTML += "<div id='popmenu' class='nav2Skin' onMouseover=\"_BPHSClearHideMenuTimeout();_BPHSHighlightNav2Menu(event,'on');\" onMouseout=\"_BPHSHighlightNav2Menu(event,'off');_BPHSDynamicHide(event);\"></div>" +
                "<table width='100%' border=0 cellspacing=0 cellpadding=0><tr><td width=5><img src='" + goBPHS.images + "spacer.gif' height=10 width=5 border=0></td><td class='greetingMsg' align='right'>" + goNav.breadCrumbLabel + "</td><td width=5><img src='" + goBPHS.images + "spacer.gif' height=10 width=5 border=0></td></tr></table>" + goNav.menuString;
    } else {
        sHTML += "<table width='100%' cellspacing=0 cellpadding=0 border=0>" +
                "<tr>" +
                    "<td><img src='" + goBPHS.images + "spacer.gif' height=21 width=5 border=0></td>" +
                    "<td width='100%'><div id='popmenu' class='hNav2Skin' onMouseover=\"_BPHSClearHideMenuTimeout();_BPHSHighlightNav2Menu(event,'on');\" onMouseout=\"_BPHSHighlightNav2Menu(event,'off');_BPHSDynamicHide(event);\"></div></td>" +
                    "<td><img src='" + goBPHS.images + "spacer.gif' height=21 width=5 border=0></td>" +
                "</tr>" +
                "</table>" +
                "<table width='100%' border=0 cellspacing=0 cellpadding=0><tr><td width=5><img src='" + goBPHS.images + "spacer.gif' height=10 width=5 border=0></td><td width=5><img src='" + goBPHS.images + "spacer.gif' height=10 width=5 border=0></td></tr></table>" + goNav.menuString;
    }

    document.write(sHTML);

    // Check if we have to draw the bread crumb.
    if (!goBPHS.menuDropDown) {
        var oBreadCrumbNav2Menu = document.getElementById(goNav.breadCrumbMenuID);

        if (oBreadCrumbNav2Menu) {
            oNav2Menu=ie4? document.all.popmenu : document.getElementById("popmenu");
            oNav2Menu.thestyle=oNav2Menu.style;
            oNav2Menu.innerHTML=oBreadCrumbNav2Menu.innerHTML;
            oNav2Menu.thestyle.visibility="visible";
        }
    }

    goBPHS.bannerDrawn = true;
}

//==============================================================================
// Function: _BPHSDrawHeader()
// Description: Displays the Banner
// Inputs: None
// Return: None
//==============================================================================
function _BPHSDrawHeader() {
    var sHTML;

    goBPHS.bannerDrawn = true;

	 if (goBPHS.enableFullCSS) {
		document.write("<link rel='stylesheet' type='text/css' href='" + goBPHS.libPath + "css/header_body.css'>");
	 }
	    sHTML = "<body bgcolor='#FFFFFF' leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>" +
			    "<table width='100%' border=0 cellspacing=5 cellpadding=0>" +
				"<tr>" +
				    //Draw BP Logo
				    "<td class='bannerSkin' width='152' valign='top'>" +
					
					"<img src='" + goBPHS.images + "bphslogo.gif' align='middle' border=0 hspace=20 vspace=9>" +
				    "</td>";

				    //Draw the image
				    if (goBPHS.enablePortalImage) {
					sHTML += "<td valign='middle' class='bannerSkin'><img src='" + goBPHS.images + "portal_image.gif' border=0 onClick='_BPHSImageClick()'></a></td>"
				     }

				    //Draw Page Title and BP Logo
				    sHTML +=    "<td width='100%' class='bannerSkin' valign='top'>" +
						    "<table width='100%' border=0 cellspacing=0 cellpadding=0 height='91'>" +
							"<tr>" +
							    "<td colspan=3></td>" +
							"</tr>" +
							"<tr>" +
							    "<td valign='top'></td>" +
							    "<td width='100%' valign='top'><blockquote><label class=pagetitle>" + goBPHS.bannerName + "</label></blockquote></td>" +
							    "<td align='right' valign='bottom'>" +
								"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='300' height='80'>" +
  "<param name='movie' value='" + goBPHS.flash + "bpsc.swf'>" +
  "<param name='quality' value='high'>" +
  "<embed src='" + goBPHS.flash + "bpsc.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='300' height='80'></embed></object>" +
							    "</td>" +
							"</tr>" +
						    "</table>" +
						"</td>" +

				    "</td>" +
				"</tr>" +
			    "</table>" +
			"</body>";

    document.write(sHTML);
}


//==============================================================================
// Function: _BPHSSymbolClick()
// Description: Back door to see what version and server the banner came from
// Inputs: e - The event that caused this routine to execute
// Return: None
//==============================================================================
function _BPHSSymbolClick(e) {
    if (window.event.altKey) {
        alert("Banner Server Name: " + g_BannerServerName + "\n Banner Version: " + g_Build);
        e.href = goBPHS.libPath + "release_notes.htm";
    }
}

//==============================================================================
// Function: _BPHSImageClick()
// Description: Back door to display the header info
// Inputs: none
// Return: None
//==============================================================================
function _BPHSImageClick() {
    if (window.event.altKey) {
        var sPath = goBPHS.pageProtocol + window.location.hostname + "/portal/atbp_showheader.jsp"
        window.location.href = sPath;
    }
}

//==============================================================================
// Function: _BPHSDrawMessages()
// Description: Displays alert\greeting message
// Inputs: None
// Return: None
//==============================================================================
function _BPHSDrawMessages() {
    var sHTML;
    var sMsg = "";

    if ((goBPHS.warningMsgGlobal != "") || (goBPHS.warningMsg != "") || (goBPHS.greetingMsg != "")) {
        if (goBPHS.warningMsgGlobal != "") {
            sMsg = goBPHS.warningMsgGlobal;
        }
        if (goBPHS.warningMsg != "") {
            if (sMsg != "") {
                sMsg += " | ";
            }
            sMsg += goBPHS.warningMsg;
        }
        sHTML = "<table width='100%' border=0 cellpadding=0 cellspacing=5>" +
                "<tr><td valign='top' class='warningMsg'>" + sMsg + "</td><td class='greetingMsg' valign='bottom' align='right'>" + goBPHS.greetingMsg + "</td></tr>" +
                "</table>";

        document.write(sHTML);
    }
}

//==============================================================================
// Function: _BPHSSetBreadCrumbMappedItem()
// Description: Sets the bread crumb for the page that is displayed.
// Inputs: None
// Return: None
//==============================================================================
function _BPHSSetBreadCrumbMappedItem() {
    var sSubMenuURL;
    var nIndex;
    var nLength;
    var bFound = false;
    var arrBreadCrumbItem;

    // Check if the bread crumb has not been set and we have a bread crumb map.
    if ((goNav.breadCrumbNav1 == "") &  (arrBreadCrumbMapItem != null)) {
        // We have a mapped bread crumb, so find out if the URL matches any of the crumbs.
        nLength = arrBreadCrumbMapItem.length;

        for(nIndex = 0; nIndex < nLength; nIndex++) {
            arrBreadCrumbItem = arrBreadCrumbMapItem[nIndex];
            sSubMenuURL = arrBreadCrumbItem[0];

            // Check if the URL matches.
            if (unescape(location.href) == sSubMenuURL || unescape(location.pathname) == sSubMenuURL) {
                bFound = true;
                break;
            }
        }
    }

    // If we found the bread crumb, set the bread crumb page variables.
    if (bFound) {
        nLength = arrBreadCrumbItem.length;

        for (nIndex = 1; nIndex < nLength; nIndex++) {
            if (nIndex == 1) {
                goNav.breadCrumbNav1 = arrBreadCrumbItem[nIndex];
                goNav.breadCrumbLabel = goNav.breadCrumbNav1;
            } else {
                goNav.breadCrumbLabel += " > " + arrBreadCrumbItem[nIndex];
            }

            if (nIndex == 2) {
                goNav.breadCrumbNav2 = arrBreadCrumbItem[nIndex];
            }
        }
    }
}

//==============================================================================
// Public APIs
//==============================================================================

//==============================================================================
// Function: setBreadCrumbs()
// Description: Creates a horizontal space with respect to the given size in the
//                   local left vertical navigation.
// Inputs: (navigation arguments, i.e. sNav1, sNav2, sNav3, etc...)
// Return: None
//==============================================================================
function setBreadCrumbs() {
    var nIndex;
    var nLength = setBreadCrumbs.arguments.length;

    for (nIndex = 0; nIndex < nLength; nIndex++) {
        if (nIndex == 0) {
            goNav.breadCrumbNav1 = setBreadCrumbs.arguments[nIndex];
            goNav.breadCrumbLabel = goNav.breadCrumbNav1;
        } else {
            goNav.breadCrumbLabel += " > " + setBreadCrumbs.arguments[nIndex];
        }

        if (nIndex == 1)
            goNav.breadCrumbNav2 = setBreadCrumbs.arguments[nIndex];
        else
            goNav.breadCrumbNav3 = setBreadCrumbs.arguments[nIndex];
    }
}

//==============================================================================
// Function: setTargetFrame(sFrame)
// Description: Sets the target frame for the feedback and support footers.
// Inputs: sFrame - The target frame to set.
// Return: None
//==============================================================================
function setTargetFrame(sFrame) {
    if (!goBPHS.feedbackTarget.length > 0)
        goBPHS.feedbackTarget = sFrame;

    if (!goBPHS.supportTarget.length > 0)
        goBPHS.supportTarget = sFrame;
}

//==============================================================================
// Function: setLocalSupportPage(sURL)
// Description: Set URL to SP's local support process
// Inputs: sURL - URL of local support process
// Return: None
//==============================================================================
function setLocalSupportPage(sURL) {
    goBPHS.supportPage = sURL;
}

//==============================================================================
// Function: setFooterFeedbackPage(sURL)
// Description: Set URL to Feed Back page
// Inputs: sURL - URL to feedback page
// Return: None
//==============================================================================
function setFooterFeedbackPage(sURL) {
    goBPHS.feedbackPage = sURL;
}

//==============================================================================
// Function: setFooterHelpPage(sURL)
// Description: Set URL to SP's help page
//==============================================================================
function setFooterHelpPage(sURL) {
    setLocalSupportPage(sURL);
}

//==============================================================================
// Function: setPageConfidential()
// Description: Display the confidential level
// Inputs: None
// Return: None
//==============================================================================
function setPageConfidential() {
    goBPHS.securityLabel = "BPHS Confidential";
}

//==============================================================================
// Function: setPagePublic()
// Description: Display the confidential level
// Inputs: None
// Return: None
//==============================================================================
function setPagePublic() {
    goBPHS.securityLabel = "BPHS Public";
}

//==============================================================================
// Function: setPagePrivate()
// Description: Display the confidential level
// Inputs: None
// Return: None
//==============================================================================
function setPagePrivate() {
    goBPHS.securityLabel = "BPHS Private";
}

//==============================================================================
// Function: drawFooter()
// Description: Display the footer
// Inputs: None
// Return: None
//==============================================================================
function drawFooter() {

    if (goBPHS.footerDrawn)
        return;

    goBPHS.footerDrawn = true;

    _BPHSCreateFooter();
    if(goBPHS.webMetrics)
        siteCatalyst_sendMetrics();

}

//==============================================================================
// Function: draw BP Footer()
// Description: Display the footer
// Inputs: None
// Return: None
// Notes:  Kept to prevent existing sites from breaking
//==============================================================================
function drawBPFooter() {
    drawFooter();
}

//==============================================================================
// Function: drawSeparator(iHeight, sColor)
// Description: Builds a table to draw a horizontal line of specified height and
//                  color
// Inputs: iHeight - Height to make the separator.
//            sColor - Color to make the separator.
// Return: None
//==============================================================================
function drawSeparator(iHeight, sColor) {
    document.writeln("<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">" +
                                "<tr><td bgcolor=\"" + sColor + "\">" +
                                    "<table border=0 cellspacing=0 cellpadding=0>" +
                                        "<tr><td height=\"" + iHeight + "\"></td></tr>" +
                                    "</table>" +
                                "</td></tr></table>");
}

//==============================================================================
// Function: setVersionNumber(sVersionNumber)
// Description: Sets the version Number
// Inputs: sVersionNumber - Version Number to set to.
// Return: None
//==============================================================================
function setVersionNumber(sVersionNumber) {
    goBPHS.versionNumber = "Site Version " + sVersionNumber;
}

//==============================================================================
// Function: setPortalVersionNumber(sVersionNumber)
// Description: Sets the portal version Number
// Inputs: sVersionNumber - Version Number to set to.
// Return: None
//==============================================================================
function setPortalVersionNumber(sVersionNumber) {
    goBPHS.versionNumber = "@BPHS Portal Version " + sVersionNumber;
}

//==============================================================================
// Function: addNavSpacer( iHeight )
// Description: Creates a horizontal space with respect to the given size in the
//                   local left vertical navigation.
// Inputs: iheight - size of spacer
// Return: None
//==============================================================================
function addNavSpacer( iHeight ) {
    var aMenu = new Array(2);

    goBPHS.enableLeftNavMenu = true;

    aMenu[0] = "Level3 - AddNavSpacer";
    aMenu[1] = iHeight;

    goMenu.push(aMenu);

    //goNav.leftNavString += "<tr><td colspan=2 height=" + iHeight + ">&nbsp;</td></tr>";
}

//==============================================================================
// Function:    addNavImage(sSubImage, sSubMenuURL, sSubMenu)
// Description: Creates a centered image in the local left vertical navigation
//                   which serves as a link.
// Inputs: sSubImage - URL for Image
//            sSubMenuURL - URL for link
//            sSubMenu - Label for alt tag
//            Optional sTarget - target location for document
// Return: None
//==============================================================================
function addNavImage(sSubImage, sSubMenuURL, sSubMenu) {
    var sTarget = "";
    var aMenu = new Array(5);

    goBPHS.enableLeftNavMenu = true;

    if (addNavImage.arguments.length > 3)
        sTarget = addNavImage.arguments[3];

    aMenu[0] = "Level3 - AddNavImage";
    aMenu[1] = sSubImage;
    aMenu[2] = sSubMenuURL;
    aMenu[3] = sSubMenu;
    aMenu[4] = sTarget;

    goMenu.push(aMenu);
    //_BPHSAddNavImage(sSubImage, sSubMenuURL, sSubMenu, sTarget);
}

//==============================================================================
// Function: addNavExpandingListSubItem(sMenuID, sSubMenu, sSubMenuURL)
// Description: Add a SubItem to the left nav sub-item
// Inputs: None
// Return: None
// Notes: This may already be deprecated
//==============================================================================
function addNavExpandingListSubItem(sMenuID, sSubMenu, sSubMenuURL) {
    var all = document.getElementsByTagName("*");
    var sTarget = "";
    var isFirstNav;
    var aMenu = new Array(6);

    if (addNavExpandingListSubItem.arguments.length > 3)
        sTarget = addNavExpandingListSubItem.arguments[3];

    isFirstNav=eval("all.ITEMS_EL_" + sMenuID);

    if (isFirstNav) {
        if(!isFirstNav.length)
            sMenuID += 1;
        else
            sMenuID += isFirstNav.length;
    }

    aMenu[0] = "Level3 - addNavExpandingListSubItem";
    aMenu[1] = "EL_" + sMenuID;
    aMenu[2] = sSubMenu;
    aMenu[3] = sSubMenuURL;
    aMenu[4] = sTarget;
    aMenu[5] = "true";

    goMenu.push(aMenu);
    //_BPHSAddNavExpandingListItem("EL_" + sMenuID, sSubMenu, sSubMenuURL, sTarget, "true");
}

//==============================================================================
// Function: addNavLabel(sSubMenu)
// Description: Add a label to the Left Nav menu
// Inputs: sSubMenu - text to display
// Return: None
//==============================================================================
function addNavLabel(sSubMenu) {
    var aMenu = new Array(2);

    goBPHS.enableLeftNavMenu = true;

    aMenu[0] = "Level3 - addNavLabel";
    aMenu[1] = sSubMenu;

    goMenu.push(aMenu);
    /*
    goNav.leftNavString +=
            "<tr><td valign=top width=100% colspan=2>" +
            "<div class=clsTocHead style='cursor:default;color:" + goNav.foreground + ";margin-left:2px;margin-right:2px;font-family:Verdana;font-size:10px;font-weight:bold;'>" + sSubMenu + "</div>" +
            "</td></tr>";
    */
}

//==============================================================================
// Function: addNavImageLink(sSubImage, sSubMenuURL, sSubMenu)
// Description: Create a link that is preceeded by an image
// Inputs: sSubImage - URL of image
//            sSubMenuURL - URL for link
//            sSubMenu - Label for alt tag
// Return: None
//==============================================================================
function addNavImageLink(sSubImage, sSubMenuURL, sSubMenu) {
    var sTarget = "";
    var aMenu = new Array(5);

    goBPHS.enableLeftNavMenu = true;

    if (addNavImageLink.arguments.length > 3)
        sTarget = addNavImageLink.arguments[3];


    aMenu[0] = "Level3 - addNavImageLink";
    aMenu[1] = sSubImage;
    aMenu[2] = sSubMenuURL;
    aMenu[3] = sSubMenu;
    aMenu[4] = sTarget;

    goMenu.push(aMenu);
    //_BPHSAddNavImageLink(sSubImage, sSubMenuURL, sSubMenu, sTarget);
}

//==============================================================================
// Function: drawLeftNavigation()
// Description: Draw the left hand navigation
// Inputs: None
// Return: None
//==============================================================================
function drawLeftNavigation() {
    if ((!ToolBar_Supported) &&(!goBPHS.enableLeftNavMenu)) {
        return;
    }

    if(goMenu.length > 0)
        _BPHSBuildMenus();

    var sHTML = "";

    sHTML = "<table class='leftNavSkin' cellspacing=0 cellpadding=0 border=0 width='151'>" +
                "<tr>" +
                    "<th class='leftNavHeader'><img src='" + goBPHS.images + "spacer.gif' width=1 height=6></th>" +
                    "<th class='leftNavHeader'></th>" +
                    "<th class='leftNavHeader'></th>" +
                "</tr>" +
                "<tr><td colspan=3></td></tr>" +
                "<tr>" +
                    "<td width=1><img src='" + goBPHS.images + "spacer.gif' width=1 height=20></td>" +
                    "<td width='138' align='center'>" +
                        "<table width='138' border=0 cellspacing=0 cellpadding=0>" +
                            "<br>" +
							goNav.leftNavString +
                        "</table>" +
                    "</td>" +
                    "<td width=1><img src='" + goBPHS.images + "spacer.gif' width=1 height=20></td>" +
                "</tr>" +
                "<tr><td colspan=3></td></tr>" +
            "</table>";

    document.writeln(sHTML);
    _BPHSOpenNavExpandingLists();
}

//==============================================================================
// Function: addNavExpandingListItem(sMenuID, sSubMenu, sSubMenuURL)
// Description: Add a sub-menu item to an existing left nav menu item (level 4)
// Inputs: sMenuID - Unique ID for Menu item
//            sSubMenu - String to display for menu Item
//            sSubMenuURL - URL for the link
//            Optional sTarget - location to place document
// Return: None
//==============================================================================
function addNavExpandingListItem(sMenuID, sSubMenu, sSubMenuURL) {
    var sTarget = "";
    var isFirstNav;
    var all = document.getElementsByTagName("*");
    var aMenu = new Array(5);

    if (addNavExpandingListItem.arguments.length > 3)
        sTarget = addNavExpandingListItem.arguments[3];

    isFirstNav = eval("all.ITEMS_EL_" + sMenuID);

    if (isFirstNav) {
        if(!isFirstNav.length)
            sMenuID += 1;
        else
            sMenuID += isFirstNav.length;
    }

    aMenu[0] = "Level3 - addNavExpandingListItem";
    aMenu[1] = "EL_" + sMenuID;
    aMenu[2] = sSubMenu;
    aMenu[3] = sSubMenuURL;
    aMenu[4] = sTarget;

    goMenu.push(aMenu);
    //_BPHSAddNavExpandingListItem("EL_" + sMenuID, sSubMenu, sSubMenuURL, sTarget);
}

//==============================================================================
// Function: addNavSeparator
// Description: Adds a horizontal separator to the left nav
// Inputs: None
// Return: None
//==============================================================================
function addNavSeparator() {
    var aMenu = new Array(1);

    goBPHS.enableLeftNavMenu = true;

    aMenu[0] = "Level3 - addNavSeparator";
    goMenu.push(aMenu);
    //goNav.leftNavString += newLineChar + "<tr><td colspan=2><hr style='margin-left:1px;margin-right:1px;width:100%;height:2px;border-style:outset;border-right-width:0px;border-left-width:0px;background-color:" + goNav.hiliteBackground + ";color:" + goNav.foreground + "'></td></tr>";
}

//==============================================================================
// Function: createNavExpandingList(sMenuID, sMenuDisplay, sMenuURL, bDefOpen, sTarget)
// Description: Creates a menu item with the ability to expand.
// Inputs: sMenuID - Unique ID for Menu item
//            sMenuDisplay - String to display for menu Item
//            sMenuURL - URL for the link
//            bDefOpen - Flags whether to open or close the list. True - Open List
//            sTarget - Optional, specifies where to open the new URL
// Return: None
//==============================================================================
function createNavExpandingList(sMenuID, sMenuDisplay, sMenuURL, bDefOpen) {
    var isFirstNav;
    var all = document.getElementsByTagName("*");
    var aMenu = new Array(6);
    var sTarget = "";

    goBPHS.enableLeftNavMenu = true;

    if (createNavExpandingList.arguments.length > 4)
        sTarget = createNavExpandingList.arguments[4];

    isFirstNav=eval("all.ITEMS_EL_" + sMenuID);
     ;
    if (isFirstNav) {
        if(!isFirstNav.length) {
            sMenuID += 1;
        } else {
            sMenuID += isFirstNav.length;
        }
    }

    aMenu[0] = "Level3 - createNavExpandingList";
    aMenu[1] = "EL_" + sMenuID;
    aMenu[2] = sMenuDisplay;
    aMenu[3] = sMenuURL;
    aMenu[4] = bDefOpen;
    aMenu[5] = sTarget;

    goMenu.push(aMenu);
    //_BPHSCreateNavExpandingList("EL_" + sMenuID, sMenuDisplay, sMenuURL, bDefOpen);
}

//==============================================================================
// Function: setWarningMessage(sMsg)
// Description: Sets the warning message to be displayed and enables msg display
// Inputs: sMsg - Alert message to display
// Return: None
//==============================================================================
function setWarningMessage(sMsg) {
    goBPHS.warningMsg = sMsg;
}

//==============================================================================
// Function: setGlobalWarningMessage(sMsg)
// Description: Sets the warning message to be displayed and enables msg display
// Inputs: sMsg - Alert message to display
// Return: None
//==============================================================================
function setGlobalWarningMessage(sMsg) {
    goBPHS.warningMsgGlobal = sMsg;
}

//==============================================================================
// Function: setGreetingMessage(sMsg)
// Description: Sets the greeting message to be displayed and enables msg display
// Inputs: sMsg - Greeting message to display
// Return: None
//==============================================================================
function setGreetingMessage(sMsg) {
    goBPHS.greetingMsg = sMsg;
}

//==============================================================================
// Function: addNavLink(sSubMenu, sSubMenuURL)
// Description: Add NavLinks to the Left Nav Menu (Level 3)
// Inputs: sSubMenu - Left hand menu name
//            sSubMenuURL - URL of menu item
//            Optional sTarget - target location for document to be displayed
// Return: None
//==============================================================================
function addNavLink(sSubMenu, sSubMenuURL) {
    var sTarget = ""; // Target of link.
    var aMenu = new Array(4);

    goBPHS.enableLeftNavMenu = true;

    if (addNavLink.arguments.length > 2) {
        sTarget = addNavLink.arguments[2];
    }

    aMenu[0] = "Level3 - AddNavLink";
    aMenu[1] = sSubMenu;
    aMenu[2] = sSubMenuURL;
    aMenu[3] = sTarget;

    goMenu.push(aMenu);

    //_BPHSAddNavLink(sSubMenu, sSubMenuURL, sTarget);
}

//==============================================================================
// Function: addMenuSeparator(sMenuID)
// Description: Adds a separator to the sub-menu item under the specified menu
//                   item found in the top horizontal navigation.
// Inputs: sMenuID - ID of Menu to place separator in
// Return: None
//==============================================================================
function addMenuSeparator(sMenuID) {

    if (goBPHS.menuDropDown) {
        var aMenu = new Array(3);

        aMenu[0] = "Separator";
        aMenu[1] = "LD_" + sMenuID + "_MENU";
        aMenu[2] = "goNav";
        goMenu.push(aMenu);
        //_BPHSAddMenuSeparator("LD_" + sMenuID + "_MENU", "goNav");
    }
}

//==============================================================================
// Function: addMenuItem
// Description: Adds a sub-menu item under the specified menu item found in the
//                   top horizontal navigation.
// Inputs: sMenuID - ID of menu item
//            sSubMenu - Label for Sub-Menu item
//            sSubMenuURL - URL associated with the sub-menu item
//            Optional sTarget - target location for document to be displayed
// Return:      None
//==============================================================================
function addMenuItem(sMenuID, sSubMenu, sSubMenuURL) {
    var sTarget = ""; // Target of link.
    var aMenu = new Array(6);

    if (addMenuItem.arguments.length > 3) {
        sTarget = addMenuItem.arguments[3];
    }

    aMenu[0] = "Level2";
    aMenu[1] = "LD_" + sMenuID + "_MENU";
    aMenu[2] = 'goNav';
    aMenu[3] = sSubMenu;
    aMenu[4] = sSubMenuURL;
    aMenu[5] = sTarget;

    goMenu.push(aMenu);

    /*
    if (goBPHS.menuDropDown)
        _BPHSAddMenuItem("LD_" + sMenuID + "_MENU", "goNav", sSubMenu, sSubMenuURL, sTarget);
    else
        _BPHSAddHorMenuItem("LD_" + sMenuID + "_MENU", "goNav", sSubMenu, sSubMenuURL, sTarget);
    */
}

//==============================================================================
// Function: addBreadCrumbMapItem()
// Description: Creates a mapping of all the bread crumb items.
// Inputs: (navigation arguments, i.e. sURL, sNav1, sNav2, sNav3, etc...)
// Return: None
//==============================================================================
function addBreadCrumbMapItem() {
    var nIndex;
    var nLength = addBreadCrumbMapItem.arguments.length;
    var arrItem = new Array();

    // Check if we have any thing already, if not create one.
    if (arrBreadCrumbMapItem == null) {
        arrBreadCrumbMapItem = new Array();
    }

    // Collect all the argument values.
    for (nIndex = 0; nIndex < nLength; nIndex++) {
        arrItem[nIndex] = addBreadCrumbMapItem.arguments[nIndex];
    }

    // Get the end of the array.
    nIndex = arrBreadCrumbMapItem.length;

    // Add the crumb item to the list.
    arrBreadCrumbMapItem[nIndex] = arrItem;
}


//==============================================================================
// Function: _BPHSForceReload()
// Description: Draw the Banner
// Inputs: None
// Return: None
//==============================================================================
function _BPHSForceReload() {
	if (_BPHSGetCookie("ATBP_FORCE_PAGE_RELOAD") == 1) {
   	_BPHSSetSessionCookie("ATBP_FORCE_PAGE_RELOAD", 0);
   	location.reload(true);
	}
}


//==============================================================================
// Function: drawBanner()
// Description: Draw the Banner and alert messages
// Inputs: None
// Return: None
//==============================================================================
function drawBanner() {

    // Reload the current page if the user just came from the BP logout page
    _BPHSForceReload()

    if (goBPHS.bannerDrawn)
        return;

    // Set the bread crumb
    _BPHSSetBreadCrumbMappedItem();

    // Draw the banner
    _BPHSDrawHeader();

    // Draw the Alert Messages and Greeting
    _BPHSDrawMessages();

}


//==============================================================================
// Function: drawHeader()
// Description: Draw the Banner, alert messages and navigation
// Inputs: None
// Return: None
//==============================================================================
function drawHeader() {

	// Draw the Banner
	drawBanner();

   // Build the menus
   _BPHSBuildMenus();

	// Draw the top horizontal navigation
   if ((ToolBar_Supported) && (goBPHS.enableNav1Menu))
   	_BPHSDrawHorizontalNavigation();

}

//==============================================================================
// Function: displayLogin(Optional sURL)
// Description: Displays the login button in the banner.
// Inputs:  Optional sURL - site protected URL
// Return: None
// Notes: Default is not to display the login button
//     This is used primarily by the @BP portal, can be used
//      by SP's if they use same SM instance as portal to allow
//      login to their site
//==============================================================================
function displayLogin(sURL) {

    if (sURL != null && sURL != "")
        g_LogOnURL = sURL;

    if (displayLogin.arguments.length > 1)
        g_LogOffURL = displayLogin.arguments[1];

    goBPHS.loginEnabled = true;
}

//==============================================================================
// Function: createMenu(sMenuID, sMenuDisplay)
// Description: Create Top Level Menu (Level 1)
// Inputs: sMenuID - ID of menu to link 2nd level items
//            sMenuDisplay - Title to display on the menubar
//            Optional sMenuURL - If menu item does not
//                  contain submenu then URL to go to
// Return: None
//==============================================================================
function createMenu(sMenuID, sMenuDisplay) {
    var sTarget = "";   // Target for link
    var sMenuURL = "";  // URL to point to
    var aMenu = new Array(6);

    goBPHS.enableNav1Menu = true;

    if (createMenu.arguments.length > 2)
        sMenuURL = createMenu.arguments[2];

    if (createMenu.arguments.length > 3)
        sTarget = createMenu.arguments[3];

    aMenu[0] = "Level1";
    aMenu[1] = "LD_" + sMenuID + "_MENU";
    aMenu[2] = 'goNav';
    aMenu[3] = sMenuDisplay;
    aMenu[4] = sMenuURL;
    aMenu[5] = sTarget;
    //_BPHSCreateMenu("LD_" + sMenuID + "_MENU", 'goNav', sMenuDisplay, sMenuURL, sTarget);
    goMenu.push(aMenu);
}

//==============================================================================
// Function: setHorizontalNav()
// Description: Tells system that we will be using 2
//                   horizontal navigations
// Inputs: None
// Return: None
// Notes: defaults set to drop down navigation, cannot be
//           changed if user has already made a call to add
//           menu items
//==============================================================================
function setHorizontalNav() {
    //var sDropDownNav = _BPHSGetCookie("DropDownNav")

    //if (sDropDownNav == "true")
    //  return false;

    goBPHS.menuDropDown = false;
}

//==============================================================================
// Function: setBanner(sBanner)
// Description: Set Banner Name
// Inputs: sBanner - Title to display in the banner
// Return: None
//==============================================================================
function setBanner(sBanner) {
    goBPHS.bannerName = sBanner;
}

//==============================================================================
// Function: setportalImage()
// Description: Loads the portal image into the banner
// Inputs: None
// Return: None
//==============================================================================
function setPortalImage() {
    goBPHS.enablePortalImage = true;
}

//==============================================================================
// Function: setSiteSearch(sSID)
// Description: Set Site Search
// Inputs: sSID - Search ID as defined by Site Search tool
//            Optional sCaption - Label for Site Search
// Return: None
//==============================================================================
function setSiteSearch(sSID) {
    if (setSiteSearch.arguments.length > 1) {
        goBPSearchMenu.siteSearchCaption = setSiteSearch.arguments[1];
    }

    goBPSearchMenu.siteSearchSID = sSID;
    goBPSearchMenu.siteSearchEnabled = true;
}



//==============================================================================
// Function: getCurrentDate()
// Description: Gets the current date from the users pc
// Inputs: None
// Return: Date String
//==============================================================================
function getCurrentDate() {
var day;
var now;

    now = new Date();
   day = now.getDay();
   var dayname;
   if (day == 0) dayname = "Sunday";
   if (day == 1) dayname = "Monday";
   if (day == 2) dayname = "Tuesday";
   if (day == 3) dayname = "Wednesday";
   if (day == 4) dayname = "Thursday";
   if (day == 5) dayname = "Friday";
   if (day == 6) dayname = "Saturday";

   var month
   month = now.getMonth();
    var monthname;
   if (month == 0) monthname = "January";
   if (month == 1) monthname = "February";
   if (month == 2) monthname = "March";
    if (month == 3) monthname = "April";
   if (month == 4) monthname = "May";
   if (month == 5) monthname = "June";
   if (month == 6) monthname = "July";
   if (month == 7) monthname = "August";
    if (month == 8) monthname = "September";
   if (month == 9) monthname = "October";
   if (month == 10) monthname = "November";
   if (month == 11) monthname = "December";

   date = now.getDate();
   year = now.getYear();
   if (year < 1000)
        year += 1900;

    //document.write(dayname + ", " + monthname + " " + date + ", " + year);
    //return (dayname + ", " + monthname + " " + date + ", " + year);
    return (monthname + " " + date + ", " + year);
}

//==============================================================================
// Function: displayPageRevision()
// Description: Displays the last modified date in the footer after version number
// Inputs: None
// Return: None
//==============================================================================
function displayPageRevision() {
var months = new Array(13);

    months[1] = "Jan";
    months[2] = "Feb";
    months[3] = "Mar";
    months[4] = "Apr";
    months[5] = "May";
    months[6] = "Jun";
    months[7] = "Jul";
    months[8] = "Aug";
    months[9] = "Sep";
    months[10] = "Oct";
    months[11] = "Nov";
    months[12] = "Dec";

    var oDate = new Date(document.lastModified)
    var iMonth = months[oDate.getMonth() + 1]
    var iYear = oDate.getYear()
    var iDate = oDate.getDate()

    if (iYear < 1000)
        iYear = iYear + 1900;

    goBPHS.pageRevision = "Page Revision: " + iDate + " " + iMonth + " " + iYear
}

//==============================================================================
// Function: disableMyLinks()
// Description: disable the button that allows users to add url to myLinks
// Inputs:
// Return: None
//==============================================================================
function disableMyLinks() {
    goBPHS.enableMyLinks = false;
}

//==============================================================================
// Function: doMyLinks()
// Description: Display MyLinks confirmation
// Inputs: None
// Return: None
//==============================================================================
function doMyLinks() {
    var sTitle, sURL, sKnown;

    sKnown = (_BPHSIsLoggedIn() || _BPHSIsRemembered()) ;
    sURL = escape(window.location.href);
    sTitle = escape(document.title);
    if ( sKnown ) {
        _BPHSOpenWindow(g_MyLinks + "?title=" + sTitle + "&url=" + sURL + "&known=" + sKnown, "MyLinks", "width=500,height=235,left=350,top=0");
    } else {
        _BPHSOpenWindow(g_MyLinks + "?title=" + sTitle + "&url=" + sURL + "&known=" + sKnown, "MyLinks", "width=800,height=535,left=350,top=0");
    }
}


//==============================================================================
// Function: _BPHSIsRemembered()
// Description: Checks to see if a user is known
// Inputs: None
// Return: true if user is remembered on the portal
//            otherwise false
//==============================================================================
function _BPHSIsRemembered() {
var sCode = _BPHSGetCookie("ATBP_COOKIE");

    if (sCode != null) {
    sCode = decodeURI(sCode);
        var location = sCode.indexOf("userID=");
         if (location != -1 ) {
            return true;
         }
    }
   return false;
}

//==============================================================================
// Function: atBPSetForcePageReload()
// Description: Sets a cookie that will force a page reload the next time that
//              drawHeader() is called.
// Inputs: None
// Return: None
//==============================================================================
function atBPSetForcePageReload() {
    _BPHSSetSessionCookie("ATBP_FORCE_PAGE_RELOAD", 1);
}

//==============================================================================
// Function: setBodyStyleDisabled()
// Description: Disable Body style from Cascading Stylesheets
//==============================================================================
function setBodyStyleDisabled() {
	goBPHS.enableFullCSS = false;
}


//==============================================================================
// DEPRECATED PUBLIC APIs
//==============================================================================

//==============================================================================
// Function: setTheme
// Description: Allows you to set the theme for the page.
//==============================================================================
function setTheme(sThemeName) {return;}

//==============================================================================
// Function: setCSSUseR3
// Description: Sets the cssUseR3 variable to true, telling header.js to use
//                   Release 3 version of the stylesheet.
//==============================================================================
function setCSSUseR3() {return;}

//==============================================================================
// Function: setCSSDisabled()
// Description: Disable Cascading Stylesheets
//==============================================================================
function setCSSDisabled() {return;}

//==============================================================================
// Function: setSearchCollection(sCollection)
// Description: Set Search option are we performing
//==============================================================================
function setSearchCollection(sCollection) {return;}

//==============================================================================
// Function: drawWarningMsg()
// Description: Display alert message
//==============================================================================
function drawWarningMsg() {return;}

//==============================================================================
// Function: drawHorizontalNavigation()
// Description: Draw Top Level Menu (Level 1)
//==============================================================================
function drawHorizontalNavigation() {return;}

//==============================================================================
// Function: scriptInTable()
// Description: Tells header.js that you are running the script in a table
//==============================================================================
function scriptInTable() {return;}


