modules.loadActions.prototype.gallery = function(){
  
  gallery = this.gallery;
  gallery.rotatorClassName = 'rotator';
  gallery.carouselClassName = 'carousel';
  gallery.browseClassName = 'browse';
  gallery.moduleConfig = SiteVars.modules.Gallery;
  gallery.loaded = false;
  gallery.currentPage = 1;
  gallery.perPage = 5;
  gallery.currentIndex = 0;
  gallery.pages = Math.ceil(gallery.moduleConfig.gallerySize / gallery.perPage); 
  gallery.reset = false;
  gallery.paused = false;
  gallery.galleryXML = SiteVars.modules.Gallery.galleryXML;
  
  
  // remainder
  gallery.remainder = (gallery.perPage * gallery.pages) - gallery.moduleConfig.gallerySize;
  
  
  if (gallery.moduleConfig.gallerySize == 1) {
   return; 
  }
  
  
  
  /* Rotator Functions */
  
  //alert($$('.imagelist')[0].offsetLeft);
  
  
  //{{{ gallery.rotatorLoad = function()
  gallery.rotatorLoad = function(){
    
    gallery.allRotators = $$('.'+gallery.rotatorClassName);
    gallery.allRotators.each(function(rotator){
        //set the properties of the rotator
        //controls
        rotator.rHandler = Element.select(rotator, '.responsehandler')[0];
        rotator.countDown = 10;
        rotator.endFlag = false;
        
        //full view
        rotator.imageArea    = Element.select(rotator, '.imagearea')[0];
        rotator.fullImage    = Element.select(rotator, '.fullimage')[0];
        rotator.imgContainer = Element.select(rotator, '.container')[0];
        rotator.imageTitle   = Element.select(rotator, 'h1')[0];
        rotator.credit       = Element.select(rotator, '.credit')[0];
        rotator.description  = Element.select(rotator, '.description')[0];
        rotator.btnWrap      = Element.select(rotator, '.button-wrapper')[0];
        rotator.btn          = Element.select(rotator.btnWrap, 'a.button-style')[0];
        
        //panels
        rotator.panels      = Element.select(rotator, '.panel');
        rotator.activePanel = Element.select(rotator, '.activepanel')[0];
        
        //rotator strip properties
        rotator.strip    = Element.select(rotator, '.imagelist')[0];
        
        rotator.strip.xDistance    = 86 * gallery.perPage;
        rotator.strip.sliding      = false
        
        
        //load up the behaviors
        gallery.rotatorPanelBehavior(rotator);
        
        //console.dir(rotator);
        
    });
    
  } //}}}
  
  //{{{ gallery.rotatorPanelBehavior = function(rotator)
  gallery.rotatorPanelBehavior = function(rotator){
    
    rotator.panels.each(function(panel){
        
        panel.parentLi = Element.ancestors(panel)[0];
        
        if(panel.title){
          panel.getAjaxDirective.sendMethod='get';
          panel.getAjaxDirective = modules.sanitizeResponse(panel.title, {});
          panel.getAjaxDirective.updateElem = rotator.rHandler;
          panel.getAjaxDirective.onLoad = function(){
            //do nothing
          }
          panel.getAjaxDirective.onSuccess = function(){
            //do nothing
          }
          panel.getAjaxDirective.onComplete = function(){
            rotator.endFlag = (panel == rotator.panels.last() && gallery.moduleConfig.endOnLast == 'true' || rotator.endFlag==true) ? true : false;
            
            
            if( Element.select(rotator.rHandler, '.fullvideo') ) {
               gallery.rotatorParserVideo(rotator);
            } else {
               gallery.rotatorParser(rotator);
            }
            
            
          }
          panel.removeAttribute('title');
          
          
          Event.observe(panel, 'click', function(e){
              gallery.rotatorImageLoad(rotator, panel)
              panel.blur();
              Event.stop(e);
          });
        }
    });
    
    /* Set the initial timer functions */
    if (gallery.reset == false) {
      rotator.generateTimer = gallery.rotatorSetRotation(rotator);
    }
    
  } //}}}

  //{{{ gallery.rotatorSetRotation = function(rotator)
  gallery.rotatorSetRotation = function(rotator){
    window.setInterval(function(){
        
        if(rotator.endFlag == true || gallery.paused == true){
          //do nothing
        }
        else if(rotator.countDown >= 1 ){
          rotator.countDown--;
        }
        else if(rotator.countDown == 0){
          rotator.countDown = 'stop';
          gallery.rotatorDoRotation(rotator)
        }
        
    }, 800, [rotator]);
  } //}}}

  
  //{{{ gallery.rotatorDoRotation = function(rotator)
  gallery.rotatorDoRotation = function(rotator){
    
    for(x=0; x<=rotator.panels.length; x++){
      
      
     // gallery loaded complete, we just need to slide to the next page
     if (x==rotator.panels.length-1 && rotator.endFlag == false 
            && gallery.currentPage <  gallery.pages
            && gallery.loaded == false  ) {
      
          gallery.currentPage++;
          if (gallery.currentPage > gallery.pages) {
              gallery.currentPage = 1; 
          }          
          
          
          
          var pfx = SiteVars.path_to_top;
          if (CoreSiteVars && CoreSiteVars.cmscontext == 'staging') {
            pfx = '/' + CoreSiteVars.cmscontext; 
          }
          
          
          
          
          var opts = {
            sendMethod:'get',
            url: pfx + '/gallery/ajaxpage?async=true',
            params:'pageNumber=' +  gallery.currentPage + '&galleryXML=' + gallery.galleryXML
          };
          
        
          opts.onComplete = function(res) {

             var elem = new Element('div');
             elem.innerHTML = res.responseText;
             
             
             //$$('.imagelist')[0].innerHTML =  Element.select(elem, '.imageset')[0].innerHTML;
             
             Element.removeClassName( Element.select(rotator, '.activepanel')[0], 'activepanel');
             Element.insert($$('.imagelist')[0], { bottom: Element.select(elem, '.imageset')[0].innerHTML  });
             
             
             // reset
             gallery.reset = true;
             gallery.rotatorLoad();
             gallery.rotatorSlideNext(rotator);
             
             
             
             
            for(z=0; z<=rotator.panels.length; z++){
              if(rotator.panels[z].parentLi == rotator.activePanel && rotator.endFlag == false){
                
                gallery.rotatorImageLoad(rotator, rotator.panels[z]);
                gallery.currentIndex = 0;
                rotator.countDown = 10;
                
                break;
              }
            }
            
            
            // now reset
            if (gallery.currentPage >= gallery.pages) {
              gallery.currentPage = 1; // reset 
              gallery.currentIndex = 0;
              gallery.loaded = true;
            }
            
            
             
          } 
                  
          modules.sendAsync(opts);
           
           
        break;
      } else if(x==rotator.panels.length-1 && rotator.endFlag == false) {
        
        
        if (gallery.pages > 1) {        
          gallery.rotatorSlideFirst(rotator);
        }
        
        gallery.rotatorImageLoad(rotator, rotator.panels[0]);
        gallery.currentIndex = 0;
        rotator.countDown = 10;
        
        break;
      } else if(rotator.panels[x].parentLi == rotator.activePanel && rotator.endFlag == false){
       
        
        
        // which page are we on?
        gallery.currentIndex++;        
        
        var curpage = Math.ceil(x/ gallery.perPage);
        
        
        
        
        
        if (curpage > gallery.pages) {
          
           gallery.currentPage = 1;
           rotator.countDown = 10;
           gallery.currentIndex = 0;
           
           gallery.rotatorSlideFirst(rotator);

        } else if ((gallery.currentIndex - 1) >= gallery.perPage || ((x + 1) % gallery.perPage) == 0) {
          // 5 and 5
          //alert('sliding next ' + gallery.currentIndex + ' and ' + gallery.perPage);
          //alert('or ' + ((x + 1) % gallery.perPage));
          
          
          gallery.currentIndex = 0;  
          gallery.rotatorSlideNext(rotator);
            
        } 
        
  
        gallery.rotatorImageLoad(rotator, rotator.panels[x+1]);
        
        
        break;
      }
    }
    
  } //}}}
  
  
  gallery.rotatorSlideFirst = function(rotator) {
      
      
      
     // gatta fix this!
      //nextDistance = rotator.strip.xDistance; //(Element.getWidth($$('.imagelist')[0]) -  rotator.strip.xDistance) + 8;
      
      
      // move back to current position
      
      
      var d = $$('.imagelist')[0];
      nextDistance = d.offsetLeft * -1;
      
      // get remainder and subtract that
      
      

      
      new Effect.Move(rotator.strip, { 
            duration:.5,
            fps:100,
            x:nextDistance, 
            y:0,
            beforeStart:function(){
              rotator.strip.highVisible++;
              rotator.strip.lowVisible++;

            },
            afterFinish:function(){
              gallery.carouselPanelLoad(rotator);
              rotator.strip.sliding = false;
            }
          });    
  }
  
  gallery.rotatorSlideNext = function(rotator) {
      nextDistance = rotator.strip.xDistance * -1;
      rotator.strip.sliding = true;
      
      
      
      
      new Effect.Move(rotator.strip, { 
            duration:.5,
            fps:100,
            x:nextDistance, 
            y:0,
            beforeStart:function(){
              rotator.strip.highVisible++;
              rotator.strip.lowVisible++;
              /*
              if(Element.hasClassName(rotator.bPrev, 'inactive')){
                Element.removeClassName(rotator.bPrev, 'inactive');
                Element.setOpacity(rotator.bPrev, 1);
              }
              if(rotator.strip.highVisible == rotator.strip.totalCount){
                Element.addClassName(rotator.bNext, 'inactive');
                Element.setOpacity(rotator.bNext, 0.4);
              }
              */
            },
            afterFinish:function(){
              gallery.carouselPanelLoad(rotator);
              rotator.strip.sliding = false;
            }
          });
  }  
  
  
  //{{{ gallery.rotatorPanelLoad = function(rotator)
  gallery.rotatorImageLoad = function(rotator, panel){
    
    Element.removeClassName(rotator.activePanel, 'activepanel');
    
    
    
    Element.addClassName(panel.parentLi, 'activepanel');
    
    Element.setStyle(rotator.activePanel, {
       /* backgroundColor:'#fff', */ 
        color:'rgb(212,112,118)'
    });    
    
    
    Element.setStyle(panel.parentLi, {
     /*   backgroundColor:'rgb(147,28,35)', */
        color:'#fff'
    });
    
    
    Element.addClassName(rotator.imageArea, 'loading');
    rotator.activePanel = panel.parentLi;

    Effect.Fade(rotator.fullImage, {
      duration:.5,
      fps:100,
      from:1.0,
      to:0.01,
      afterFinish:function(){
        modules.sendAsync(panel.getAjaxDirective);
      }
    });
  } //}}}
  
  
 
  gallery.rotatorParserVideo = function(rotator){
    
    var newImage = Element.select(rotator.rHandler, '.fullimage')[0]
    //var imgSrc = Element.select(newImage, 'img')[0];
    //var preLoad = new Image();
    //preLoad.src = imgSrc.src;
    
    rotator.fullImage.innerHTML = newImage.innerHTML;
    rotator.fullImage.className = newImage.className;
    
    
    
    Effect.Appear(rotator.fullImage, {
        duration:.5,
        fps:100,
        from:0.01,
        to:1.0,
        afterFinish:function(){
          Element.removeClassName(rotator.imageArea, 'loading');
        }
    });
    
 
    rotator.rHandler.innerHTML='';
    rotator.countDown = 10;
 
    
  } //}}}  
  
  //{{{ gallery.rotatorParser = function(rotator)
  gallery.rotatorParser = function(rotator){
    
    var newImage = Element.select(rotator.rHandler, '.fullimage')[0]
    var imgSrc = Element.select(newImage, 'img')[0];
    
    var preLoad = new Image();
    preLoad.src = imgSrc.src;
    
    rotator.fullImage.innerHTML = newImage.innerHTML;
    rotator.fullImage.className = newImage.className;
    
    Effect.Appear(rotator.fullImage, {
        duration:.5,
        fps:100,
        from:0.01,
        to:1.0,
        afterFinish:function(){
          Element.removeClassName(rotator.imageArea, 'loading');
        }
    });
    /*
    rotator.imageTitle.innerHTML   = Element.select(rotator.rHandler, 'h1')[0].innerHTML;
    rotator.description.innerHTML  = Element.select(rotator.rHandler, '.description')[0].innerHTML;
    
    rotator.newBtn = Element.select(rotator.rHandler, '.button-style')[0];
    rotator.btn.href = rotator.newBtn.href;
    rotator.btn.innerHTML = rotator.newBtn.innerHTML;
    */
    
    rotator.rHandler.innerHTML='';
    
    rotator.countDown = 10;
    
    //Fix for IE6 nav issues
    /* if(topNav.backVersion < 8 && topNav.backVersion != false){
      topNav.rebuild();
    } */
    
    /* DD_roundies.addRule('ol.imagelist li', '12px');
    DD_roundies.addRule('a.button-style', '7px'); */
    //Cufon.replace('h1');
    //Cufon.now(); 
    
    
  } //}}}
  
  
  /* Carousel Functions */
  
  //{{{ gallery.carouselLoad = function()
  gallery.carouselLoad = function(){
    
    gallery.allCarousels = $$('.'+gallery.carouselClassName);
    gallery.allCarousels.each(function(carousel){
        //set the properties of the carousel
        //controls
        carousel.bPrev    = Element.select(carousel, '.carouselprev')[0];
        carousel.bNext    = Element.select(carousel, '.carouselnext')[0];
        carousel.rHandler = Element.select(carousel, '.responsehandler')[0];
        
        //full view
        carousel.imageArea    = Element.select(carousel, '.imagearea')[0];
        carousel.fullImage    = Element.select(carousel, '.fullimage')[0];
        carousel.imgContainer = Element.select(carousel, '.container')[0];
        carousel.imageTitle   = Element.select(carousel, 'h3')[0];
        carousel.credit       = Element.select(carousel, '.credit')[0];
        carousel.description  = Element.select(carousel, '.description')[0];
        
        //panels
        carousel.panels      = Element.select(carousel, '.panel');
        carousel.activePanel = Element.select(carousel, '.activepanel')[0];
        
        //carousel strip properties
        carousel.strip    = Element.select(carousel, '.imagelist')[0];

        //load up the behaviors
        gallery.carouselPanelBehavior(carousel);
        gallery.carouselStripBehavior(carousel);
        
        //console.dir(carousel);
        
    });
    
  } //}}}
  
  //{{{ gallery.carouselPanelBehavior = function(carousel)
  gallery.carouselPanelBehavior = function(carousel){
    carousel.panels.each(function(panel){
        
        panel.parentLi = Element.ancestors(panel)[0];
        
        if(panel.title){
          panel.getAjaxDirective.sendMethod='get';
          panel.getAjaxDirective = modules.sanitizeResponse(panel.title, {});
          panel.getAjaxDirective.updateElem = carousel.rHandler;
          panel.getAjaxDirective.onLoad = function(){
            //do nothing
          }
          panel.getAjaxDirective.onSuccess = function(){
            //do nothing
          }
          panel.getAjaxDirective.onComplete = function(){
            gallery.carouselParser(carousel);
          }
          panel.removeAttribute('title');
          
          
          Event.observe(panel, 'click', function(e){
              
              Element.removeClassName(carousel.activePanel, 'activepanel');
              Element.addClassName(panel.parentLi, 'activepanel');
              Element.addClassName(carousel.imageArea, 'loading');
              carousel.activePanel = panel.parentLi;
              gallery.paused = false;
              
              
              Effect.Fade(carousel.fullImage, {
                duration:.5,
                fps:100,
                from:1.0,
                to:0.01,
                afterFinish:function(){
                  modules.sendAsync(panel.getAjaxDirective);
                }
              });
              
              Event.stop(e);
          });
        }
    });
  } //}}}
  
  //{{{ gallery.carouselStripBehavior = function(carousel)
  gallery.carouselStripBehavior = function(carousel){
    
    carousel.strip.startNum     = 1;
    carousel.strip.lowVisible   = 1;
    carousel.strip.highVisible  = parseInt(gallery.moduleConfig.panelWindowSize);
    carousel.strip.totalVisible = parseInt(gallery.moduleConfig.panelWindowSize);
    carousel.strip.buffer       = parseInt(gallery.moduleConfig.buffer);
    carousel.strip.totalCount   = parseInt(gallery.moduleConfig.gallerySize);
    carousel.strip.xDistance    = 85 * gallery.perPage; // TODO: CHANGE THIS
    carousel.strip.sliding      = false
    //carousel.strip.style.width = 480;
    
    Element.setOpacity(carousel.bPrev, 0.4);
    if(carousel.strip.highVisible > carousel.strip.totalCount){
      Element.addClassName(carousel.bNext, 'inactive');
    }
    
    Event.observe(carousel.bNext, 'click', function(e){
        if(carousel.strip.highVisible < carousel.strip.totalCount && carousel.strip.sliding == false){
          nextDistance = carousel.strip.xDistance * -1;
          carousel.strip.sliding = true;
          
          new Effect.Move(carousel.strip, { 
            duration:.5,
            fps:100,
            x:nextDistance, 
            y:0,
            beforeStart:function(){
              carousel.strip.highVisible++;
              carousel.strip.lowVisible++;
              if(Element.hasClassName(carousel.bPrev, 'inactive')){
                Element.removeClassName(carousel.bPrev, 'inactive');
                Element.setOpacity(carousel.bPrev, 1);
              }
              if(carousel.strip.highVisible == carousel.strip.totalCount){
                Element.addClassName(carousel.bNext, 'inactive');
                Element.setOpacity(carousel.bNext, 0.4);
              }
            },
            afterFinish:function(){
              gallery.carouselPanelLoad(carousel);
              carousel.strip.sliding = false;
            }
          });
          //Event.stop(e);
        }
    });
    
    Event.observe(carousel.bPrev, 'click', function(e){
        if(carousel.strip.lowVisible > 1 && carousel.strip.sliding == false){
          prevDistance = carousel.strip.xDistance * 1;
          carousel.strip.sliding = true;
          new Effect.Move(carousel.strip, { 
            duration:.5,
            fps:100,
            x:prevDistance, 
            y:0,
            beforeStart:function(){
              carousel.strip.highVisible--;
              carousel.strip.lowVisible--;
              if(Element.hasClassName(carousel.bNext, 'inactive')){
                Element.removeClassName(carousel.bNext, 'inactive');
                Element.setOpacity(carousel.bNext, 1);
              }
              if(carousel.strip.lowVisible == 1){
                Element.addClassName(carousel.bPrev, 'inactive');
                Element.setOpacity(carousel.bPrev, 0.4);
              }
            },
            afterFinish:function(){
              carousel.strip.sliding = false;
            }
          });
          //Event.stop(e); 
        }
    });
    
  } //}}}
  
  //{{{ gallery.carouselPanelLoad = function(carousel)
  gallery.carouselPanelLoad = function(carousel){
    //console.log(carousel.strip.highVisible + carousel.strip.buffer);
    //not ready for optimized page yet
  } //}}}
  
  //{{{ gallery.carouselParser = function(carousel)
  gallery.carouselParser = function(carousel){
    
    var newImage = Element.select(carousel.rHandler, '.fullimage')[0]
    var imgSrc = Element.select(newImage, 'img')[0];
    
    carousel.fullImage.innerHTML = newImage.innerHTML;
    carousel.fullImage.className = newImage.className;
    
    Effect.Appear(carousel.fullImage, {
        duration:.5,
        fps:100,
        from:0.01,
        to:1.0,
        afterFinish:function(){
          Element.removeClassName(carousel.imageArea, 'loading');
        }
    });
    
    carousel.imageTitle.innerHTML   = Element.select(carousel.rHandler, 'h3')[0].innerHTML;
    carousel.credit.innerHTML       = Element.select(carousel.rHandler, '.credit')[0].innerHTML;
    carousel.description.innerHTML  = Element.select(carousel.rHandler, '.description')[0].innerHTML;
    
    carousel.rHandler.innerHTML='';
    
  } //}}}
  
  
  /* Lightbox extensions (extends base object at lightbox.js)*/
  
  //{{{ gallery.extendLightbox = function()
  gallery.extendLightbox = function(){

    //The following functions are only extending the lightbox object in order to deal with the addition of the hi-res download link, the cms-specific locations of the icons and the translation of text output
    //the following functions have been overriden:
    //  - initialize()
    //  - start()
    //  - updateDetails()
    
    // Also, the final line has been commented out of lightbox.js ( document.observe ... ) and call to the new Lightbox(); is being made here
    
    LightboxOptions.fileLoadingImage = '../template_images/gallery/loading.gif';
    LightboxOptions.fileBottomNavCloseImage = '../template_images/gallery/closelabel.gif';
    LightboxOptions.labelImage = gallery.moduleConfig.phrases.labelImage;
    LightboxOptions.labelOf = gallery.moduleConfig.phrases.labelOf;
    
    //{{{ Lightbox.prototype.initialize = function()
    Lightbox.prototype.initialize = function() {    
        
      this.updateImageList();
      
      this.keyboardAction = this.keyboardAction.bindAsEventListener(this);
  
      if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10;
      if (LightboxOptions.resizeSpeed < 1)  LightboxOptions.resizeSpeed = 1;
  
      this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0;
      this.overlayDuration = LightboxOptions.animate ? 0.2 : 0;  // shadow fade in/out duration

      var size = (LightboxOptions.animate ? 250 : 1) + 'px';
      var objBody = $$('body')[0];
      
      
        objBody.appendChild(Builder.node('div',{id:'overlay'}));
      
            objBody.appendChild(Builder.node('div',{id:'lightbox'}, [
                Builder.node('div',{id:'outerImageContainer'}, 
                    Builder.node('div',{id:'imageContainer'}, [
                        Builder.node('img',{id:'lightboxImage'}), 
                        Builder.node('div',{id:'hoverNav'}, [
                            Builder.node('a',{id:'prevLink', href: '#' }),
                            Builder.node('a',{id:'nextLink', href: '#' })
                        ]),
                        Builder.node('div',{id:'loading'}, 
                            Builder.node('a',{id:'loadingLink', href: '#' }, 
                                Builder.node('img', {src: LightboxOptions.fileLoadingImage})
                            )
                        )
                    ])
                ),
                Builder.node('div', {id:'imageDataContainer'},
                    Builder.node('div',{id:'imageData'}, [
                        Builder.node('div',{id:'imageDetails'}, [
                            Builder.node('span',{id:'caption'}),
                            Builder.node('span',{id:'numberDisplay'}),
                            Builder.node('a',{id:'hireslink', href: '#', target:'_blank'},gallery.moduleConfig.phrases.downloadText)
                        ]),
                        Builder.node('div',{id:'bottomNav'},
                            Builder.node('a',{id:'bottomNavClose', href: '#' },
                                Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage })
                            )
                        )
                    ])
                )
            ]));
      
      
      Event.observe($('hireslink'), 'click', function(e){
        
        var image = $('lightboxImage');
        var newLocation = image.src.substring(0, image.src.indexOf('?'))
        
        $('hireslink').href = newLocation;
        
        //Event.stop(e);
      });
          
      
      $('overlay').hide().observe('click', (function() { this.end(); }).bind(this));
      $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this));
      //$('outerImageContainer').setStyle({ width: size, height: size });
      $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this));
      $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this));
      $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this));
      $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this));
  
          var th = this;
          (function(){
              var ids = 
                  'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 
                  'imageDataContainer imageData imageDetails caption numberDisplay hireslink bottomNav bottomNavClose';   
              $w(ids).each(function(id){ th[id] = $(id); });
          }).defer();
      } //}}}
      
    //{{{ Lightbox.prototype.start = function(imageLink)
    Lightbox.prototype.start = function(imageLink) {    

        $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });

        // stretch overlay to fill page and fade in
        var arrayPageSize = this.getPageSize();
        $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });

        new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity });

        this.imageArray = [];
        var imageNum = 0;       

        if ((imageLink.rel == 'lightbox')){
            // if image is NOT part of a set, add single image to imageArray
            this.imageArray.push([imageLink.href, imageLink.title]);         
        } else {
            // if image is part of a set..
            this.imageArray = 
                $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]').
                collect(function(anchor){ return [anchor.href, anchor.title, anchor.className]; }).
                uniq();
            
            while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; }
        }

        // calculate top and left offset for the lightbox 
        var arrayPageScroll = document.viewport.getScrollOffsets();
        var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
        var lightboxLeft = arrayPageScroll[0];
        this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();
        
        this.changeImage(imageNum);
      } //}}}
      
    //{{{ Lightbox.prototype.updateDetails = function()
    Lightbox.prototype.updateDetails = function() {
        //if allowdownload classname is present
        //console.log(this.imageArray[this.activeImage][2]);
        if (this.imageArray[this.activeImage][2].indexOf('allowdownload') != -1){
            $('hireslink').show();
        }
        else{
          $('hireslink').hide();
        }
        
        // if caption is not null
        if (this.imageArray[this.activeImage][1] != ""){
            this.caption.update(this.imageArray[this.activeImage][1]).show();
        }
        
        // if image is part of set display 'Image x of x' 
        if (this.imageArray.length > 1){
            this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + '  ' + this.imageArray.length).show();
        }

        new Effect.Parallel(
            [ 
                new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), 
                new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) 
            ], 
            { 
                duration: this.resizeDuration, 
                afterFinish: (function() {
                  // update overlay size and update nav
                  var arrayPageSize = this.getPageSize();
                  this.overlay.setStyle({ height: arrayPageSize[1] + 'px' });
                  this.updateNav();
                }).bind(this)
            } 
        );
      } //}}}

      
      new Lightbox();
  } //}}}
  
  if($$('.'+gallery.rotatorClassName)[0]){
    gallery.rotatorLoad();
  }
  
  if($$('.'+gallery.carouselClassName)[0]){
    gallery.carouselLoad();
  }
  
  if($$('.'+gallery.browseClassName)[0]){
    gallery.extendLightbox();
  }
  
}




