
        // Discover what the browser is
        //--------------------------------------
        function Browser()
        //--------------------------------------
        {
                // Set the vars
                var ua, s, i;
                this.isIE    = false;  // Internet Explorer
                this.isNS    = false;  // Netscape
                this.version = null;

                // Grab the info
                ua = navigator.userAgent;

                // Then work it out
                s = "MSIE";

                // If "ua" contains MSIE, then return IE
                if ((i = ua.indexOf(s)) >= 0)
                {
                        this.isIE = true;
                        this.version = parseFloat(ua.substr(i + s.length));
                        return;
                }

                s = "Netscape6/";

                // If "ua" contains Netscape6/, then return netscape
                if ((i = ua.indexOf(s)) >= 0)
                {
                        this.isNS = true;
                        this.version = parseFloat(ua.substr(i + s.length));
                        return;
                }

                // Treat any other "Gecko" browser as NS 6.1.
                s = "Gecko";
                if ((i = ua.indexOf(s)) >= 0)
                {
                        this.isNS = true;
                        this.version = 6.1;
                        return;
                }

        } /////// END browser(); ////////////////



        //////// GLOBALS //////////////////////
        // Create the var browser for use in the script.
        var browser = new Browser();
        // Set the active button to a global var
        var activeButton = null;


        // Capture mouse clicks on the page so any active button can be deactivated.
        if (browser.isIE)
        {
                document.onmouseover = pageMousedown;
        }
        else
        {
                document.addEventListener("mouseover", pageMousedown, true);
        }




        // Discover what the next element up in the tree is.
        //--------------------------------------
        function getContainerWith(node, tagName, className)
        //--------------------------------------
        {

                // Starting with the given node, find the nearest containing element
                // with the specified tag name and style class.

                while (node != null) {
                if (node.tagName != null && node.tagName == tagName && hasClassName(node, className))
                {
                        return node;
                }
                        node = node.parentNode;
                }

                return node;

        } /////// END browser(); ////////////////


        // Discover what the class name of the particular element is and if it is in the list of class="class1 class2 class3" etc.
        //--------------------------------------
        function hasClassName(el, name)
        //--------------------------------------
        {

                var i, list;

                // Return true if the given element currently has the given class
                // name.
                list = el.className.split(" ");

                for (i = 0; i < list.length; i++)
                {
                        if (list[i] == name)
                        {
                                return true;
                        }
                }

                return false;

        } ////// end hasClassName(el, name) ///////



        // Remove a classname from the list i.e. class="class1 class2 class3" >> class="class1 class3"
        //--------------------------------------
        function removeClassName(el, name)
        //--------------------------------------
        {

                var i, curList, newList;

                if (el.className == null)
                {
                        return;
                }

                // Remove the given class name from the element's className property.
                newList = new Array();
                curList = el.className.split(" ");

                        for (i = 0; i < curList.length; i++)
                        {
                                if (curList[i] != name)
                                {
                                        newList.push(curList[i]);
                                }
                        }

                el.className = newList.join(" ");

        } ///// end removeClassName(el, name) //////



        // Get the LEFT pixel of current element
        //--------------------------------------
        function getPageOffsetLeft(el)
        //--------------------------------------
        {

                var x;

                x = el.offsetLeft;
                if (el.offsetParent != null)
                {
                        x += getPageOffsetLeft(el.offsetParent);
                }

                return x;
        } //// end getPageOffsetLeft(el) ////


        // Get the TOP pixel of current element
        //--------------------------------------
        function getPageOffsetTop(el)
        //--------------------------------------
        {

                var y;

                y = el.offsetTop;
                if (el.offsetParent != null)
                {
                        y += getPageOffsetTop(el.offsetParent);
                        if (!browser.isIE)
                        {
                                y = y - 0.75;
                        }
                }

                return y;
        } //// end getPageOffsetTop(el) /////


        // Do this stuff when the button is click (or moused over)
        //--------------------------------------
        function buttonClick(event, menuId)
        //--------------------------------------
        {
                var button;
		sidemenu = 0;
		if (menuId.substring(0,1) == "-") {
			sidemenu = 1;
			menuId = menuId.substring(1,1000)
			}


                // Get the target button element.

                if (browser.isIE)
                {
                        button = window.event.srcElement;
                }
                else
                {
                        button = event.currentTarget;
                }

                // Blur focus from the link to remove that annoying outline.
                button.blur();

                // Associate the named menu to this button if not already done.
                // Additionally, initialize menu display.

                if (button.menu == null)
                {
                        button.menu = document.getElementById(menuId);
                        if (button.menu.isInitialized == null)
                        {
                                menuInit(button.menu);
                        }
                }

                // Reset the currently active button, if any.
                if (activeButton != null)
                {
                        resetButton(activeButton);
                }

                // Activate this button, unless it was the currently active one.
                if (button != activeButton)
                {
                        depressButton(button);
                        activeButton = button;

                        // Sort out the IE div problem with selects and objects
                        // This will hide them when you open the menu.
                        flash_obj = document.getElementById("hide_flash");
                        if (flash_obj)
                        {
                                flash_obj.style.visibility = "hidden";
                        }
                }
                else
                {
                        activeButton = null;

                        // Sort out the IE div problem with selects and objects
                        // This will hide them when you open the menu.
                        flash_obj = document.getElementById("hide_flash");
                        if (flash_obj)
                        {
                                flash_obj.style.visibility = "visible";
                        }
                }

                //return false;
        } //// end buttonClick(event, menuID) ////


        // Work out where to put the dropdown menu and make it visible
        //--------------------------------------
        function depressButton(button)
        //--------------------------------------
        {

                var x, y;

                // Update the button's style class to make it look like it's
                // depressed.

                //button.className += " menuButtonActive";

                // Position the associated drop down menu under the button and
                // show it.

                x = getPageOffsetLeft(button);
                y = getPageOffsetTop(button) + button.offsetHeight;

                button.menu.style.left = (x-7+(85*sidemenu)) + "px";
                button.menu.style.top  = (y-(40*sidemenu)) + "px";
                if (sidemenu == 0 || (sidemenu == 1 && nosidemenu !=1)) button.menu.style.visibility = "visible";
        }


        // Hide the dropdown again
        //--------------------------------------
        function resetButton(button)
        //--------------------------------------
        {

                // Restore the button's style class.
                //removeClassName(button, "menuButtonActive");

                // Hide the button's menu, first closing any sub menus.

                if (button.menu != null) {
                        //closeSubMenu(button.menu);
                        button.menu.style.visibility = "hidden";
                }

                // Sort out the IE div problem with selects and objects
                // This will hide them when you open the menu.
                flash_obj = document.getElementById("hide_flash");
                if (flash_obj)
                {
                        flash_obj.style.visibility = "visible";
                }
        }



        // If anywhere else on the page is clicked, cancel the flyout
        //--------------------------------------
        function buttonMouseover(event, menuId)
        //--------------------------------------
        {

                var button;

                if (browser.isIE)
                {
                        button = window.event.srcElement;
                }
                else
                {
                        button = event.currentTarget;
                }

                // If any other button menu is active, make this one active instead.
                if (activeButton != button)
                {
                        buttonClick(event, menuId);
                }
        }


        // If anywhere else on the page is moused, cancel the flyout
        //--------------------------------------
        function pageMousedown(event)
        //--------------------------------------
        {

                var el;

                // If there is no active button, exit.
                if (activeButton == null)
                {
                        return;
                }

                // Find the element that was clicked on.
                if (browser.isIE)
                {
                        el = window.event.srcElement;
                }
                else
                {
                        el = (event.target.tagName ? event.target : event.target.parentNode);
                }

                // If the active button was clicked on, exit.
                if (el == activeButton)
                {
                        return;
                }

                // If the element is not part of a menu, reset and clear the active
                // button.
                if ((getContainerWith(el, "DIV", "menu") == null) && (getContainerWith(el, "DIV", "menushow") == null))
                {
                        resetButton(activeButton);
                        activeButton = null;
                }
        }


        // Initialise the dropdown, allows for full length hightlighting, even on the shortest link
        //--------------------------------------
        function menuInit(menu)
        //--------------------------------------
        {

                var itemList, spanList;
                var textEl, arrowEl;
                var itemWidth;
                var w, dw;
                var i, j;

                // For IE, replace arrow characters.

                if (browser.isIE)
                {
                        menu.style.lineHeight = "2.5ex";
                        spanList = menu.getElementsByTagName("SPAN");
                        for (i = 0; i < spanList.length; i++)
                        {
                                if (hasClassName(spanList[i], "menuItemArrow"))
                                {
                                        spanList[i].style.fontFamily = "Webdings";
                                        spanList[i].firstChild.nodeValue = "4";
                                }
                        }
                }

                // Find the width of a menu item.
                itemList = menu.getElementsByTagName("A");
                if (itemList.length > 0)
                {
                        itemWidth = itemList[0].offsetWidth;
                }
                else
                {
                        return;
                }

                // Fix IE hover problem by setting an explicit width on first item of the menu.
                if (browser.isIE)
                {

                        w = 0
			for (i = 0 ; i < itemList.length; i++ ){
				if (itemList[i].offsetWidth > w ) {
					w = itemList[i].offsetWidth				
					}
				}



                        itemList[0].style.width = w + "px";
                        dw = itemList[0].offsetWidth - w;
                        w -= dw;
                        itemList[0].style.width = w + "px";
                }

                menu.isInitialized = true;

        }


