(function(a){a.fn.carousel=function(b){var c={scroller:"",scrollList:"div#scroller_window ul",counter:"#scroll_count",nextLink:"li#scroll_next a",previousLink:"li#scroll_prev a",scrollDistance:462,displayCount:1,anime:false,expandDistance:85,animeNormal:{},animeCurrentSib:{},animeCurrent:{},randomize:false,autoscroll:false,horizontal:true,speed:500,custominit:function(){},allClickable:false};if(b){jQuery.extend(c,b)}return this.each(function(){var m=a(this).find(c.scrollList),k,h,l=false,o=1,q=this,p,j=(c.horizontal===true)?"left":"top";function r(){if(!l){h-=c.scrollDistance;l=true;if(c.anime===true){p.prev().find("a").animate(c.animeNormal,c.speed).parent().removeClass("next");p.find("a").animate(c.animeCurrentSib,c.speed).parent().removeClass("current").addClass("next");p.next().find("a").animate(c.animeCurrent,c.speed).parent().addClass("current");p.next().next().find("a").animate(c.animeCurrentSib,c.speed).parent().addClass("next")}var t=(c.horizontal===true)?{left:h+"px"}:{top:h+"px"};m.animate(t,c.speed,"swing",function(){o+=1;if(o>k){o=1}a(q).find(c.counter).text(o+" of "+k);d();p=p.next();l=false;if(c.autoscroll){r()}})}return false}function d(){if((c.scrollDistance*c.displayCount-h-(c.scrollDistance*k))===0){m.find("li:first").appendTo(m);h+=c.scrollDistance;m.css(j,h+"px")}}function n(){if(!l){if(h===0){m.find("li:last").prependTo(m);h-=c.scrollDistance;m.css(j,h+"px")}h+=c.scrollDistance;l=true;if(c.anime===true){p.find("a").animate(c.animeCurrentSib,c.speed).parent().removeClass("current").addClass("next");p.prev().find("a").animate(c.animeCurrent,c.speed).parent().removeClass("next").addClass("current");p.prev().prev().find("a").animate(c.animeCurrentSib,c.speed).parent().addClass("next");p.next().find("a").animate(c.animeNormal,c.speed).parent().removeClass("next")}var t=(c.horizontal===true)?{left:h+"px"}:{top:h+"px"};m.animate(t,c.speed,"swing",function(){o-=1;if(o<1){o=k}a(q).find(c.counter).text(o+" of "+k);p=p.prev();l=false})}return false}function f(){if(k>1){var t=m.children("li");var u=new Array();for(i=0;i<k;i++){u[u.length]=i}u=u.sort(e);a.each(u,function(w,v){m.append(t.eq(v))})}}function g(y,z){var t=m.children("li"),x=a("#"+z,m),u=t.index(p),w=t.index(x),v=c.scrollDistance*(w-u);h=parseInt(m.css(j))-v;if(v!=0){m.css(j,h);d();p=x}}function e(){return(Math.round(Math.random())-0.5)}function s(){k=m.find("li").length;h=0;l=false;o=1;var u=(c.horizontal===true)?"width":"height",t=(c.anime===false)?(c.scrollDistance*k):(c.scrollDistance*(k-1)+c.expandDistance);m.css(u,t+"px").css(j,"0px").show();p=(c.anime)?m.find("li.current"):m.children("li:first");a(q).bind("jumptoid",g);if(c.custominit){c.custominit()}}s();this.reload=function(){s()};if(c.randomize){f()}if(c.autoscroll){r()}else{a(this).find(c.nextLink).click(r).end().find(c.previousLink).click(n).end().find(c.counter).text(o+" of "+k);if(c.allClickable){a(this).click(r)}}})}})(jQuery);