
/*
	Simple Gallery
	Author: Sergei Tolmachyov - Fuse8 Online
*/

(function($){$.fn.simpleGallery=function(c){var d={galleryWidth:200,effect:'fade',rotatingSpeed:700,currentItem:1,autoScroll:true,rotatingInterval:10000,stopAutoScrollByHover:true,showItemCallBack:null,zIndex:1,frameClass:'gm_iv_frame',plugIns:{}};var e=this;e.options=$.extend({},d,c);if(!e.parent().hasClass(e.options.frameClass)){e.hoverOnGallery=false;e.animating=false;e.timerRotatingItems=null;e.animationsCount=1;e.css({margin:0,padding:0,position:'relative',overflow:'hidden'});e.items=e.find('>li').css({'list-style-type':'none',overflow:'hidden',margin:0,padding:0,position:'absolute',left:'-9999em',top:0,opacity:0});e.items.find('img').css({display:'block'});e.options.currentItem=Math.min((e.options.currentItem),e.items.length);e.options.currentItem=Math.max((e.options.currentItem-1),0);$.extend(e,{getPadding:function(a,b){return parseInt($(a).css('padding-'+b),10)},addPlugIns:function(){$.fn.simpleGallery.plugIns=$.extend({});for(var i in this.options.plugIns){var a=$.fn.simpleGallery.plugIn[i];if(typeof(a)=="function")a(this,this.options.plugIns[i])}},existPlugin:function(a){if(e.options.plugIns[a]!=undefined)return true;return false},setSizeOfGallery:function(b){e.width(b);e.items.each(function(){var a=$(this);a.width(b-e.getPadding(a,'left')-e.getPadding(a,'right'))})},setGalleryTimer:function(){if(!e.timerRotatingItems)e.timerRotatingItems=setInterval(e.showNextItem,e.options.rotatingInterval)},removeGalleryTimer:function(){if(e.timerRotatingItems){clearInterval(e.timerRotatingItems);e.timerRotatingItems=null}},startAutoRotating:function(){if(e.options.rotatingInterval<e.options.rotatingSpeed+1000)e.options.rotatingInterval=e.options.rotatingSpeed+1000;e.parent().hover(function(){e.hoverOnGallery=true},function(){e.hoverOnGallery=false});if(e.options.autoScroll&&typeof(e.showItem)=='function'){e.setGalleryTimer();if(e.options.stopAutoScrollByHover)e.parent().hover(function(){e.removeGalleryTimer()},function(){if(e.animating==false){e.setGalleryTimer()}else{var a=setInterval(function(){if(e.animating==false){clearInterval(a);e.setGalleryTimer()}},50)}})}},showNextItem:function(){var a=e.options.currentItem+1;if(a==e.items.length)a=0;if(!e.animating){if(e.options.autoScroll){e.removeGalleryTimer();e.setGalleryTimer()}e.showItem(a)}if(e.existPlugin('navigation'))e.setNavigationActiveItem(a)}});e.frameContainer=$('<div class="'+e.options.frameClass+'"><div class="'+e.options.frameClass+'_inner"><span class="gm_iv_f_sh gm_iv_f_sh_tl"/><span class="gm_iv_f_sh gm_iv_f_sh_tr"/></div><span class="gm_iv_f_sh gm_iv_f_sh_bl"/><span class="gm_iv_f_sh gm_iv_f_sh_br"/></div>').css({position:'relative',overflow:'hidden',width:e.options.galleryWidth});e.before(e.frameContainer);e.frameContainer.find('div.'+e.options.frameClass+'_inner').append(e);$(e.items[e.options.currentItem]).css({opacity:1,left:0}).addClass('active');e.setSizeOfGallery(e.options.galleryWidth);e.addPlugIns();$.fn.simpleGallery.loadEffect=$.extend({});var f=$.fn.simpleGallery.loadEffect[e.options.effect];if(f!=null)f(e);e.startAutoRotating()}$(window).bind('unload',function(){e.remove()});return this}})(jQuery);(function($){$.fn.simpleGallery.loadEffect=$.extend({'fade':function(d){$.extend(d,{hideItem:function(a){$(d.items[a]).stop().fadeTo(d.options.rotatingSpeed,0,function(){$(d.items[a]).css({left:'-9999em'}).removeClass('active')})},showItem:function(a,b){if(a!=d.options.currentItem){var c=0;d.animating=true;d.hideItem(d.options.currentItem);$(d.items[a]).stop().css({left:0}).fadeTo(d.options.rotatingSpeed,1,function(){$(d.items[a]).addClass('active');if(++c==d.animationsCount){if(typeof(b)=='function')b();if(typeof(d.options.showItemCallBack)=='function')d.options.showItemCallBack();d.animating=false}});if(d.existPlugin('label'))d.showLabel(a,function(){if(++c==d.animationsCount){if(typeof(b)=='function')b();if(typeof(d.options.showItemCallBack)=='function')d.options.showItemCallBack();d.animating=false}});d.options.currentItem=a}}})}})})(jQuery);
