var showAlbum = { anchorSet: null, currentImage: 0, images: 0, offset: 0, visible: 6, scrollIntervalHandle: null, init : function(nr, anchorSet) { showAlbum.anchorSet = anchorSet; jQuery('body').css('overflow', 'hidden'); jQuery('#overlayLayer').css('display', 'block'); jQuery('#overlayLayer').css('height', jQuery('html').height()); jQuery('#overlayAlbum').css('display', 'block'); jQuery('#overlayAlbum').css('left', (jQuery(window).width() - 660) / 2); jQuery('#overlayAlbum').css('top', jQuery(window).scrollTop() + 100); jQuery('#overlayAlbum .images').html('
'); jQuery('#overlayAlbum .images .right').mouseover(function() { showAlbum.scrollIntervalHandle = setInterval(function() { if(showAlbum.offset + showAlbum.visible < showAlbum.images) { showAlbum.offset++; jQuery('#overlayAlbum .images ul').css('left', -1 * showAlbum.offset * 110) } }, 250); }) jQuery('#overlayAlbum .images .left').mouseover(function() { showAlbum.scrollIntervalHandle = setInterval(function() { if(showAlbum.offset > 0) { showAlbum.offset--; jQuery('#overlayAlbum .images ul').css('left', -1 * showAlbum.offset * 110) } }, 250); }) jQuery('#overlayAlbum .images').find('.right, .left').mouseleave(function() { clearInterval(showAlbum.scrollIntervalHandle); }) var a, img; for(var i = 0 ; i < anchorSet.length ; i++) { showAlbum.images++; a = jQuery(anchorSet[i]); img = jQuery('').attr('src', a.find('img').attr('src')); a = jQuery('').data('i', i).attr('href', a.attr('href')).append(img).data('description', 'lololtest1'); a.click(function(e) { e.preventDefault(); showAlbum.showImage(jQuery(this).data('i')); }) jQuery('#overlayAlbum .images ul').append(jQuery('
  • ').append(a)); } showAlbum.showImage(nr); if(showAlbum.images <= showAlbum.visible) { jQuery('#overlayAlbum .images .left').remove(); jQuery('#overlayAlbum .images .right').remove(); } }, close : function() { jQuery('body').css('overflow', 'auto'); jQuery('#overlayLayer').css('display', 'none'); jQuery('#overlayAlbum').css('display', 'none'); }, showImage : function(i) { showAlbum.currentImage = i; var anchor = showAlbum.anchorSet[i]; jQuery('#overlayAlbum .top .image .show').html(jQuery('').attr('src', jQuery(anchor).attr('href'))); jQuery('#overlayAlbum .top .description').html(jQuery(anchor).data('description')); jQuery('#overlayAlbum .images ul li').removeClass('active'); jQuery('#overlayAlbum .images ul li')[i].className = 'active'; if(i+1 > showAlbum.visible) { if(i+1 - showAlbum.offset > showAlbum.visible) { showAlbum.offset = (i+1) - showAlbum.visible; } } else { showAlbum.offset = 0; } jQuery('#overlayAlbum .images ul').css('left', -1 * showAlbum.offset * 110) }, scrollImage : function(i) { showAlbum.currentImage += i; if(showAlbum.currentImage == -1) showAlbum.currentImage = showAlbum.anchorSet.length - 1; if(showAlbum.currentImage == showAlbum.anchorSet.length) showAlbum.currentImage = 0; showAlbum.showImage(showAlbum.currentImage); } }