var IA = IA ? IA : new Object();
IA.Navigation = IA.Navigation ? IA.Navigation : new Object();

// **** ACCORDION CLASS - START **** //
IA.Navigation.ActionMenu = function () {
    var obj = this; // Reference variable

    /* ---> GLOBALS <--- */
    var oMenu = null;
    var oItems = new Array();
    var initialized = false;
    var currItem = null;

    /* ---> PROPERTIES <--- */
    /* this.containerId = null; // Target ID for menu container */


    /* ---> PUBLIC METHODS <--- */
    this.init = function () {
        if (!initialized) {
            var a;
            initialized = true;
            oMenu = document.createElement('div');
            oMenu.className = 'IAAM_container';
            for (i = 0; i < oItems.length; i++) {
                a = document.createElement('a');
                a.href = oItems[i][0];
                a.innerHTML = oItems[i][1];
                oMenu.appendChild(a);
            }
        }
    }

    //ADD MENU ITEM
    this.addItem = function (sLink, sText) {
        var i;
        i = oItems.length;
        oItems[i] = new Array(2);
        oItems[i][0] = sLink;
        oItems[i][1] = sText;

        //If the popup is already initialized, add this to the menu.
        if (initialized == true) {
            var a
            a = document.createElement('a');
            a.href = oItems[i][0];
            a.innerHTML = oItems[i][1];
            oMenu.appendChild(a);
        }
    }

    //REPLACE TEXT IN LINKS (in case of a placeholder)
    this.replaceText = function (idx, sPlaceholder, sText) {
        if (initialized) {
            var iCount = oMenu.getElementsByTagName('a').length;
            var sTemp;

            for (i = 0; i < iCount; i++) {
                sTemp = oItems[i][idx];
                sTemp = sTemp.replace(sPlaceholder, sText);
                if (idx == 0) {
                    oMenu.getElementsByTagName('a')[i].href = sTemp;
                }
                else {
                    oMenu.getElementsByTagName('a')[i].innerHTML = sTemp;
                }
            }
        }
    }

    //SHOW AND HIDE THE MENU
    this.toggleMenu = function (elmnt) {

        var oParent;
        var showMenu = true;

        oParent = oMenu.parentNode;

        if (oParent) {
            oParent.removeChild(oMenu);
            oParent.className = 'IAAM_button';

            if (oParent == elmnt) {
                showMenu = false;
            }
        }

        if (showMenu == true) {
            elmnt.className = 'IAAM_selectedbutton';
            elmnt.appendChild(oMenu);
        }
    }













    /* ---> EVENTS <--- */
    this.onmenuopened = null;
    this.onmenuclosed = null;

}
// **** ACCORDION CLASS - END **** //
