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