/*
* EON CSS Image gallery
* 0.95b
* Copyright(c) 2007, Blue Skies information Services
* 
*/
jQuery.noConflict();

(function($) {
   jQuery.delayedTask = function(fn, scope, args) {
      var nTimeoutId = null; this.delay = function(time, newFn, newScope, newArgs) {
         if(nTimeoutId) {
            clearTimeout(nTimeoutId); }
         fn = newFn || fn; scope = newScope || scope; args = newArgs || args; nTimeoutId = setTimeout(function() {
            fn.call(scope, args); }
         , time); }
      this.cancel = function() {
         if(nTimeoutId) {
            clearTimeout(nTimeoutId); nTimeoutId = null; }
         }
      }
   jQuery.fn.stop = function() {
      this.each(function() {
         jQuery.dequeue(this, "fx"); }
      ); return this; }; }
)(jQuery); 
function hImgRes(src) {
   this.src = src; 
   this.loaded = false; 
   this.loading = false; 
   this.toString = function() {
      return this.src}; 
   }
jQuery.eonGallery = {
   aMessages : {
      missingList : 'The list with images is missing'}
   , bDebug : false, build : function(hOptions) {
      return this.each(function() {
         var hG = this; if(!this.id) {
            this.id = 'eonTestGallery_' + (jQuery.eonGallery.counter++); }
         var sId = this.id; var heonGalleryOptions = {
            width : 500, height : 380, containerTag : 'div', containerClass : 'eonGallery', imageHolderClass : 'eonImageHolder', prevLinkText : 'previous', nextLinkText : 'next', playLinkText : 'play', pauseLinkText : 'pause', prevLinkClass : 'eonPrevious', nextLinkClass : 'eonNext', playLinkClass : 'eonPlay', pauseLinkClass : 'eonPause', swapImageClass : 'eonSwap', thumbWidth : 95, thumbHeight : 80, thumbPadding : 5, thumbHolderHeight : 80, thumbHolderWidth : 'auto', thumbHolderPosition : 'right', thumbHolderHorizontal : false, thumbHolderVertical : true, thumbShowOnHover : false, thumbListHidden : true, captionPosition : 'top', playerDelay : 3, autoPlay : false, showInfoMessage : false, autosize : true, loaded : 0, messageHidden : true, captionOpacity : 40, imgIndex : 0, preloadTreshold : 2, allPreloaded : false}
         if(hOptions) {
            hG.options = jQuery.extend(heonGalleryOptions, hOptions); }
         jQuery(this).attr('tabIndex', - 1); var hList = jQuery('ul', this); if(hList.length == 0) {
            jQuery.eonGallery.debug(jQuery.eonGallery.aMessages.missingList); return; }
         var hHolder = jQuery('.' + heonGalleryOptions.imageHolderClass, this); if(hHolder.length == 0) {
            hHolder = jQuery('<div class="' + heonGalleryOptions.imageHolderClass + '">').append(jQuery('ul', this)).appendTo(jQuery(this)); }
        jQuery(this).height(heonGalleryOptions.height + 'px'); jQuery(this).width(heonGalleryOptions.width + 'px'); hG.thumbList = []; hG.imageList = []; jQuery(hHolder).find('ul').css('display', 'none'); jQuery(hHolder).find('ul li').each(function(nI) {
            hG.imageList.push(new hImgRes(jQuery(this).find('.image').attr('src'))); jQuery('img', this).remove(); }
         )
				var hThumbList = jQuery('#' + sId + '_thumb'); if(hThumbList.length > 0) {
            jQuery(hThumbList).find('ul li').each(function(nI) {
               hG.thumbList.push(new hImgRes(jQuery(this).find('img').attr('src'))); }
            );jQuery(hThumbList).empty(); }
         else {
            hG.thumbList = hG.imageList; }
         hThumbList = jQuery.eonGallery.buildThumbnailList(hG); jQuery.eonGallery.buildMessage(hG); hG.options.messageHide = new jQuery.delayedTask(function() {
            jQuery.eonGallery.doHideMessage(hG)}
         )
			jQuery.eonGallery.buildImageHolders(hG); jQuery.eonGallery.buildCaption(hG); jQuery.eonGallery.buildGalleryNavigation(hG); jQuery.eonGallery.buildWaiting(hG); window.setTimeout(function() {
            jQuery.eonGallery.showImage(hG, 0)}
         , 10); jQuery.eonGallery.showMessage(hG, 'loading images...'); jQuery.eonGallery.hideMessage(hG); hG.options.player = new jQuery.delayedTask(function() {
            jQuery.eonGallery.nextImage(hG); jQuery.eonGallery.play(hG)}
         ); this.focus(); jQuery(hG).keydown(function(event) {
            jQuery.event.fix(event); if(event.keyCode == 37) {
               jQuery.eonGallery.previousImage(hG); }
            if(event.keyCode == 39) {
               jQuery.eonGallery.nextImage(hG); }
            }
         ); hG.options.thumbsHide = new jQuery.delayedTask(function() {
            jQuery.eonGallery.hideThumbnailList(hG); }
         ); hG.options.thumbsShow = new jQuery.delayedTask(function() {
            jQuery.eonGallery.showThumbnailList(hG); }
         ); jQuery(hG).hover(function(event) {
            jQuery.event.fix(event); if(hG.options.thumbShowOnHover) {
               hG.options.thumbsHide.cancel(); hG.options.thumbsShow.delay(100); }
            }
         , function(event) {
            jQuery.event.fix(event); if(hG.options.thumbShowOnHover &&!hG.options.swapping) {
               hG.options.thumbsShow.cancel(); hG.options.thumbsHide.delay(400); }
            }
         ); jQuery(hThumbList).keydown(function(event) {
            jQuery.event.fix(event); if(event.keyCode == 37) {
               jQuery.eonGallery.scrollThumbnailList(hG, 'left'); }
            if(event.keyCode == 39) {
               jQuery.eonGallery.scrollThumbnailList(hG, 'right'); }
            }
         ); jQuery(this).bind('focus', function() {
            jQuery(this).addClass('eonGalleryFocused')}
         ); if(hG.options.autoPlay) {
            jQuery.eonGallery.play(hG); }
         }
      ); 
      }
   , pngFix : function(elm) {
      if(jQuery.browser.msie && jQuery.browser.version < 7) {
         elm.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + elm.currentStyle.backgroundImage.split('\"')[1] + ", sizingMethod='scale')"; 
         elm.runtimeStyle.backgroundImage = "none"; 
         }
      }
   , buildGalleryNavigation : function(hGallery) {
      var hG = hGallery; 
      var hImgCon = jQuery(hG).find('.imageMainContainer').eq(0); 
      var prev = jQuery('<a href="javascript:;" class="' + hG.options.prevLinkClass + '">').click(function() {
         jQuery(hG).focus(); jQuery.eonGallery.previousImage(hG)}
      ).appendTo(hImgCon).append(jQuery('<span>').html(hG.options.prevLinkText)); 
      var next = jQuery('<a href="javascript:;" class="' + hG.options.nextLinkClass + '">').click(function() {
         jQuery(hG).focus(); jQuery.eonGallery.nextImage(hG)}
      ).appendTo(hImgCon).append(jQuery('<span>').html(hG.options.nextLinkText)); 
      var play = jQuery('<a href="javascript:;" class="' + hG.options.playLinkClass + '">').click(function() {
         jQuery(hG).focus(); jQuery.eonGallery.play(hG)}
      ).appendTo(hImgCon).append(jQuery('<span>').html(hG.options.playLinkText)); 
      var pause = jQuery('<a href="javascript:;" class="' + hG.options.pauseLinkClass + '">').css( {
         display : 'none'}
      ).click(function() {
         jQuery(hG).focus(); jQuery.eonGallery.pause(hG)}
      ).appendTo(hImgCon).append(jQuery('<span>').html(hG.options.pauseLinkText)); 
      jQuery.eonGallery.pngFix(prev.get(0)); 
      jQuery.eonGallery.pngFix(next.get(0)); 
      jQuery.eonGallery.pngFix(play.get(0)); 
      jQuery.eonGallery.pngFix(pause.get(0)); 
      }
   , buildImageHolders : function(hGallery) {
      var hG = hGallery; 
      var sId = hGallery.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var nLeft = 0, nTop = 0; 
      var nWidth = jQuery(hG).width(); 
      var nHeight = jQuery(hG).height(); 
      jQuery.eonGallery.debug('buildImageHolders, paddingTop = ' + jQuery(hG).css('paddingTop')); 
      var mcCss = {
         left : parseInt(jQuery(hG).css('paddingLeft')), top : parseInt(jQuery(hG).css('paddingTop')), right : parseInt(jQuery(hG).css('paddingRight')), bottom : parseInt(jQuery(hG).css('paddingBottom')), overflow : 'hidden', position : 'absolute'}; 
      if(!hG.options.thumbShowOnHover) {
         switch(hG.options.thumbHolderPosition) {
            case'left':mcCss.left += hG.options.thumbHolderWidth + parseInt(hThumbList.css('paddingLeft')) + parseInt(hThumbList.css('paddingRight')) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginLeft')), 0) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginRight')), 0); 
            break; 
            case'right':mcCss.right += hG.options.thumbHolderWidth + parseInt(hThumbList.css('paddingLeft')) + parseInt(hThumbList.css('paddingRight')) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginLeft')), 0) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginRight')), 0); 
				break; 
            case'top':mcCss.top += hG.options.thumbHolderHeight + parseInt(hThumbList.css('paddingTop')) + parseInt(hThumbList.css('paddingBottom')) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginTop')), 0) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginBottom')), 0); 
            break; 
            case'bottom':mcCss.bottom += hG.options.thumbHolderHeight + parseInt(hThumbList.css('paddingTop')) + parseInt(hThumbList.css('paddingBottom')) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginTop')), 0) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginBottom')), 0); 
            break; 
            }
         }
      jQuery.eonGallery.debug('mcCss:'); 
      jQuery.eonGallery.dir(mcCss); 
      var mainCont = jQuery('<div class="imageMainContainer" id="' + sId + '_c0">').appendTo(hGallery).css(mcCss); 
      var hIC1 = jQuery('<div class="imageContainer" id="' + sId + '_1">').appendTo(mainCont).css( {
         opacity : 0}
      ); 
      var hIC2 = jQuery('<div class="imageContainer" id="' + sId + '_2">').appendTo(mainCont).css( {
         opacity : 0}
      ); 
      jQuery.eonGallery.debug('boxModel: ' + jQuery.boxModel); 
      if(jQuery.browser.msie && jQuery.browser.version < 7 ||!jQuery.boxModel) {
         var wCorrection = 'this.parentNode.style.pixelWidth - (parseInt(this.parentNode.currentStyle.borderTopWidth) || 0) - (parseInt(this.parentNode.currentStyle.borderBottomWidth) || 0) - this.style.pixelTop - this.style.pixelBottom'; 
         var hCorrection = 'this.parentNode.style.pixelHeight - (parseInt(this.parentNode.currentStyle.borderTopWidth) || 0) - (parseInt(this.parentNode.currentStyle.borderBottomWidth) || 0) - this.style.pixelTop - this.style.pixelBottom'; 
         if(hG.options.thumbHolderVertical) {
            if(jQuery.boxModel) {
               wCorrection = 'this.parentNode.style.pixelWidth - (parseInt(this.currentStyle.borderLeftWidth) || 0) - (parseInt(this.currentStyle.borderRightWidth) || 0) - ' + hG.options.thumbHolderWidth; 
               hCorrection = 'this.parentNode.style.pixelHeight - (parseInt(this.currentStyle.borderBottomWidth) || 0) - (parseInt(this.currentStyle.borderTopWidth) || 0)'; 
               }
            hThumbList.get(0).style.setExpression('height', hCorrection); 
            }
         else {
            if(jQuery.boxModel) {
               wCorrection = 'this.parentNode.style.pixelWidth - (parseInt(this.currentStyle.borderLeftWidth) || 0) - (parseInt(this.currentStyle.borderRightWidth) || 0)'; 
               hCorrection = 'this.parentNode.style.pixelHeight - (parseInt(this.currentStyle.borderBottomWidth) || 0) - (parseInt(this.currentStyle.borderTopWidth) || 0) - ' + hG.options.thumbHolderWidth; 
               }
            hThumbList.get(0).style.setExpression('width', wCorrection); 
            }
         mainCont.get(0).style.setExpression('width', wCorrection); 
         mainCont.get(0).style.setExpression('height', hCorrection); 
         }
      mainCont.mousewheel(function(event, delta) {
         if(delta > 0) {
            jQuery.eonGallery.previousImage(hG); }
         if(delta < 0) {
            jQuery.eonGallery.nextImage(hG); }
         hG.focus(); }
      ); 
      }
   , buildWaiting : function(hGallery) {
      jQuery('<div class="eonWaiting">').css( {
         width : jQuery(hGallery).width(), height : jQuery(hGallery).height()}
      ).appendTo(hGallery); 
      }
   , showWaiting : function(hGallery) {
      jQuery('.eonWaiting', hGallery).css( {
         display : 'block'}
      ); 
      jQuery('.eonWaiting', hGallery).animate( {
         opacity : 1}
      ); 
      }
   , hideWaiting : function(hGallery) {
      jQuery('.eonWaiting', hGallery).animate( {
         opacity : 0}
      , 'fast', 'linear', function() {
         jQuery('.eonWaiting', hGallery).css( {
            display : 'none'}
         )}
      ); 
      }
   , buildMessage : function(hGallery) {
      var mOpac = 0.5; 
      if(!hGallery.options.showInfoMessage)mOpac = 0; 
      var hM = jQuery('<div class="message">').css( {
         opacity : mOpac}
      ).appendTo(hGallery); 
      hM.css( {
         top : jQuery(hGallery).height() - hM.height()}
      ); 
      }
   , showMessage : function(hGallery, sMessage) {
      if(hGallery.options.showInfoMessage) {
         var hM = jQuery(hGallery).find('div.message'); 
         var nH = jQuery(hGallery).height(); 
         var nMH = hM.height(); 
         if(hGallery.options.messageHidden) {
            hM.animate( {
               top : nH - nMH, opacity : 0.5}
            , 'slow'); 
            }
         hM.text(sMessage); 
         hGallery.options.messageHide.cancel(); 
         hGallery.options.messageHidden = false; 
         }
      }
   , hideMessage : function(hGallery) {
      if(hGallery.options.messageHide)hGallery.options.messageHide.delay(1000); 
      }
   , doHideMessage : function(hGallery) {
      var hM = jQuery(hGallery).find('div.message'); 
      var nH = jQuery(hGallery).height(); 
      jQuery(hM).animate( {
         top : nH, opacity : 0}
      , 'slow'); 
      hGallery.options.messageHidden = true; 
      }
   , buildCaption : function(hG) {
      var hImgCon = jQuery(hG).find('.imageMainContainer').eq(0); 
      var hCaption = jQuery('<div class="imageCaption">').appendTo(hImgCon); 
      var nCH = hCaption.height(); 
      var nCTop; 
      if(hG.options.captionPosition == 'bottom') {
         nCTop = jQuery(hG).height(); 
         }
      else {
         nCTop =- jQuery(hCaption).height(); 
         }
      var nLeft = 0; 
      hCaption.css( {
         top : nCTop, left : nLeft, width : '100%', opacity : hG.options.captionOpacity / 100}
      ); 
      }
   , showCaption : function(hG) {
      jQuery.eonGallery.debug('showCaption() ' +!jQuery.eonGallery.captionHidden(hG)); 
      if(!jQuery.eonGallery.captionHidden(hG)) {
         jQuery.eonGallery.hideCaption(hG, true); 
         return; 
         }
      var hCaption = jQuery('div.imageCaption', hG); 
      var hElements = jQuery(hG).find('div.eonImageHolder').find('ul li'); 
      if(hElements.eq(hG.options.imgIndex).find('h3').length > 0 || hElements.eq(hG.options.imgIndex).find('p').length > 0) {
         var nH = jQuery(hG).height(); 
         hCaption.find('h3').remove(); 
         hCaption.find('p').remove(); 
         hElements.eq(hG.options.imgIndex).find('h3').clone().appendTo(hCaption); 
         hElements.eq(hG.options.imgIndex).find('p').clone().appendTo(hCaption); 
         jQuery(hCaption).css( {
            display : 'block'}
         )
			var nCTop; 
         if(hG.options.captionPosition == 'bottom') {
            nCTop = nH + hCaption.height(); 
            if(!hG.options.thumbShowOnHover) {
               if(hG.options.thumbHolderHorizontal) {
                  nCTop -= hG.options.thumbHolderHeight; 
                  }
               }
            }
         else {
            nCTop =- hCaption.height(); 
            }
         hCaption.css( {
            'top':nCTop}
         ); 
         if(hG.options.captionPosition == 'bottom') {
            nCTop -= 2 * hCaption.height(); 
            }
         else {
            nCTop = 0; 
            }
         window.setTimeout(function() {
            hCaption.animate( {
               top : nCTop, opacity : hG.options.captionOpacity / 100}
            , 'slow')}
         , 100); 
			/*window.setTimeout(function() {
            hCaption.animate( {
            top : nCTop, opacity : 0}
         , 'slow', 'linear', function() {
            jQuery(hCaption).css( {
               display : 'none'}
            ); }
	         ); 				}
         , 10000); 			*/
         }
      }
   , hideCaption : function(hG, bShow) {
      var hCaption = jQuery('div.imageCaption', hG); 
      var nCTop; 
      if(hG.options.captionPosition == 'bottom') {
         nCTop = jQuery(hG).height(); 
         }
      else {
         nCTop =- jQuery(hCaption).height(); 
         }
      if(bShow) {
         hCaption.animate( {
            top : nCTop, opacity : 0}
         , 'slow', 'linear', function() {
            jQuery(hCaption).css( {
               display : 'none'}
            ); jQuery.eonGallery.showCaption(hG)}
         ); 
         }
      else {
         hCaption.animate( {
            top : nCTop, opacity : 0}
         , 'slow'); 
         }
      }
   , captionHidden : function(hG) {
      var hCaption = jQuery('div.imageCaption', hG); 
      var nH = jQuery(hG).height(); 
      var nTop = parseInt(hCaption.css('top')); 
      if(jQuery(hCaption).css('display') == 'none' || nH == nTop) {
         return true; 
         }
      return false; 
      }
   , buildThumbnailList : function(hGallery) {
      var hG = hGallery; 
      var sId = hG.id; 
      var nW = jQuery(hG).width(); 
      var nH = jQuery(hG).height(); 
      var hDim = jQuery(hG).offset( {
         border : true, padding : true}
      ); 
      var hTT = hDim.top + nH - hG.options.thumbHolderHeight; 
      if(hG.options.thumbHolderPosition == 'top' || hG.options.thumbHolderPosition == 'bottom') {
         hG.options.thumbHolderHorizontal = true; 
         hG.options.thumbHolderVertical = false; 
         }
      jQuery.eonGallery.debug('buildThumbnailList ' + sId); 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      if(hThumbList.length == 0) {
         hThumbList = jQuery('<div class="eonThumbList" id="' + sId + '_thumb">'); 
         }
      hThumbList.css( {
         left : 'auto', top : 'auto', right : 'auto', bottom : 'auto'}
      ); 
      if(hG.options.thumbHolderVertical) {
         hThumbList.addClass('eonThumbListVertical'); 
         }
      hG.options.thumbHolderHeight = hG.options.thumbHeight + 2 * hG.options.thumbPadding; 
      hG.options.thumbHolderWidth = hG.options.thumbWidth + 2 * hG.options.thumbPadding; 
      var tlLeft = parseInt(jQuery(hG).css('paddingLeft')) || 0; 
      var tlTop = parseInt(jQuery(hG).css('paddingTop')) || 0; 
      var tlRight = parseInt(jQuery(hG).css('paddingRight')) || 0; 
      var tlBottom = parseInt(jQuery(hG).css('paddingBottom')) || 0; 
      switch(hG.options.thumbHolderPosition) {
         case'top':hThumbList.css( {
            right : tlRight, left : tlLeft, top : tlTop, width : 'auto', height : hG.options.thumbHolderHeight}
         ); 
         break; 
         case'bottom':hThumbList.css( {
            right : tlRight, left : tlLeft, bottom : tlBottom, width : 'auto', height : hG.options.thumbHolderHeight}
         ); 
         break; 
         case'left':hThumbList.css( {
            top : tlTop, left : tlLeft, bottom : tlBottom, width : hG.options.thumbHolderWidth, height : 'auto'}
         ); 
         break; 
         case'right':hThumbList.css( {
            top : tlTop, right : tlRight, bottom : tlBottom, width : hG.options.thumbHolderWidth, height : 'auto'}
         ); 
         break; 
         }
      var hUL = jQuery('<ul>'); 
      hThumbList.append(hUL).appendTo(hG); 
      var nTW = 0; 
      var nTH = 0; 
      jQuery.each(hG.thumbList, function(nI, hImage) {
         var hItem = jQuery('<li>').css( {
            width : hG.options.thumbWidth, height : hG.options.thumbHeight, margin : hG.options.thumbPadding, display : 'inline'}
         ); var hLink = jQuery('<a href="#">').css( {
            width : hG.options.thumbWidth, height : hG.options.thumbHeight}
         ).click(function() {
            jQuery.eonGallery.showImage(hG, nI); return false; }
         ).appendTo(hItem); hItem.appendTo(hUL); if(jQuery.boxModel) {
            hLink.css( {
               width : hG.options.thumbWidth - parseInt(hLink.css('borderLeftWidth')) - parseInt(hLink.css('borderRightWidth')), height : hG.options.thumbHeight - parseInt(hLink.css('borderTopWidth')) - parseInt(hLink.css('borderBottomWidth'))}
            ); }
         else {
            hLink.css( {
               width : hG.options.thumbWidth, height : hG.options.thumbHeight}
            ); }
         hLink.hover(function() {
            var theLink = this; window.setTimeout(function() {
               if(jQuery.boxModel) {
                  jQuery(theLink).css( {
                     width : hG.options.thumbWidth - parseInt(hLink.css('borderLeftWidth')) - parseInt(hLink.css('borderRightWidth')), height : hG.options.thumbHeight - parseInt(hLink.css('borderTopWidth')) - parseInt(hLink.css('borderBottomWidth'))}
                  ); }
               else {
                  jQuery(theLink).css( {
                     width : hG.options.thumbWidth, height : hG.options.thumbHeight}
                  ); }
               }
            , 1); }
         , function() {
            var theLink = this; window.setTimeout(function() {
               if(jQuery.boxModel) {
                  jQuery(theLink).css( {
                     width : hG.options.thumbWidth - parseInt(hLink.css('borderLeftWidth')) - parseInt(hLink.css('borderRightWidth')), height : hG.options.thumbHeight - parseInt(hLink.css('borderTopWidth')) - parseInt(hLink.css('borderBottomWidth'))}
                  ); }
               else {
                  jQuery(theLink).css( {
                     width : hG.options.thumbWidth, height : hG.options.thumbHeight}
                  ); }
               }
            , 1); }
         ); var hGImage = jQuery('<img>'); hGImage.load(function() {
            hImage.loaded = true; hG.options.loaded++; jQuery.eonGallery.showMessage(hG, 'loaded ' + hG.options.loaded + ' images'); jQuery.eonGallery.hideMessage(hG); hItem.css("backgroundImage", 'url( "' + jQuery(this).attr('src') + '" )'); hItem.css("backgroundPosition", 'center center'); }
         ).attr('src', hImage.toString()); nTW += hG.options.thumbWidth + 2 * hG.options.thumbPadding; nTH += hG.options.thumbHeight + 2 * hG.options.thumbPadding; }
      ); 
      if(hG.options.thumbHolderVertical)
			hUL.css({ height : nTH, left : 0, top : 0}); 
      else
			hUL.css({width : nTW, left : 0, top : 0}); 
      var leftElm = jQuery('<a href="javascript:;" class="' + hG.options.prevLinkClass + '">').click(function(event) {
         jQuery.eonGallery.scrollThumbnailList(hG, 'left'); event.preventDefault(); event.stopPropagation(); return false; }
      ).appendTo(hThumbList).append(jQuery('<span>').html(hG.options.prevLinkText)); 
      var rightElm = jQuery('<a href="javascript:;" class="' + hG.options.nextLinkClass + '">').click(function(event) {
         jQuery.eonGallery.scrollThumbnailList(hG, 'right'); event.preventDefault(); event.stopPropagation(); return false; }
      ).appendTo(hThumbList).append(jQuery('<span>').html(hG.options.nextLinkText)); 
      jQuery.eonGallery.pngFix(leftElm.get(0)); 
      jQuery.eonGallery.pngFix(rightElm.get(0)); 
      hThumbList.mousewheel(function(event, delta) {
         if(delta > 0) {
            jQuery.eonGallery.scrollThumbnailList(hG, 'left', 200); }
         if(delta < 0) {
            jQuery.eonGallery.scrollThumbnailList(hG, 'right', 200); }
         hG.focus(); }
      ); 
      return hThumbList; 
      }
   , hideThumbnailList : function(hG) {
      var sId = hG.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      hG.options.thumbListHidden = true; 
      hThumbList.animate( {
         opacity : 0}
      , 200); 
      }
   , showThumbnailList : function(hG) {
      if(!hG.options.thumbListHidden) {
         return}
      var sId = hG.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      hG.options.thumbListHidden = false; 
      hThumbList.animate( {
         opacity : 1}
      , 200); 
      }
   , initThumbnailListEvents : function(hG) {
      var sId = hG.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var hList = hThumbList.find('ul'); 
      hThumbList.mousemove(function(event) {
         jQuery.event.fix(event); }
      ); 
      hThumbList.mouseout(function(event) {
         jQuery.event.fix(event); }
      ); 
      }
   , scrollThumbnailList : function(hG, sDirection, nSpeed) {
      var sId = hG.id; 
      var theSpeed = nSpeed ? nSpeed : 500; 
      jQuery.eonGallery.debug('scrollThumbnailList, scrollingThumbnails : ' + hG.options.scrollingThumbnails); 
      if(hG.options.scrollingThumbnails) {
         return; 
         }
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var hList = hThumbList.find('ul'); 
      var nW = jQuery(hG).width(); 
      var nH = jQuery(hG).height(); 
      var nLL = parseInt(jQuery(hList).css('left')); 
      if(!nLL) {
         nLL = 0; 
         jQuery(hList).css( {
            left : 0}
         ); 
         }
      var nLW = jQuery(hList).outerWidth(); 
      var nLT = parseInt(jQuery(hList).css('top')); 
      if(!nLT) {
         nLT = 0; 
         jQuery(hList).css( {
            top : '0px'}
         ); 
         }
      var nLH = jQuery(hList).outerHeight(); 
      var nNL; 
      var nScrollWidth = hG.options.thumbWidth + 2 * hG.options.thumbPadding; 
      var nScrollHeight = hG.options.thumbHeight + 2 * hG.options.thumbPadding; 
      jQuery.eonGallery.debug('scroll = ' + sDirection); 
      if(hG.options.thumbHolderHorizontal) {
         switch(sDirection) {
            case'left':if(nLL < 0) {
               nNL = nLL + Math.min(nScrollWidth, Math.abs(nLL)); 
               hG.options.scrollingThumbnails = true; 
               jQuery(hList).animate( {
                  left : nNL}
               , theSpeed, 'linear', function() {
                  hG.options.scrollingThumbnails = false; }
               ); 
               }
            break; 
            case'right':if(Math.abs(nLL) < nLW - nW) {
               nNL = nLL - Math.min(nScrollWidth, Math.abs(nLW - nW + nLL)); 
               hG.options.scrollingThumbnails = true; 
               jQuery(hList).animate( {
                  left : nNL}
               , theSpeed, 'linear', function() {
                  hG.options.scrollingThumbnails = false; }
               ); 
               }
            break; 
            }
         }
      else if(hG.options.thumbHolderVertical) {
         switch(sDirection) {
            case'left':jQuery.eonGallery.debug('scroll pos : nLT=' + nLT); 
            if(nLT < 0) {
               nNL = nLT + Math.min(nScrollHeight, Math.abs(nLT)); 
               hG.options.scrollingThumbnails = true; 
               jQuery(hList).animate( {
                  top : nNL}
               , theSpeed, 'linear', function() {
                  hG.options.scrollingThumbnails = false; }
               ); 
               }
            break; 
            case'right':jQuery.eonGallery.debug('scroll pos : ' + Math.abs(nLT) + '<=' + nLH + '-' + nH); 
            if(Math.abs(nLT) < nLH - nH) {
               nNL = nLT - Math.min(nScrollHeight, Math.abs(nLH - nH + nLT)); 
               jQuery.eonGallery.debug('scroll nNL : ' + nNL); 
               hG.options.scrollingThumbnails = true; 
               jQuery(hList).animate( {
                  top : nNL}
               , theSpeed, 'linear', function() {
                  hG.options.scrollingThumbnails = false; }
               ); 
               }
            break; 
            }
         }
      }
   , fixThumbnailListPosition : function(hG) {
      var sId = hG.id; 
      if(hG.options.scrollingThumbnails) {
         return; 
         }
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var nW = jQuery(hThumbList).width(); 
      var hList = hThumbList.find('ul'); 
      var nLL = parseInt(jQuery(hList).css('left')); 
      var nLW = jQuery(hList).outerWidth(); 
      var nNL = nLW + nLL; 
      if(nNL < nW) {
         jQuery(hList).animate( {
            left : nW - nLW}
         , 1000, 'linear', function() {
            hG.options.scrollingThumbnails = false; }
         ); 
         }
      }
   , markThumbnail : function(hGallery, nId) {
      var hG = hGallery; 
      var sId = hG.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var hThumbLinks = hThumbList.find('ul a'); 
      hThumbLinks.removeClass('selected'); 
      hThumbLinks.eq(nId).addClass('selected'); 
      jQuery.eonGallery.scrollMarkedThumbIntoView(hG, nId); 
      }
   , scrollMarkedThumbIntoView : function(hGallery, nId) {
      jQuery.eonGallery.debug('scrollMarkedThumbIntoView'); 
      var hG = hGallery; 
      var sId = hG.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var hThumbLinks = hThumbList.find('ul a'); 
      var nW = jQuery(hThumbList).width(); 
      var nH = jQuery(hThumbList).height(); 
      var hList = hThumbList.find('ul'); 
      var nLL = parseInt(jQuery(hList).css('left')) || 0; 
      var nLT = parseInt(jQuery(hList).css('top')) || 0; 
      var nLW = jQuery(hList).outerWidth(); 
      var nNL = nLW + nLL; 
      var nThumbLeft, nThumbTop; 
      var nTW = hG.options.thumbWidth + 2 * hG.options.thumbPadding; 
      var nTH = hG.options.thumbHeight + 2 * hG.options.thumbPadding; 
      if(hG.options.thumbHolderHorizontal) {
         nThumbLeft = nId * nTW; 
         jQuery.eonGallery.debug('scrollMarkedThumbIntoView horizontal ' + nThumbLeft + ':' + nLL); 
         jQuery.eonGallery.debug('scrollMarkedThumbIntoView horizontal2 ' + nId + ':' + nTW + ':' + nW); 
         if((nThumbLeft + nLL) < 0) {
            jQuery(hList).animate( {
               left :- nThumbLeft}
            , 300, 'linear', function() {
               hG.options.scrollingThumbnails = false; }
            ); 
            }
         if((nThumbLeft + nLL + nTW) > nW) {
            jQuery.eonGallery.debug('left: ' + ( - nThumbLeft + nW - nTW)); 
            jQuery.eonGallery.debug('left2: ' + jQuery(hList).css('left')); 
            jQuery(hList).animate( {
               left :- nThumbLeft + nW - nTW}
            , 300, 'linear', function() {
               hG.options.scrollingThumbnails = false; }
            ); 
            }
         }
      else if(hG.options.thumbHolderVertical) {
         nThumbTop = nId * nTH; 
         if((nThumbTop + nLT) < 0) {
            jQuery(hList).animate( {
               top :- nThumbTop}
            , 300, 'linear', function() {
               hG.options.scrollingThumbnails = false; }
            ); 
            }
         if((nThumbTop + nLT + nTH) > nH) {
            jQuery(hList).animate( {
               top :- nThumbTop + nH - nTH}
            , 300, 'linear', function() {
               hG.options.scrollingThumbnails = false; }
            ); 
            }
         }
      jQuery.eonGallery.fixThumbnailListPosition(hG); 
      }
   , nextImage : function(hGallery) {
      var hG = hGallery; 
      hG.options.imgIndex += 1; 
      var hElements = jQuery(hG).find('div.eonImageHolder').find('ul li'); 
      if(hG.options.imgIndex >= hElements.length) {
         hG.options.imgIndex = 0; 
         }
      jQuery.eonGallery.swapImages(hG, hG.options.imgIndex); 
      }
   , previousImage : function(hGallery) {
      var hG = hGallery; 
      hG.options.imgIndex -= 1; 
      var hElements = jQuery(hG).find('div.eonImageHolder').find('ul li'); 
      if(hG.options.imgIndex < 0) {
         hG.options.imgIndex = hElements.length - 1; 
         }
      jQuery.eonGallery.swapImages(hG, hG.options.imgIndex); 
      }
   , play : function(hGallery) {
      var hG = hGallery; 
      jQuery('a.eonPause', hG).css( {
         display : ''}
      ); 
      jQuery('a.eonPlay', hG).css( {
         display : 'none'}
      ); 
      hG.options.player.delay(hG.options.playerDelay * 1000); 
      }
   , pause : function(hGallery) {
      var hG = hGallery; 
      jQuery('a.eonPause', hG).css( {
         display : 'none'}
      ); 
      jQuery('a.eonPlay', hG).css( {
         display : ''}
      ); 
      hG.options.player.cancel(); 
      }
   , swapImages : function(hGallery, nId) {
      var hG = hGallery; 
      hG.options.swapping = true; 
      var hHolder = jQuery('.' + hG.options.imageHolderClass, hG); 
      jQuery('div.imageContainer', hG).eq(1).empty(); 
      var hImage = jQuery('<img id="' + jQuery(hG).find('.imageContainer').eq(1).attr('id') + '_image' + '">'); 
      jQuery(hG).find('.imageContainer').eq(1).append(hImage); 
      if(!hG.imageList[nId].loaded) {
         hG.imageList[nId].loading = true; 
         hImage.load(function() {
            jQuery.eonGallery.debug('image loaded.'); hG.imageList[nId].loading = false; hG.imageList[nId].loaded = true; jQuery.eonGallery.hideWaiting(hG); jQuery.eonGallery.doSwapImages(hG); if(hG.options.autosize) {
               jQuery.eonGallery.resizeGalleryToContent(hG); }
            else {
               window.setTimeout(function() {
                  jQuery.eonGallery.showCaption(hG)}
               , 100); }
            hG.options.swapping = false; }
         ).attr('src', hG.imageList[nId]); 
         jQuery.eonGallery.debug('load image: ' + hG.imageList[nId]); 
         }
      else {
         hImage.attr('src', hG.imageList[nId]); 
         jQuery.eonGallery.hideWaiting(hG); 
         jQuery.eonGallery.doSwapImages(hG); 
         if(hG.options.autosize) {
            jQuery.eonGallery.resizeGalleryToContent(hG); 
            }
         else {
            window.setTimeout(function() {
               jQuery.eonGallery.showCaption(hG)}
            , 100); 
            }
         hG.options.swapping = false; 
         }
      jQuery.eonGallery.markThumbnail(hGallery, nId); 
      jQuery.eonGallery.preloadImages(hG, nId); 
      if(typeof soundManager != 'undefined') {
         try {
            soundManager.play('gallery'); 
            }
         catch(hE) {
            }
         }
      }
   , doSwapImages : function(hGallery) {
      var hG = hGallery; 
      jQuery.eonGallery.debug('doSwapImages begin'); 
      jQuery('div.imageContainer', hG).eq(1).insertBefore(jQuery('div.imageContainer', hG).eq(0)); 
      jQuery('div.imageContainer', hG).eq(0).animate( {
         opacity : 1}
      , 'slow'); 
      jQuery('div.imageContainer', hG).eq(1).animate( {
         opacity : 0}
      , 'fast'); 
      jQuery.eonGallery.debug('doSwapImages end'); 
      }
   , showImage : function(hGallery, nId) {
      var hG = hGallery; 
      jQuery.eonGallery.showWaiting(hG); 
      hG.options.imgIndex = nId; 
      jQuery.eonGallery.swapImages(hG, hG.options.imgIndex); 
      }
   , preloadImages : function(hGallery, nCurrentId) {
      if(hGallery.options.allPreloaded) {
         return; 
         }
      for(var nI = 0; nI < hGallery.imageList.length; nI++) {
         if(!hGallery.imageList[nI].loaded) {
            break; 
            }
         }
      if(nI == hGallery.imageList.length) {
         hGallery.options.allPreloaded = true; 
         return; 
         }
      function getIds(hImageList, nCurrentId, nTreshold) {
         var aIds = []; 
         var nCId = 1; 
         nTreshold = nTreshold > hImageList.length ? Math.floor(hImageList.length / 2) : nTreshold; 
         while(nCId <= nTreshold) {
            aIds[aIds.length] = nCurrentId - nCId < 0 ? hImageList.length + nCurrentId - nCId : nCurrentId - nCId; 
            aIds[aIds.length] = nCurrentId + nCId >= hImageList.length ? (nCurrentId + nCId) % hImageList.length : nCurrentId + nCId; 
            nCId++; 
            }
         return aIds; 
         }
      var aIds = getIds(hGallery.imageList, nCurrentId, hGallery.options.preloadTreshold); 
      var nId; 
      while(aIds.length > 0) {
         nId = aIds.shift(); 
         if(!hGallery.imageList[nId].loaded) {
            hGallery.imageList[nId].loading = true; 
            var hImage = jQuery('<img>'); 
            hImage.load(function() {
               hGallery.imageList[nId].loading = false; hGallery.imageList[nId].loaded = true; }
            ).attr('src', hGallery.imageList[nId]); 
            }
         }
      }
   , resizeGalleryToContent : function(hG) {
      jQuery.eonGallery.debug(' resizeGalleryToContent, hG = ' + jQuery(hG).attr('id')); 
      var sId = hG.id; 
      var hThumbList = jQuery('#' + sId + '_thumb'); 
      var hMIC = jQuery('div.imageMainContainer', hG).eq(0); 
      var hIC = jQuery('div.imageContainer', hG).eq(0); 
      jQuery.eonGallery.debug(' resizeGalleryToContent, IC = ' + hIC.attr('id')); 
      var sIId = hIC.attr('id') + '_image'; 
      jQuery.eonGallery.debug(' resizeGalleryToContent, sIId = ' + sIId); 
      var hImage = jQuery('#' + sIId); 
      jQuery.eonGallery.debug(' resizeGalleryToContent, gallery: ' + jQuery(hG).width() + 'x' + jQuery(hG).height() + ', image: ' + hImage.width() + 'x' + hImage.height()); 
      if(jQuery(hG).width() == hImage.width() && jQuery(hG).height() == hImage.height()) {
         window.setTimeout(function() {
            jQuery.eonGallery.showCaption(hG)}
         , 10); 
         return; 
         }
      else {
         var gWidth = hImage.width(); 
         var gHeight = hImage.height(); 
         if(!hG.options.thumbShowOnHover) {
            if(hG.options.thumbHolderHorizontal) {
               gHeight += hG.options.thumbHolderHeight + parseInt(hThumbList.css('paddingTop')) + parseInt(hThumbList.css('paddingBottom')) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginTop')), 0) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginBottom')), 0); 
               }
            else if(hG.options.thumbHolderVertical) {
               gWidth += hG.options.thumbHolderWidth + parseInt(hThumbList.css('paddingLeft')) + parseInt(hThumbList.css('paddingRight')) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginLeft')), 0) + jQuery.eonGallery.ifNull(parseInt(hThumbList.css('marginRight')), 0); 
               }
            if(!jQuery.boxModel) {
               gHeight += parseInt(jQuery(hG).css('paddingTop')) + parseInt(jQuery(hG).css('paddingBottom')) + parseInt(jQuery(hG).css('borderTopWidth')) + parseInt(jQuery(hG).css('borderBottomWidth')) + jQuery.eonGallery.ifNull(parseInt(jQuery(hG).css('marginTop')), 0) + jQuery.eonGallery.ifNull(parseInt(jQuery(hG).css('marginBottom')), 0); 
               gWidth += parseInt(jQuery(hG).css('paddingLeft')) + parseInt(jQuery(hG).css('paddingRight')) + parseInt(jQuery(hG).css('borderLeftWidth')) + parseInt(jQuery(hG).css('borderRightWidth')) + jQuery.eonGallery.ifNull(parseInt(jQuery(hG).css('marginLeft')), 0) + jQuery.eonGallery.ifNull(parseInt(jQuery(hG).css('marginRight')), 0); 
               }
            if(jQuery.boxModel && jQuery.browser.msie && jQuery.browser.version < 7) {
               gHeight += parseInt(hMIC.css('borderTopWidth')) + parseInt(hMIC.css('borderBottomWidth'));
					gWidth += parseInt(hMIC.css('borderLeftWidth')) + parseInt(hMIC.css('borderRightWidth'))}
            }
         jQuery.eonGallery.debug('before animate'); 
         jQuery(hG).stop(); 
         jQuery.eonGallery.debug('after stop animate'); 
         jQuery(hG).animate( {
            width : gWidth, height : gHeight}
         , "slow", "linear", function() {
            jQuery.eonGallery.debug('after animate'); window.setTimeout(function() {
               jQuery.eonGallery.showCaption(hG)}
            , 10); }
         ); 
         jQuery.eonGallery.debug('end resizeGalleryToContent'); 
         }
      }
   , ifNull : function(theVar, defVal) {
      return theVar ? theVar : defVal; 
      }
   , debug : function(sMessage) {
      if(this.bDebug) {
         if(typeof window.console != 'undefined') {
            if(arguments.length > 1) {
               window.console.log(arguments); 
               }
            else {
               window.console.log(sMessage); 
               }
            }
         else {
            alert(sMessage); 
            }
         }
      }
   , dir : function(sMessage) {
      if(this.bDebug) {
         if(typeof window.console != 'undefined') {
            if(arguments.length > 1) {
               window.console.dir(arguments); 
               }
            else {
               window.console.dir(sMessage); 
               }
            }
         else {
            alert(sMessage); 
            }
         }
      }
   }
jQuery.eonGallery.counter = 0; 
jQuery.fn.eonGallery = jQuery.eonGallery.build; 

