var ProductGallery = { toggleTween: null, moreTeewn: null, imageBlock: null, btnMore: null, limit: 0, container: null, maskHeight: 0, t: 10, h: 0, init: function() { $$('#prod-gallery .toggle').addEvent('click', function() { ProductGallery.toggleGallery( this ); return false;}); $$('#prod-gallery .image_block').addEvent('mouseenter', function() { ProductGallery.showZoomButton();}); $$('#prod-gallery .image_block').addEvent('mouseleave', function() { ProductGallery.hideZoomButton();}); ProductGallery.imageBlock = $('prod-image'); ProductGallery.btnMore = $('moreBtns'); var tags = $$('#gallery-container a'); tags.forEach( function (t) { ProductGallery.h += parseInt(t.getChildren('img').getProperty('height'));}); $('gallery-container').setStyle('height', ProductGallery.h); ProductGallery.tot = parseInt($$('#gallery .scroller img').length); ProductGallery.container = $('gallery-container'); ProductGallery.maskHeight = parseInt($$('#gallery .scroller').getStyle('height')); ProductGallery.limit = parseInt($('gallery-container').getStyle('height')) - ProductGallery.maskHeight; if (ProductGallery.tot <= 4) { $$('#gallery .navigation .next').setStyle('display', 'none'); $$('#gallery .navigation .prev').setStyle('display', 'none');}
ProductGallery.createEvents();}, toggleGallery: function( t ) { $('gallery').setStyle('z-index', -1); if (ProductGallery.toggleTween != null) { ProductGallery.toggleTween.cancel();}
if (ProductGallery.moreTeewn != null) { ProductGallery.moreTeewn.cancel();}
ProductGallery.toggleTween = new Fx.Morph(ProductGallery.imageBlock, {duration: 800, transition: Fx.Transitions.Sine.easeOut}); ProductGallery.moreTeewn = new Fx.Morph(ProductGallery.btnMore, {duration: 800, transition: Fx.Transitions.Sine.easeOut}); if (parseInt(ProductGallery.imageBlock.getStyle('left')) != 0) { var step = 0; t.setStyle('background', "transparent url('/img/shop/toggle_off.gif') top left no-repeat");}
else
{ var step = -96; t.setStyle('background', "transparent url('/img/shop/toggle_on.gif') top left no-repeat");}
ProductGallery.toggleTween.start({ 'left': step
}); ProductGallery.moreTeewn.start({ 'right': -(step-20)
}); ProductGallery.toggleTween.addEvent('onComplete', function() { if (parseInt(ProductGallery.imageBlock.getStyle('left')) != 0)
{ $('gallery').setStyle('z-index', 22);}
});}, setEnterFrame: function( dir ) { if (dir == '-')
{ if ( $(ProductGallery.container).getStyle('top').toInt() > -(ProductGallery.limit) ) { $(ProductGallery.container).setStyle('top', $(ProductGallery.container).getStyle('top').toInt() - 1);}
}
else
{ if ( $(ProductGallery.container).getStyle('top').toInt() < 0 ) { $(ProductGallery.container).setStyle('top', $(ProductGallery.container).getStyle('top').toInt() + 1);}
}
}, deleteEnterFrame: function( id ) { $clear(ProductGallery.interval);}, createEvents: function() { $$('#gallery .navigation .next').addEvent('mouseover', function() { ProductGallery.deleteEnterFrame(); ProductGallery.interval = ProductGallery.setEnterFrame.periodical(ProductGallery.t, null, '-'); return false;}); $$('#gallery .navigation .prev').addEvent('mouseover', function() { ProductGallery.deleteEnterFrame(); ProductGallery.interval = ProductGallery.setEnterFrame.periodical(ProductGallery.t, null, '+'); return false;}); $$('#gallery .navigation .next').addEvent('mouseout', function() { ProductGallery.deleteEnterFrame();}); $$('#gallery .navigation .prev').addEvent('mouseout', function() { ProductGallery.deleteEnterFrame();}); $$('#gallery .navigation .next').addEvent('click', function() { return false;}); $$('#gallery .navigation .prev').addEvent('click', function() { return false;}); $$('#gallery .scroller a').forEach(function(tag) { tag.addEvent('click', function(t) { ProductGallery.replaceImage(tag.href); return false;});})
}, showZoomButton: function() { $$('#prod-gallery .image_block .zoom').setStyle('display', 'block'); $$('#prod-gallery .image_block .video').setStyle('display', 'block');}, hideZoomButton: function() { $$('#prod-gallery .image_block .zoom').setStyle('display', 'none'); $$('#prod-gallery .image_block .video').setStyle('display', 'none');}, replaceImage: function(url) { $('large_image').setProperty('src', url);}
}; window.addEvent('domready', ProductGallery.init);