(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,btnSlides: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 running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("> ul:first-of-type",div),tLi=$("> ul:first-of-type > li",div),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v;}
var li=tLi,itemLength=tl,curr=o.start;div.css("visibility","visible");li.css({overflow:"hidden","float":o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=(liSize*v)-css(li[1],'marginLeft');ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if((o.btnPrev||o.btnNext||o.btnSlides)&&itemLength>o.visible){if(!running){$(o.btnPrev).addClass('disabled');$(o.btnNext).removeClass('disabled');}
$(o.btnPrev).click(function(){return go(curr-o.scroll);});$(o.btnNext).click(function(){return go(curr+o.scroll);});if(o.btnSlides){cueButtons="";for(var i=0;i<itemLength/o.scroll;i++){cueButtons+="<li><span>"+i+"</span></li>";};
cueButtons +="<li class='static'>&rarr; more</li>";
$("<ul />").addClass("cueButtons").html(cueButtons).insertBefore(o.btnSlides);$('ul.cueButtons li:not(.static)').each(function(){$(this).click(function(){return go($(this).prevAll().length*o.scroll);});});$('ul.cueButtons li:first').addClass("active");}}else{$(o.btnPrev).addClass('disabled');$(o.btnNext).addClass('disabled');}
if(o.btnGo)
$.each(o.btnGo,function(i,val){$(val).click(function(){return go(o.circular?o.visible+i:i);});});if(o.mouseWheel&&div.mousewheel)
div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll);});if(o.auto)
setInterval(function(){go(curr+o.scroll);},o.auto+o.speed);function setActive(offset){if(offset>=0&&offset<itemLength){$('li.active','ul.cueButtons').removeClass("active");$('li:eq('+Math.ceil(offset/o.visible)+')','ul.cueButtons').addClass('active');}}
function vis(){return li.slice(curr).slice(0,v);};function go(to){if(!running){if(itemLength<=o.visible)
return false;if(o.beforeStart)
o.beforeStart.call(this,vis());if(o.circular){if(to<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*liSize)+"px");curr=to==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll;}else if(to>=itemLength-v+1){ul.css(animCss,-((v)*liSize)+"px");curr=to==itemLength-v+1?v+1:v+o.scroll;}else curr=to;}else{if(to<0){if(curr=0){return false;}else{curr=0;}}else if(to>itemLength-v){if(curr==itemLength-v){return false;}else{curr=itemLength-v;}}else{curr=to;}}
running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){if(o.afterEnd)
o.afterEnd.call(this,vis());running=false;});if(o.btnSlides)
setActive(curr);if(!o.circular){if(curr==0){$(o.btnPrev).addClass("disabled");}else{$(o.btnPrev).removeClass("disabled");}
if(curr==itemLength-v){$(o.btnNext).addClass("disabled");}else{$(o.btnNext).removeClass("disabled");}}}
return false;};});};function css(el,prop){return parseInt($.css(el,prop))||0;};function width(el){return el[1].offsetWidth+css(el[1],'marginLeft')+css(el[1],'marginRight');};function height(el){return el[1].offsetHeight+css(el[1],'marginTop')+css(el[1],'marginBottom');};})(jQuery);
