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