dojo.require("dojo.fx");

/*******************************************************************************
 * 
 *   SLIDESHOW
 * 
 *******************************************************************************/

dojo.declare("SlideShow", null, {
  /** Path to the images */
  /*String*/ imagePath: null,
  
  /** Array containing all images (file-names) */
  /*String[]*/ images: null,
  
  /** Content-Switch for changing the image */
  /*ContentSwitch*/ containerImage: null,
  
  /** Node containing the current image-number */
  /*Node*/ containerNumber: null,
  
  /** Node containing the total image-count */
  /*Node*/ containerTotalCount: null,
  
  /** Control: Previous */
  /*Node*/ controlPrev: null,
  
  /** Control: Next */
  /*Node*/ controlNext: null,
  
  /** Node containing the thumbnails */
  /*Node*/ containerThumbnails: null,
  
  /** Control: Show thumbnails */
  /*Node*/ controlThumbnails: null,
  
  /** Content-Switch for changing the thumbail-page */
  /*ContentSwitch*/ contSwitchThumbnailPage: null,
  
  /** Connection: Previous. Re-registered on show/hide thumbnails */
  /*Node*/ connectionPrev: null,
  
  /** Connection: Next. Re-registered on show/hide thumbnails */
  /*Node*/ connectionNext: null,
  
  /** Index of current image */
  /*int*/ currentIndex: 0,
  
  /** Current thumbnail-page */
  /*int*/ currentThumbnailPage: 0,
  
  /** Indicates whether the image is changable */
  /*boolean*/ changable: true,
  
  /** Indicates whether the slideshow is playing */
  /*boolean*/ playing: false,
  
  /** Indicates whether the Thumbnails are shown */
  /*boolean*/ thumbsShown: false,
  
  /** Framerate for animations (msec) */
  /*int*/ rate: 30,
  
  /** Path to thubnails-page (without appended page-number) */
  /*String*/ thumbsPath: null,
  
  /** Time to wait between two images in slideshow (msec) */
  /*int*/ waitingDuration: 2000,
  
  /** Unplaced helper-node for play-animation */
  /*Node*/ playHelperNode: null,
  
  /**
   * Creates the slideshow and intiializes controls.
   * @param imagePath - Path to the images (including ending "/")
   * @param images - Array of images in the path 
   * @param containerImageID - ID of container for the actual image
   * @param ctrlPrevID - ID of "previous image"-container
   * @param ctrlNextID - ID of "next image"-container
   * @param ctrlNumbersID - ID of numbers-showing container
   * @param ctrlCurrentNumberID - ID of container showing the current index
   * @param ctrlTotalCountID - ID of container showing the total image-count
   * @param thumbsPath - Path to the thumbnails (including ending "/")
   * @param thumbsID - ID of container to show on "show thumbnails"-click
   * @param ctrlThumbsID - ID of "show thumbnails"-control
   * @param thumbsPageID - ID of the container of the actual thumbnails (content switched on page-change)
   * @param thumbswitchDuration - Duration to animate-in the thumbnails (msec)
   * @param thumbsPerPage - Thumbnail-count per page
   * @param play - Play on init? 
   * @param rate - Framerate of the animation (msec)
   * @param transitionDuration - Duration of switching-image-animation (msec)
   * @param waitingDuration - Time to wait in slideshow (msec)
   */
  constructor: function(/*String*/ imagePath, /*String[]*/ images, /*String*/ containerImageID, 
      /*String*/ ctrlPrevID, /*String*/ ctrlNextID, 
      /*String*/ ctrlNumbersID, /*String*/ ctrlCurrentNumberID, /*String*/ ctrlTotalCountID, 
      /*String*/ thumbsPath, /*String*/ thumbsID, /*String*/ ctrlThumbsID, /*String*/ thumbsPageID, /*int*/ thumbswitchDuration, /*int*/ thumbsPerPage,
      /*boolean*/ play, /*int*/ rate, /*int*/ transitionDuration, /*int*/ waitingDuration) {
    this.currentIndex = -1;
    this.currentThumbnailPage = 0;
    this.changable = true;
    this.thumbsShown = false;
    this.playHelperNode = dojo.create("div");
    
    //settings
    this.playing = play == null ? false : play;
    this.rate = rate == null ? 30 : rate;
    this.waitingDuration = waitingDuration == null ? 2000 : waitingDuration;
    transitionDuration = transitionDuration == null ? 300 : transitionDuration;
    thumbswitchDuration = thumbswitchDuration == null ? 300 : thumbswitchDuration;
    
    //images
    this.imagePath = imagePath;
    this.images = images;
    this.containerImage = new ContentSwitch(containerImageID, "loader", null, false, this.rate, null, transitionDuration, null);
    
    //controls
    if(ctrlPrevID != null) {
      this.controlPrev = dojo.byId(ctrlPrevID);
      this.connectionPrev = dojo.connect(this.controlPrev, "onclick", this, "prevImage");
    }
    if(ctrlNextID != null) {
      this.controlNext = dojo.byId(ctrlNextID);
      this.connectionNext = dojo.connect(this.controlNext, "onclick", this, "nextImage");
    }
    if(ctrlNumbersID != null) {
      this.containerNumbers = dojo.byId(ctrlNumbersID);
      dojo.style(this.containerNumbers, "opacity", "0");
      dojo.style(this.containerNumbers, "display", "block");
    }
    if(ctrlCurrentNumberID != null) {
      this.containerCurrentNumber = dojo.byId(ctrlCurrentNumberID);
    }
    if(ctrlTotalCountID != null) {
      this.containerTotalCount = dojo.byId(ctrlTotalCountID);
      this.containerTotalCount.innerHTML = this.images.length;
    }
    if(thumbsID != null && ctrlThumbsID != null) {
      this.thumbsPath = thumbsPath;
      
      this.containerThumbnails = dojo.byId(thumbsID);
      dojo.style(this.containerThumbnails, "opacity", 0);
      
      this.controlThumbnails = dojo.byId(ctrlThumbsID);
      if(this.controlThumbnails != null) {
        dojo.connect(this.controlThumbnails, "onclick", this, "showThumbnails");
      }
      
      this.thumbsPerPage = thumbsPerPage == null ? 20 : thumbsPerPage;
      
      var loader = dojo.create("div", {id: thumbsID+"loader", innerHTML:""});
      dojo.place(loader, this.containerThumbnails, "first");
      dojo.style(loader, {opacity: 0, display: "none"});
      this.contSwitchThumbnailPage = new ContentSwitch(thumbsPageID, "loader", null, true, this.rate, null, thumbswitchDuration, thumbswitchDuration/2);
    }
    
    //show initial image
    this.showImage(0);
    
    //play slideshow if set
    if(this.playing) {
      this.play();
    }
  },
  
  /**
   * Shows the next image
   * @return void
   */
  nextImage: function() {
    if(this.changable && !this.playing) {
      this.showImage(this.currentIndex+1);
    }
  },
  
  /**
   * Shows the previous image
   * @return void
   */
  prevImage: function() {
    if(this.changable && !this.playing) {
      this.showImage(this.currentIndex-1);
    }
  },

  
  /**
   * Shows the image of the thumbnail, the user clicked on and hides the thumbnail-view.
   * @return void
   */
  thumbClick: function(/*int*/ index) {
    this.thumbsShown = false;
    dojo.disconnect(this.connectionPrev);
    dojo.disconnect(this.connectionNext);
    
    this.connectionPrev = dojo.connect(this.controlPrev, "onclick", this, "prevImage");
    this.connectionNext = dojo.connect(this.controlNext, "onclick", this, "nextImage");
    
    var anim = dojo.fadeOut({node: this.containerThumbnails, rate: this.rate});
    dojo.connect(anim, "onEnd", dojo.hitch(this, "showImage", index));
    anim.play();
    
  },
  
  /**
   * Shows the image with the index
   * @param index - Index of the image to show
   * @param [callbackOnEnd] - Callback-function to run after showing the image
   * @return void
   */
  showImage: function(/*int*/ index, /*function*/ callbackOnEnd) {
    dojo.style(this.containerThumbnails, "display", "none");
    if(this.changable && this.currentIndex != index%this.images.length && this.images.length > 0) {
      this.setUnchangable(); //is setChangable again on callback of the contentSwitch
      //remove disabled-flags from controls
      /*if(this.currentIndex == 0 && this.images.length > 1) {
        dojo.removeClass(this.controlPrev, "disabled");
      }
      if(this.currentIndex == this.images.length-1 && this.images.length > 1) {
        dojo.removeClass(this.controlNext, "disabled");
      }*/
      
      //Change image
      this.currentIndex = (index+this.images.length)%this.images.length;
      var url = this.imagePath + this.images[this.currentIndex];
      if(callbackOnEnd != null) {
        this.containerImage.switchTo(url, callbackOnEnd);
        this.setChangable();
      } else {
        this.containerImage.switchTo(url, dojo.hitch(this, "setChangable"));
      }
      
      //add disabled-flags to controls
      /*if(this.currentIndex == 0 && this.images.length > 1) {
        dojo.addClass(this.controlPrev, "disabled");
      }
      if(this.currentIndex == this.images.length-1 && this.images.length > 1) {
        dojo.addClass(this.controlNext, "disabled");
      }*/
    }
    this.setIndices(this.currentIndex+1, this.images.length);
  },
  
  /**
   * Plays the slideshow. Waits some time by playing an invisible animation
   * before showing the next image.
   * @return void
   */
  play: function() {
    this.playing = true;
    var anim = dojo.animateProperty({
      node: this.playHelperNode,
      duration: this.waitingDuration,
      properties: { height: { end: 0, start:0 }}
    });
    dojo.connect(anim, "onEnd", dojo.hitch(this, "playNext"));
    anim.play();
  },
  
  /**
   * Shows the next image if still playing. 
   * @return void
   */
  playNext: function() {
    if(this.playing) {
      this.showImage(this.currentIndex+1, dojo.hitch(this, "play"));
    }
  },
  
  /**
   * Stops playing the slideshow.
   * @return void
   */
  pause: function() {
    this.playing = false;
  },
  
  /**
   * Sets the slideshow to status "changable"
   * @return void 
   */
  setChangable: function() {
    this.changable = true;
  },

  /**
   * Sets the slideshow to status "unchangable"
   * @return void 
   */
  setUnchangable: function() {
    this.changable = false;
  },
  
  /**
   * Shows the Thumbnails
   * @return void
   */
  showThumbnails: function() {
    if(this.thumbsShown) {
      this.thumbClick(this.currentIndex);
    } else {
      dojo.disconnect(this.connectionPrev);
      dojo.disconnect(this.connectionNext);
      
      this.connectionPrev = dojo.connect(this.controlPrev, "onclick", this, "prevThumbPage");
      this.connectionNext = dojo.connect(this.controlNext, "onclick", this, "nextThumbPage");
      
      this.currentThumbnailPage = Math.floor(this.currentIndex / this.thumbsPerPage); 
      this.showThumbPage(this.currentThumbnailPage);
      this.thumbsShown = true;
    }
  },
  
  /**
   * Switches to the previous thumbnail-page
   * @return void
   */
  prevThumbPage: function() {
    this.showThumbPage(this.currentThumbnailPage-1);
  },
  
  /**
   * Switches to the next thumbnail-page
   * @return void
   */
  nextThumbPage: function() {
    this.showThumbPage(this.currentThumbnailPage+1);
  },
  
  /**
   * Shows the thumbnail-page with the given number
   * @param thumbPage - Page-number of the thumbnail-page
   * @return void
   */
  showThumbPage: function(/*int*/ thumbPage) {
    var pageCount = Math.ceil(this.images.length / this.thumbsPerPage);
    this.currentThumbnailPage = (thumbPage + pageCount) % pageCount;
    var url = this.thumbsPath + this.currentThumbnailPage;
    
    this.contSwitchThumbnailPage.switchTo(url, dojo.hitch(this, function() {
      dojo.style(this.containerThumbnails, "display", "block");
      dojo.fadeIn({node: this.containerThumbnails, rate: this.rate}).play();
    }));
    
    this.setIndices(this.currentThumbnailPage+1, pageCount);
  },
  
  /**
   * Sets the indices indicating the current index and total count.
   * @param current - Current index
   * @param total - Total count
   * @return void
   */
  setIndices: function(/*int*/ current, /*int*/ total) {
    if(this.containerNumbers != null) {
      // Only animate parent
      var animOut = dojo.fadeOut({node: this.containerNumbers, rate: this.rate});
      var animIn  = dojo.fadeIn({node: this.containerNumbers, rate: this.rate});
  
      dojo.connect(animOut, "onEnd", dojo.hitch(this, function(args) {
        this.containerCurrentNumber.innerHTML = args.c;
        this.containerTotalCount.innerHTML = args.t;
      }, {c: current, t: total}));
      
      dojo.fx.chain([animOut, animIn]).play();
    } else {
      // Animate single numbers
      var animCountOut = dojo.fadeOut({node: this.containerCurrentNumber, rate: this.rate});
      var animCountIn  = dojo.fadeIn({node: this.containerCurrentNumber, rate: this.rate});
      var animCount = dojo.fx.chain([animCountOut, animCountIn]);
  
      var animTotalOut = dojo.fadeOut({node: this.containerTotalCount, rate: this.rate});
      var animTotalIn  = dojo.fadeIn({node: this.containerTotalCount, rate: this.rate});
      var animTotal = dojo.fx.chain([animTotalOut, animTotalIn]);
      
      dojo.connect(animCountOut, "onEnd", dojo.hitch(this, function(v) {
        this.containerCurrentNumber.innerHTML = v;
      }, current));
      
      dojo.connect(animTotalOut, "onEnd", dojo.hitch(this, function(v) {
        this.containerTotalCount.innerHTML = v;
      }, total));
      
      if(current != this.containerCurrentNumber.innerHTML && total != this.containerTotalCount.innerHTML) {
        dojo.fx.combine([animCount, animTotal]).play();
      } else if(current != this.containerCurrentNumber.innerHTML) {
        animCount.play();
      } else if(total != this.containerTotalCount.innerHTML) {
        animTotal.play();
      }
    }
  }
});









  /*******************************************************************************
   * 
   *   CONTENT-SWITCH
   * 
   *******************************************************************************/

dojo.declare("ContentSwitch", null, {
  /** Container-Node to swap contents */
  /*Node*/ container: null,
  
  /** Node for Loading-Indicator */
  /*Node*/ loader: null,
  
  /** In-Animation for Loader */
  /*Animation*/ loaderIn: null,
  
  /** Out-Animation for Loader */
  /*Animation*/ loaderOut: null,
  
  /** Function to call after content-in-animation completed */
  /*function*/ callbackFun: null,
  
  /** Indicates whether the content is changable (no animation running) */
  /*boolean*/ changable: true,
  
  /** The currently shown content-url */
  /*String*/ current: null,
  
  /** Wrap around the currently shown content */
  /*Node*/ contentWrap: null,
  
  /** Indicates whether the currently shown content shall animate-out (or just vanish) */
  /*boolean*/ fadeOutContent: true,
  
  /** Framerate for animations (msec) */
  /*int*/ rate: 30,
  
  /** Duration of loader-animation (msec) */
  /*int*/ loaderDuration: 300,
  
  /** Duration of content-in-animation (msec) */
  /*int*/ contentInDuration: 300,
  
  /** Duration of content-out-animation (msec) */
  /*int*/ contentOutDuration: 300,
  
  /**
   * Initializes Content-Switch
   * @param containerID - container-ID to swap the contents in and out
   * @param loaderID - loader-ID to show and hide when indicating a loading-procedure
   * @param [current] - the initially shown content-url
   * @param [fadeOutContent] - True to animate-out old content. False to just let it disappear
   * @param [rate] - Framerate for animations (msec)
   * @param [loaderDuration] - Duration of loader-animation (msec)
   * @param [contentInDuration] - Duration of content-in-animation (msec)
   * @param [contentOutDuration] - Duration of content-out-animation (msec)
   */
  constructor: function(/*String*/ containerID, /*String*/ loaderID, /*String*/current, 
      /*boolean*/ fadeOutContent, /*int*/ rate, /*int*/ loaderDuration, /*int*/ contentInDuration, /*int*/ contentOutDuration) {
    this.content = "";
    this.changable = true;
    
    this.current = current;
    this.container = dojo.byId(containerID);
    this.loader = dojo.byId(loaderID);
    this.callbackFun = null;
    this.fadeOutContent = fadeOutContent == null ? true : fadeOutContent;
    this.rate = rate == null ? 30 : rate;
    this.loaderDuration = loaderDuration == null ? 300 : loaderDuration;
    this.contentInDuration = contentInDuration== null ? 300 : contentInDuration;
    this.contentOutDuration = contentOutDuration == null ? 300 : contentOutDuration;
    
    //animations for loader
    this.loaderIn = dojo.fadeIn({node: this.loader, rate: this.rate, duration: this.loaderDuration});
    this.loaderOut = dojo.fadeOut({node: this.loader, rate: this.rate, duration: this.loaderDuration});
    
    //init (hide) loader
    dojo.style(this.loader, "opacity", 0);
    dojo.style(this.loader, "display", "block");
    
    //wrap content
    var html = this.container.innerHTML;
    this.contentWrap = dojo.create("div", {innerHTML: html});
    dojo.style(this.contentWrap, "opacity", 1);
    dojo.place(this.contentWrap, this.container, "only");
  },
  
  /**
   * Switches content inside the given container
   * @param url - Url to get the content from
   * @param [callbackFun] - function to call after the animation is completed
   * @return void
   */
  switchTo: function(/*String*/ url, /*function*/ callbackFun) {
    //Load new content
    if(this.changable/* && this.current != url*/) {
      //Show loader
      this.showLoader();
      
      this.current = url;
      this.callbackFun = callbackFun;
      dojo.xhrGet({
        url: url,
        handleAs: "text",
        load: dojo.hitch(this, function(response, ioArgs) {
          //this.hideLoader(); // moved into switchContent
          this.switchContent(response);
        }),
        error: function(errorMessage) {
          this.hideLoader();
          console.log(errorMessage);
        }
      });
    }
  },
  
  /**
   * Shows the loader
   */
  showLoader: function() {
    this.loaderOut.stop();
    this.loaderIn.play();
  },
  
  /**
   * Hides the loader
   */
  hideLoader: function() {
    this.loaderIn.stop();
    this.loaderOut.play();
  },
  
  /**
   * Sets the switch to status "changable" 
   */
  setChangable: function() {
    this.changable = true;
  },

  
  /**
   * Sets the switch to status "unchangable" 
   */
  setUnchangable: function() {
    this.changable = false;
  },
  
  /**
   * Inserts the new content
   * @param newContent - content to insert
   * @param [callbackFun] - function to call after the animation is completed
   */
  switchContent: function(/*String*/ newContent) {
    var newContentWrap = dojo.create("div", {innerHTML: newContent});
    dojo.style(newContentWrap, "opacity", "0");
    dojo.place(newContentWrap, this.container, "last");
    
    var onLoadFun = dojo.hitch(this, function(cntWrp) {
      this.hideLoader();
      
      var oldContentAnim = this.contentOutAnim(this.contentWrap); 
      var newContentAnim = this.contentInAnim(newContentWrap);
      
      if(this.fadeOutContent) {
        //chain animation
        var anim = dojo.fx.chain([oldContentAnim, newContentAnim]);
      } else {
        //overlay animation
        var anim = newContentAnim;
      }
      
      dojo.connect(anim, "onEnd", this, dojo.hitch(this, "removeOldContent", cntWrp));
      if(this.callbackFun != null) {
        dojo.connect(anim, "onEnd", this.callbackFun);
      }
      anim.play();
    }, newContentWrap);
    
    
    var imageNodes = dojo.query("img", newContentWrap);
    this.imagesToLoad = new Array(imageNodes.length);
    this.imageCounter = 0;
    imageNodes.forEach(dojo.hitch( this, function(node, index, arr) {
      this.imagesToLoad[index] = new Image();
      dojo.connect(this.imagesToLoad[index], "onload", dojo.hitch(this, "loadImage", onLoadFun));
    }));
    
    imageNodes.forEach(dojo.hitch(this, function(node, index, arr) {
      this.imagesToLoad[index].src = node.src;
    }));
    if(imageNodes.length == 0) {
      onLoadFun();
    }
  },
  
  /**
   * Creates an in-animation for the content
   * @param node - Node to animate-in
   * @return Animation
   */
  contentInAnim: function(/*Node*/ node) {
    var anim = dojo.fadeIn({node: node, rate: this.rate, duration: this.contentInDuration});
    dojo.connect(anim, "onEnd", dojo.hitch(this, "setChangable"));
    return anim;
  },
  
  /**
   * Creates an out-animation for the content
   * @param node - Node to animate-out
   * @return Animation
   */
  contentOutAnim: function(/*Node*/ node) {
    return dojo.fadeOut({node: node, rate: this.rate, duration: this.contentOutDuration, beforeBegin: dojo.hitch(this, "setUnchangable")});
  },
  
  /**
   * Removes the old content from DOM
   * @param ncw - new content Wrap
   * @return void
   */
  removeOldContent: function(ncw) {
    dojo.destroy(this.contentWrap);
    this.contentWrap = ncw;
  },
  
  loadImage: function(/*function*/ onLoadFun) {
    this.imageCounter++;
    if(this.imageCounter >= this.imagesToLoad.length) {
      this.imageCounter = 0;
      onLoadFun();
    }
  }
});








/*******************************************************************************
 * 
 *   MENU
 * 
 *******************************************************************************/

dojo.declare("SubMenu", null, {
  /** Currently open subMenu */ 
  /*Node*/ current: null,
  
  /** All submenus */
  /*Node[]*/ subMenus: null,
  
  /** True if not currently playing an animation.*/
  /*boolean*/ changable: true,
  
  /** Framerate for animations (msec) */
  /*int*/ rate: 30,
  
  /** Duration of loader-animation (msec) */
  /*int*/ duration: 300,
  
  /**
   * Registers events for anchors.  
   * @param anchors - anchors to register events on 
   * @param subMenus - all submenu-ids corresponding to the anchors
   * @param [current] - currently open submenu-id
   * @param [classNameActiveMenu] - CSS-class to add on click
   */
  constructor: function(/*String[]*/ anchors, /*String[]*/ subMenus, /*String*/current, /*int*/ rate, /*int*/ duration, /*String*/ classNameActiveMenu) {
    this.classNameActiveMenu = classNameActiveMenu == null ? "menuActive" : classNameActiveMenu;
    this.current = current;
    this.currentAnchor = null;
    this.subMenus = subMenus;
    this.changable = true;
    this.rate = rate == null ? 30 : rate;
    this.duration = duration == null ? 300 : duration;

    //register events
    for(var i=0; i<anchors.length && i<subMenus.length; i++) {
      dojo.connect(dojo.byId(anchors[i]), "onclick", this, dojo.hitch(this, "show", {submenu: subMenus[i], anchor: anchors[i]}));
      if(current == subMenus[i]) {
        this.currentAnchor = anchors[i];
        dojo.addClass(this.currentAnchor, this.classNameActiveMenu);
        dojo.style(subMenus[i],"opacity","1");
      } else {
        dojo.style(subMenus[i],"opacity","0");
      }
    }
    
    //animate-in initial submenu
    /*if(current != null) {
      //dojo.style(current,"opacity","0");
      dojo.style(current,"display","block");
      //dojo.fadeIn({node: dojo.byId(current)}).play();
    }*/
  },
  
  /**
   * Hides the old submenu, shows the new one (only if changable)
   * @param arg - property-bag with:
   *    submenu - the new submenu (id) to show
   *    anchor - the anchor (id) of which the class needs to be changed
   * @return void
   */
  show: function(/*Object*/ arg) {
    var submenu = arg.submenu;
    var anchor = arg.anchor;
    if(this.changable && this.current != submenu) {
      this.changable = false;
      var cur = this.current;
      
      if(this.currentAnchor != null) {
        dojo.removeClass(this.currentAnchor, this.classNameActiveMenu);
      }
      this.currentAnchor = anchor;
      dojo.addClass(this.currentAnchor, this.classNameActiveMenu);
      
      var animNew = dojo.fadeIn({
        node: dojo.byId(submenu), 
        rate: this.rate, 
        duration: this.duration
      });

      dojo.connect(animNew, "beforeBegin", dojo.hitch(this, "unhide", submenu));
      dojo.connect(animNew, "onEnd", dojo.hitch(this, "completeShow", submenu));
      
      
      if(cur == null) { //Don't remove current, if no current available
        animNew.play();
      } else {          //Remove old first, then show new 
        var animOld = dojo.fadeOut({
          node: dojo.byId(cur),
          rate: this.rate,
          duration: this.duration
        });
        dojo.connect(animOld, "onEnd", dojo.hitch(this, "hide", cur));
        dojo.fx.chain([
          animOld,
          animNew
        ]).play();
      }
    }
  },
  
  /**
   * Completes the switching-procedure by setting new "current" and making it changable again
   * @param next - new "current"
   * @return void
   */
  completeShow: function(next) {
    this.current = next;
    this.changable = true;
  },

  /**
   * hides old submenu
   * @param toHide - submenu to hide
   * @return void
   */
  hide: function(toHide) {
    dojo.style(toHide,"display","none");
  },
  
  /**
   * Unhides new submenu
   * @param toUnhide - submenu to unhide
   * @return void
   */
  unhide: function(/*String*/ toUnhide) {
    dojo.style(toUnhide,"display","block");
  }
});
