﻿Type.registerNamespace("IG");

IG.subMenuSmall = function(controlId, pageCount) {
    this._controlId = controlId;
    this._pageCount = pageCount;
    this._page = 1;
}

IG.subMenuSmall.prototype = {

    getControlId: function() {
        return this._controlId;
    },

    getPageCount: function() {
        return this._pageCount;
    },
    
    getPage: function() {
        return this._page;
    },
    
    goPrev: function() {
         var newPg = this._page - 1;
         if(newPg==0)
            this.changePage(this._pageCount);
         else
            this.changePage(newPg);
    },
    
    goNext: function() {
         var newPg = this._page + 1;
         if(newPg>this._pageCount)
            this.changePage(1);
         else
            this.changePage(newPg);
    },

    changePage: function(pg) {
         for (var i=1; i<=this._pageCount; i++){
            if (i==pg){
               this._show(this._controlId + i);
            }
            else{
                this._hide(this._controlId + i);
            }
         }
         this.toggleMenu(pg);
         this._page = pg;
    },
    
    toggleMenu: function(pg) {
         for (var i=1; i<=this._pageCount; i++){
            if (i==pg){
               Sys.UI.DomElement.addCssClass($get(this._controlId + '_menu' + i), "selected");
            }
            else{
               Sys.UI.DomElement.removeCssClass($get(this._controlId + '_menu' + i), "selected");
            }
         }
     },
    
    _show: function(lyr) {        var obj;        obj = $get(lyr);        if (obj != null) {            if (obj.style) {                obj.style.display = "";            }        }    },
    
    _hide: function(lyr) {        var obj;        obj = $get(lyr);        if (obj != null) {            if (obj.style) {                obj.style.display = "none";            }        }    },

    dispose: function() {
        
    }
}
IG.subMenuSmall.registerClass('IG.subMenuSmall', null, Sys.IDisposable);

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();