(function(e){e.fn.jCarouselLite=function(f){f=e.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,getcurrent:false,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null,firststart:0},f||{});return this.each(function(){var k=false,g=f.vertical?"top":"left",h=f.vertical?"height":"width";var s=e(this),q=e("ul",s),w=e("li",q),l=w.size(),o=f.visible;var n=null;if(f.circular){q.prepend(w.slice(l-o).clone()).append(w.slice(0,o).clone());f.start+=o}var p=e("li",q),m=p.size(),x=f.start;if(f.circular){for(i=0;i<2*o;i++){var A=e(".lazy_img[rel]",e("li:nth-child("+(i+1)+")",q));if(A.length!=0){A.attr("src",A.attr("rel"));A.removeAttr("rel")}if(i>=o){var A=e(".lazy_img[rel]",e("li:nth-child("+(m-i+1)+")",q));if(A.length!=0){A.attr("src",A.attr("rel"));A.removeAttr("rel")}}}}s.css("visibility","visible");p.css({overflow:"hidden","float":f.vertical?"none":"left"});q.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});s.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var z=f.vertical?a(p):c(p);var y=z*m;var r=z*o;p.css({width:p.width(),height:p.height()});q.css(h,y+"px").css(g,-(x*z));s.css(h,r+"px");if(f.btnPrev){e(f.btnPrev).click(function(){j();return u(f.circular?x-f.scroll:Math.max(0,x-f.scroll))})}if(f.btnNext){e(f.btnNext).click(function(){j();return u(f.circular?x+f.scroll:Math.min(x+f.scroll,m-o))})}if(f.btnGo){e.each(f.btnGo,function(v,B){e(B).click(function(){j();return u(f.circular?f.visible+v:v)})})}if(f.mouseWheel&&s.mousewheel){s.mousewheel(function(v,B){return B>0?u(x-f.scroll):u(x+f.scroll)})}if(f.auto){if(f.firststart>0){setTimeout(function(){n=setInterval(function(){u(x+f.scroll)},f.auto+f.speed)},f.firststart)}else{n=setInterval(function(){u(x+f.scroll)},f.auto+f.speed)}}function t(){return p.slice(x).slice(0,o)}function j(){if(f.auto){clearInterval(n);n=setInterval(function(){u(x+f.scroll)},f.auto+f.speed)}return}function u(B){if(!k){if(f.beforeStart){f.beforeStart.call(this,t())}if(f.circular){if(B<=f.start-o-1){q.css(g,(-(x+l)*z)+"px");d=(B+l)-x;x=B+l}else{if(B>=m-o+1){q.css(g,(-(x-l)*z)+"px");x=B-l}else{x=B}}d=1}else{if(B<0||B>m-o||B==x){return}d=Math.abs(B-x)/f.scroll;x=B}for(i=x;i<x+f.scroll;i++){var v=e(".lazy_img[rel]",e("li:nth-child("+(i+1)+")",q));if(v.length!=0){v.attr("src",v.attr("rel"));v.removeAttr("rel")}}k=true;q.animate(g=="left"?{left:-(x*z)}:{top:-(x*z)},f.speed*d,f.easing,function(){if(f.afterEnd){f.afterEnd.call(this,t())}k=false});if(!f.circular){e(f.btnPrev+","+f.btnNext).removeClass("disabled");if(x==0){e(f.btnPrev).addClass("disabled")}if(x+f.scroll==m){e(f.btnNext).addClass("disabled")}}}return false}})};function b(f,g){return parseInt(jQuery.css(f[0],g))||0}function c(f){return f[0].offsetWidth+b(f,"marginLeft")+b(f,"marginRight")}function a(f){return f[0].offsetHeight+b(f,"marginTop")+b(f,"marginBottom")}})(jQuery);
