/**
 * jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.
 * @requires jQuery v1.2 or above
 *
 * http://gmarwaha.com/jquery/jcarousellite/
 *
 * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 1.0.1
 * Note: Requires jquery 1.2 or above from version 1.0.1
 * Patched for: pauseOnHover, stopOnClick, fix circular, and randomize
 */

(function(d){d.fn.jCarouselLite=function(e){e=d.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:15000,speed:1000,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,pauseOnHover:true,stopOnClick:true,beforeStart:null,afterEnd:null},e||{});return this.each(function(){var h=false,f=e.vertical?"top":"left",g=e.vertical?"height":"width";var p=d(this),n=d("ul",p),t=d("li",n),i=t.size(),l=e.visible,y=0;if(e.circular){n.prepend(t.slice(i-l+1).clone()).append(t.slice(0,e.scroll).clone());e.start+=l-1}e.pauseOnHover?n.hover(function(){y=1},function(){y=0}):"";var m=d("li",n),k=m.size(),u=e.start;p.css("visibility","visible");m.css({overflow:"hidden","float":e.vertical?"none":"left"});n.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});p.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var x=e.vertical?a(m):c(m);var w=x*k;var o=x*l;m.css({width:m.width(),height:m.height()});n.css(g,w+"px").css(f,-(u*x));if(e.btnPrev){d(e.btnPrev).click(function(){r();return s(u-e.scroll)})}if(e.btnNext){d(e.btnNext).click(function(){r();return s(u+e.scroll)})}if(e.btnGo){d.each(e.btnGo,function(v,z){d(z).click(function(){return s(e.circular?e.visible+v:v)})})}if(e.mouseWheel&&p.mousewheel){p.mousewheel(function(v,z){return z>0?s(u-e.scroll):s(u+e.scroll)})}if(e.auto){var j=setInterval(function(){s(u+e.scroll)},e.auto+e.speed)}function r(){if(e.stopOnClick){clearInterval(j);r=function(){return}}}function q(){return m.slice(u).slice(0,l)}function s(v){if(!h&&!y){if(e.beforeStart){e.beforeStart.call(this,q())}if(e.circular){if(v<0){n.css(f,-((u+i)*x)+"px");u=v+i}else{if(v>k-l){n.css(f,-((u-i)*x)+"px");u=v-i}else{u=v}}}else{if(v<0||v>k-l){return}else{u=v}}h=true;n.animate(f=="left"?{left:-(u*x)}:{top:-(u*x)},e.speed,e.easing,function(){if(e.afterEnd){e.afterEnd.call(this,q())}h=false});if(!e.circular){d(e.btnPrev+","+e.btnNext).removeClass("disabled");d((u-e.scroll<0&&e.btnPrev)||(u+e.scroll>k-l&&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")}d(document).ready(function(){var e=d("#carousel li").length;var f=Math.floor(Math.random()*(e-1));var g=d("#carousel");g.jCarouselLite({btnNext:".next",btnPrev:".prev",start:f})})})(jQuery);
