         function Elements( OBJ, TagName ) {
            return OBJ.getElementsByTagName( TagName.toUpperCase() );
         }

         function Element( ID ) { return document.getElementById( ID ); }

         function GetDelta(e) {
            if(!e) e = window.event;

            if( e.wheelDelta )
               delta = e.wheelDelta/120;
            else if( e.detail )
               delta = -e.detail/3;

            return delta;
         }

         function PreventDefault( e ) {
            if( window.event )
               window.event.returnValue = false;
            else if( e )
               e.preventDefault();
         }

         function Gallery( ID, e ) {
            var SELF      = this;

            SELF.gallery   = Element(ID);
            SELF.thumbs      = Elements( SELF.gallery, 'dt' )[0];
            SELF.timer      = null;
            SELF.step      = 5;

            SELF.thumbs.style.overflow   = 'hidden';

            var Images   = Elements( this.gallery, 'img' );
            var count   = Images.length;

            SELF.pic   = Images[--count];

            SELF.pic.style.visibility   = 'hidden';
            SELF.pic.onload   = function() {
               this.style.visibility   = 'visible';
            }

            for(var i=0; i<count; i++) {
                Images[i].onclick   = function(e) {
                   SELF.pic.style.visibility   = 'hidden';
                   SELF.SetPic( this.parentNode.href );
                  PreventDefault(e);
               }
            }

            var Links   = Elements( this.gallery, 'a' );
            var Down   = Links[Links.length - 2];
            var Up      = Links[Links.length - 1];

            Up.onmouseover   = function() {
               SELF.timer   = window.setInterval( function() { SELF.Scroll(1, 5) }, 1 );
            }

            Down.onmouseover   = function() {
               SELF.timer   = window.setInterval( function() { SELF.Scroll(-1, 5) }, 1 );
            }

            Up.onmouseout = Down.onmouseout = function() { window.clearInterval(SELF.timer); }

            SELF.thumbs.onmousewheel = function(e) {
               SELF.Scroll(-GetDelta(e), 20);
               PreventDefault(e);
            }

            if( window.addEventListener ) {
               SELF.thumbs.addEventListener(
                  'DOMMouseScroll',
                  function(e) {
                     SELF.Scroll(-GetDelta(e), 20);
                     PreventDefault(e);
                  },
                  false
               );
            }
         }

         Gallery.prototype.SetPic   = function( SRC ) {
            this.pic.src   = SRC;
         }

         Gallery.prototype.Scroll   = function( DIR, STEP ) {
            this.thumbs.scrollTop += DIR * STEP;
         }
