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