(function(a){a.fn.orbit=function(b){var c={animation:"fade",animationSpeed:800,advanceSpeed:4000,startClockOnMouseOut:true,startClockOnMouseOutAfter:3000,directionalNav:true,captions:true,captionAnimationSpeed:800,timer:false,bullets:false};var b=a.extend(c,b);return this.each(function(){var e=0;var q=0;var g;var f;var H;var I=a(this).addClass("orbit");var p=I.find("img, a img");p.each(function(){var M=a(this);var L=M.width();var K=M.height();I.width(L);g=I.width();I.height(K);f=I.height();q++});p.eq(e).css({"z-index":3});if(b.timer){var u='<div class="timer"><span class="mask"><span class="rotator"></span></span><span class="pause"></span></div>';I.append(u);var r=a("div.timer");var C;if(r.length!=0){var z=(b.advanceSpeed)/180;var m=a("div.timer span.rotator");var y=a("div.timer span.mask");var l=a("div.timer span.pause");var x=0;var J;function G(){C=true;l.removeClass("active");J=setInterval(function(L){var K="rotate("+x+"deg)";x+=2;m.css({"-webkit-transform":K,"-moz-transform":K,"-o-transform":K});if(x>180){m.addClass("move");y.addClass("move")}if(x>360){m.removeClass("move");y.removeClass("move");x=0;A("next")}},z)}function h(){C=false;clearInterval(J);l.addClass("active")}G();r.click(function(){if(!C){G()}else{h()}});if(b.startClockOnMouseOut){var B;I.mouseleave(function(){B=setTimeout(function(){if(!C){G()}},b.startClockOnMouseOutAfter)});I.mouseenter(function(){clearTimeout(B)})}}}function k(){H=false}function F(){H=true}if(b.captions){var t='<div class="caption"><span class="orbit-caption"></span></div>';I.append(t);var E=I.children("div.caption").children("span").addClass("orbit-caption").show();function s(){var L=p.eq(e).attr("rel");var M=a("#"+L).html();var K=E.height()+20;E.attr("id","#"+L).html(M);if(!M){E.parent().stop().animate({bottom:-K},b.captionAnimationSpeed)}else{E.parent().stop().animate({bottom:0},b.captionAnimationSpeed)}}s()}if(b.directionalNav){var n='<div class="slider-nav"><span class="right">Right</span><span class="left">Left</span></div>';I.append(n);var w=I.children("div.slider-nav").children("span.left");var D=I.children("div.slider-nav").children("span.right");w.click(function(){if(b.timer){h()}A("prev")});D.click(function(){if(b.timer){h()}A("next")})}if(b.bullets){var d='<ul class="orbit-bullets"></ul>';I.append(d);var j=a("ul.orbit-bullets");for(i=0;i<q;i++){var o=a("<li>"+i+"</li>");a("ul.orbit-bullets").append(o);o.data("index",i);o.click(function(){if(b.timer){h()}A(a(this).data("index"))})}function v(){j.children("li").removeClass("active").eq(e).addClass("active")}v()}function A(M){var L=e;var K=M;if(L==K){return false}function N(){p.eq(L).css({"z-index":1});k()}if(!H){F();if(M=="next"){e++;if(e==q){e=0}}else{if(M=="prev"){e--;if(e<0){e=q-1}}else{e=M;if(L<e){K="next"}else{if(L>e){K="prev"}}}}if(b.bullets){v()}if(b.animation=="fade"){p.eq(L).css({"z-index":2});p.eq(e).css({opacity:0,"z-index":3}).animate({opacity:1},b.animationSpeed,N);if(b.captions){s()}}if(b.animation=="horizontal-slide"){p.eq(L).css({"z-index":2});if(K=="next"){p.eq(e).css({left:g,"z-index":3}).animate({left:0},b.animationSpeed,N)}if(K=="prev"){p.eq(e).css({left:-g,"z-index":3}).animate({left:0},b.animationSpeed,N)}if(b.captions){s()}}if(b.animation=="vertical-slide"){p.eq(L).css({"z-index":2});if(K=="prev"){p.eq(e).css({top:f,"z-index":3}).animate({top:0},b.animationSpeed,N)}if(K=="next"){p.eq(e).css({top:-f,"z-index":3}).animate({top:0},b.animationSpeed,N)}if(b.captions){s()}}}}})}})(jQuery);
