/**include
//_javascript/js-wrapper.js;
*/



var oMenuControl = {

	ul : null,
	bOpen : null,
	/**
	 * @param {Object} nCurrentId
	 * @param {Object} aMenuKey
	 * @param {Object} sMenu
	 * @param {Object} sSubMenu
	 */
	init : function(bOpen, nCurrentId, aMenuKey, sMenu, sSubMenu)
    {
        this.nCurrentId = this.BackElm = nCurrentId;
        this.bOpen = bOpen;

        this.aMenuKey = aMenuKey;
        this.sMenu = sMenu;
        this.sSubMenu = sSubMenu;
        this.winWr.createStyle(".jsHide", "display:none;");
    },

    onready  : function(evtWr)
    {
    	// !!! link = this.$("#link"); -- without var - error in IE!!!
    	var link = this.$("#link");
        this.ul = this.$("ul#left_menu");
        /*if (!this.bOpen) {
        	this.ul.hide();
        }*/
    	if (link) {
        	link.addListener(this, "onclick", "clickUl");
        }
        for (var i in this.aMenuKey) {
            var oMenuElm = this.$("#" + this.sMenu + this.aMenuKey[i]);
            if (oMenuElm) {
                oMenuElm.addListener(this, "onclick").elm = this.aMenuKey[i];
                if (i == this.nCurrentId) {
                    oMenuElm.removeClass("jsHide");
                }
            }
        }
    },

    clickUl : function(evtWr, dt)
    {
        this.ul.invDisplay();
        //this.ul.show();
    },


    onclick : function(evtWr, data)
    {
        var oMenuElm = this.$("#" + this.sSubMenu+data['elm']);
		if (oMenuElm) {
		    evtWr.eventDrop();
            var li = this.$("#li_" + data['elm']);
            if (oMenuElm.isShow()) {
                oMenuElm.addClass("jsHide");
                if (li) {
                    li.removeClass('current');
                }
            } else {
                oMenuElm.removeClass("jsHide");
                if (li) {
                    li.addClass('current');
                }
                if (this.BackElm != -1) {
                  //  this.winWr.getElement("submenu_"+this.BackElm).addClass("jsHide");
                }
                this.BackElm = data['elm'];
            }
		}
    }
}

var menuControl = newClass(oMenuControl);