(function($){$.fn.jCarouselLite=function(o){o=$.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},o||{});return this.each(function(){var curr=o.start,running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=div.find("ul"),li=div.find("li"),itemLength=li.size();div.css("visibility","visible");li.css("overflow","hidden").css("float",o.vertical?"none":"left").children().css("overflow","hidden");ul.css("margin","0").css("padding","0").css("position","relative").css("list-style-type","none").css("z-index","1");div.css("overflow","hidden").css("position","relative").css("z-index","2").css("left","0px");var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=liSize*o.visible;li.css("width",li.width()).css("height",li.height());ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if(o.btnPrev){$(o.btnPrev).click(function(){return go(curr-o.scroll);});}
if(o.btnNext){$(o.btnNext).click(function(){return go(curr+o.scroll);});}
if(o.btnGo){$.each(o.btnGo,function(i,val){$(val).click(function(){return go(i);});});}
if(o.mouseWheel&&div.mousewheel){div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll);});}
var autoInterval;function startAuto(){$('.pause').animate({'opacity':0},300);autoInterval=setInterval(function(){go(curr- o.scroll);},o.auto+ o.speed);};function stopAuto(){$('.pause').animate({'opacity':1},300);clearInterval(autoInterval);};if(o.auto){if(o.hoverPause){div.hover(function(){stopAuto();},function(){startAuto();});}
startAuto();};function vis(){return li.gt(curr-1).lt(o.visible);};function go(to){if(!running){running=true;if(o.beforeStart)o.beforeStart.call(this,vis());if(to<0&&curr==0){if(o.circular)curr=itemLength-o.visible;else return;}else if(to>=itemLength-o.visible&&curr+o.visible>=itemLength){if(o.circular)curr=0;else return;}else curr=to;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){ul.css(animCss,-(curr*liSize)+"px");if(o.afterEnd)o.afterEnd.call(this,vis());running=false;});}
return false;};});};function css(el,prop){return parseInt($.css(el.jquery?el[0]:el,prop))||0;};function width(el){return el[0].offsetWidth+ css(el,'marginLeft')+ css(el,'marginRight');};function height(el){return el[0].offsetHeight+ css(el,'marginTop')+ css(el,'marginBottom');};})(jQuery);
