
var howDoIMenu;
if (!howDoIMenu) howDoIMenu = {};
else throw new Error("howDoIMenu has already been defined");

howDoIMenu.addHowDoIMenu =
    function(howDoIMenuArray) {
        headerMenuDiv = document.getElementById("headerMenu"); //headerMenu

        howDoIMenuDiv = this.createHowDoIMenu(howDoIMenuArray);

        headerMenuDiv.appendChild(howDoIMenuDiv);
    };

howDoIMenu.createHowDoIMenu =
    function(howDoIMenuArray) {

        var howDoIMenuDiv, howDoIMenuLeftDiv, howDoIMenuMiddleDiv, howDoIMenuRightDiv;

        howDoIMenuDiv = this.createHowDoIMenuDiv();

        howDoIMenuLeftDiv = this.createHowDoIMenuLeftDiv();

        howDoIMenuDiv.appendChild(howDoIMenuLeftDiv);

        howDoIMenuMiddleDiv = this.createHowDoIMenuMiddleDiv(howDoIMenuArray);

        howDoIMenuDiv.appendChild(howDoIMenuMiddleDiv);

        howDoIMenuRightDiv = this.createHowDoIMenuRightDiv();

        howDoIMenuDiv.appendChild(howDoIMenuRightDiv);

        return howDoIMenuDiv;
    };

howDoIMenu.createHowDoIMenuDiv =
    function() {
        var howDoIMenuDiv = document.createElement("div");
        howDoIMenuDiv.id = "howDoIMenu";
        howDoIMenuDiv.style.cssFloat = "right";
        howDoIMenuDiv.style.styleFloat = "right";

        return howDoIMenuDiv;
    };

howDoIMenu.createHowDoIMenuLeftDiv =
    function() {
        var howDoIMenuLeftDiv = document.createElement("div");
        howDoIMenuLeftDiv.id = "howDoILeftCorner";
        howDoIMenuLeftDiv.style.cssFloat = "left";
        howDoIMenuLeftDiv.style.styleFloat = "left";
        howDoIMenuLeftDiv.style.width = "20px";
        howDoIMenuLeftDiv.style.height = "24px";

        this.setElementBackground(howDoIMenuLeftDiv, imageDirectory + "header_menu_left_rounded.png");

        return howDoIMenuLeftDiv;
    };

howDoIMenu.createHowDoIMenuMiddleDiv =
    function(howDoIMenuArray) {
        var howDoIMenuMiddleDiv, howDoIMenuLabel, howDoIMenuSelect, howDoIMenuOption;

        howDoIMenuMiddleDiv = document.createElement("div");
        howDoIMenuMiddleDiv.id = "howDoIMiddle";
        howDoIMenuMiddleDiv.style.cssFloat = "left"
        howDoIMenuMiddleDiv.style.styleFloat = "left";
        howDoIMenuMiddleDiv.style.height = "21px";
        howDoIMenuMiddleDiv.style.padding = "3px 3px 0 0";

        this.setElementBackground(howDoIMenuMiddleDiv, imageDirectory + "header_menu_middle.png");
        howDoIMenuMiddleDiv.style.backgroundRepeat = "repeat-x";

        howDoIMenuLabel = document.createElement("label");
        howDoIMenuLabel.style.marginRight = "5px";
        howDoIMenuLabel.style.fontWeight = "bold";

        howDoIMenuLabel.appendChild(document.createTextNode("How do I"));

        howDoIMenuMiddleDiv.appendChild(howDoIMenuLabel);

        howDoIMenuSelect = document.createElement("select");
        howDoIMenuSelect.onchange = function() { document.location.href=this.value; };
        howDoIMenuSelect.style.fontSize = "1.1em";
        howDoIMenuSelect.style.width = "266px";

        howDoIMenuOption = document.createElement("option");
        howDoIMenuOption.setAttribute("value", "");
        howDoIMenuOption.setAttribute("selected", "selected");
        howDoIMenuOption.appendChild(document.createTextNode("Please select..."));

        howDoIMenuSelect.appendChild(howDoIMenuOption);

        for (var pageId in howDoIMenuArray) {
            if (!howDoIMenuArray[pageId].call) {
                howDoIMenuOption = document.createElement("option");
                howDoIMenuOption.setAttribute("value", protocol + "www.senh.org.uk/index.cgi?contentid=" + pageId);
                howDoIMenuOption.appendChild(document.createTextNode(howDoIMenuArray[pageId]));

                howDoIMenuSelect.appendChild(howDoIMenuOption);
            }
        }

        howDoIMenuMiddleDiv.appendChild(howDoIMenuSelect);

        return howDoIMenuMiddleDiv;
    };

howDoIMenu.createHowDoIMenuRightDiv =
    function() {
        var howDoIMenuRightDiv = document.createElement("div");
        howDoIMenuRightDiv.id = "howDoIRightCorner";
        howDoIMenuRightDiv.style.cssFloat = "left";
        howDoIMenuRightDiv.style.styleFloat = "left";
        howDoIMenuRightDiv.style.width = "15px";
        howDoIMenuRightDiv.style.height = "24px";

        this.setElementBackground(howDoIMenuRightDiv, imageDirectory + "howDoIMenuRightCorner.png");

        return howDoIMenuRightDiv;
    };

howDoIMenu.setElementBackground =
    function(element, backgroundImageURL) {
        if (navigator.appName == "Microsoft Internet Explorer" &&
            parseFloat(navigator.appVersion) >= 4) {
            element.style.display = "inline-block";
            element.style.cssText = element.style.cssText + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (src='" + backgroundImageURL + "', sizingMethod='scale')";
        }
        else {
            element.style.backgroundImage = "url('" + backgroundImageURL + "')";
            element.style.backgroundRepeat = "no-repeat";
        }
    };
