/**include
//_javascript/js-wrapper.js;
*/


var menuControl = function(nCurrentId, aMenuKey, sMenu, sSubMenu, winWr)
{

        this.winWr = winWr ? winWr : _wrapper;

        this.BackElm = nCurrentId;

        this.nCurrentId = nCurrentId;
        this.aMenuKey = aMenuKey;
        this.sMenu = sMenu;
        this.sSubMenu = sSubMenu;
        this.winWr.createStyle(".jsHide", "display:none;");
		this.winWr.setOnloadListener(this);
}

menuControl.prototype = {
    onload  : function(evtWr)
    {
        for (var i in this.aMenuKey) {
            if (this.winWr.checkElement(this.sMenu+i)) {
                var oMenuElm = this.winWr.getElement(this.sMenu+i);
                oMenuElm.addListener(this, "onclick").elm = i;
                if (i == this.nCurrentId) {
                    this.winWr.getElement(this.sMenu+i).removeClass("jsHide");
                }
            }
        }
    },


    onclick : function(evtWr, data)
    {
		if (this.winWr.checkElement(this.sSubMenu+data['elm'])) {
		    evtWr.eventDrop();
    		var oMenuElm = this.winWr.getElement(this.sSubMenu+data['elm']);
            if (oMenuElm.isShow()) {
                oMenuElm.addClass("jsHide");
            } else {
                oMenuElm.removeClass("jsHide");
                if (this.BackElm != -1) {
                  //  this.winWr.getElement("submenu_"+this.BackElm).addClass("jsHide");
                }
                this.BackElm = data['elm'];
            }
		}
    }
};
