(function(n){n.fn.orbit=function(t){var r={animation:"horizontal-push",animationSpeed:600,timer:!0,advanceSpeed:4e3,pauseOnHover:!1,startClockOnMouseOut:!1,startClockOnMouseOutAfter:1e3,directionalNav:!0,captions:!0,captionAnimation:"fade",captionAnimationSpeed:600,bullets:!1,bulletThumbs:!1,bulletThumbLocation:"",afterSlideChange:function(){}},t=n.extend(r,t);return this.each(function(){function vt(){b=!1}function yt(){b=!0}function k(){if(t.timer&&t.timer!="false")y.is(":hidden")?g=setInterval(function(){a("next")},t.advanceSpeed):(p=!0,rt.removeClass("active"),g=setInterval(function(){var n="rotate("+l+"deg)";l+=2;d.css({"-webkit-transform":n,"-moz-transform":n,"-o-transform":n});l>180&&(d.addClass("move"),it.addClass("move"));l>360&&(d.removeClass("move"),it.removeClass("move"),l=0,a("next"))},t.advanceSpeed/180));else return!1}function c(){if(t.timer&&t.timer!="false")p=!1,clearInterval(g),rt.addClass("active");else return!1}function et(){if(t.captions&&t.captions!="false"){var i=u.eq(r).data("caption");_captionHTML=n(i).html();_captionHTML?(s.attr("id",i).html(_captionHTML),t.captionAnimation=="none"&&s.show(),t.captionAnimation=="fade"&&s.fadeIn(t.captionAnimationSpeed),t.captionAnimation=="slideOpen"&&s.slideDown(t.captionAnimationSpeed)):(t.captionAnimation=="none"&&s.hide(),t.captionAnimation=="fade"&&s.fadeOut(t.captionAnimationSpeed),t.captionAnimation=="slideOpen"&&s.slideUp(t.captionAnimationSpeed))}else return!1}function at(){if(t.bullets)lt.children("li").removeClass("active").eq(r).addClass("active");else return!1}function a(n){function e(){u.eq(f).css({"z-index":1});vt();t.afterSlideChange.call(this)}var f=r,i=n;if(f==i||u.length=="1")return!1;b||(yt(),n=="next"?(r++,r==v&&(r=0)):n=="prev"?(r--,r<0&&(r=v-1)):(r=n,f<r?i="next":f>r&&(i="prev")),at(),u.eq(f).css({"z-index":2}),t.animation=="fade"&&u.eq(r).css({opacity:0,"z-index":3}).animate({opacity:1},t.animationSpeed,e),t.animation=="horizontal-slide"&&(i=="next"&&u.eq(r).css({left:o,"z-index":3}).animate({left:0},t.animationSpeed,e),i=="prev"&&u.eq(r).css({left:-o,"z-index":3}).animate({left:0},t.animationSpeed,e)),t.animation=="vertical-slide"&&(i=="prev"&&u.eq(r).css({top:w,"z-index":3}).animate({top:0},t.animationSpeed,e),i=="next"&&u.eq(r).css({top:-w,"z-index":3}).animate({top:0},t.animationSpeed,e)),t.animation=="horizontal-push"&&(i=="next"&&(u.eq(r).css({left:o,"z-index":3}).animate({left:0},t.animationSpeed,e),u.eq(f).animate({left:-o},t.animationSpeed)),i=="prev"&&(u.eq(r).css({left:-o,"z-index":3}).animate({left:0},t.animationSpeed,e),u.eq(f).animate({left:o},t.animationSpeed))),et())}var r=0,v=0,o,w,b,e=n(this).addClass("orbit"),f=e.wrap('<div class="orbit-wrapper" />').parent(),u,tt,y,p,ut,ft,s,ot,st,ht,ct,lt,nt,h;if(e.add(o).width("1px").height("1px"),u=e.children("img, a, div"),u.each(function(){var t=n(this),i=t.width(),r=t.height();i>e.width()&&(e.add(f).width(i),o=e.width());r>e.height()&&(e.add(f).height(r),w=e.height());v++}),u.length==1&&(t.directionalNav=!1,t.timer=!1,t.bullets=!1),u.eq(r).css({"z-index":3}).fadeIn(function(){u.css({display:"block"})}),t.timer&&(tt='<div class="timer"><span class="mask"><span class="rotator"><\/span><\/span><span class="pause"><\/span><\/div>',f.append(tt),y=f.children("div.timer"),y.length!=0)){var d=n("div.timer span.rotator"),it=n("div.timer span.mask"),rt=n("div.timer span.pause"),l=0,g;k();y.click(function(){p?c():k()});t.startClockOnMouseOut&&(f.mouseleave(function(){ut=setTimeout(function(){p||k()},t.startClockOnMouseOutAfter)}),f.mouseenter(function(){clearTimeout(ut)}))}if(t.pauseOnHover&&f.mouseenter(function(){c()}),t.captions&&(ft='<div class="orbit-caption"><\/div>',f.append(ft),s=f.children(".orbit-caption"),et()),t.directionalNav){if(t.directionalNav=="false")return!1;ot='<div class="slider-nav"><span class="right">Right<\/span><span class="left">Left<\/span><\/div>';f.append(ot);st=f.children("div.slider-nav").children("span.left");ht=f.children("div.slider-nav").children("span.right");st.click(function(){c();a("prev")});ht.click(function(){c();a("next")})}if(t.bullets){for(ct='<ul class="orbit-bullets"><\/ul>',f.append(ct),lt=f.children("ul.orbit-bullets"),i=0;i<v;i++)h=n("<li>"+(i+1)+"<\/li>"),t.bulletThumbs&&(nt=u.eq(i).data("thumb"),nt&&(h=n('<li class="has-thumb">'+i+"<\/li>"),h.css({background:"url("+t.bulletThumbLocation+nt+") no-repeat"}))),f.children("ul.orbit-bullets").append(h),h.data("index",i),h.click(function(){c();a(n(this).data("index"))});at()}})}})(jQuery)