/*
 * jQuery FlexSlider v1.7
 * http://flex.madebymufffin.com
 *
 * Copyright 2011, Tyler Smith
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Shoutout to Darin Richardson for his wonderful contributions to the betterment of FlexSlider
 */
(function(a){a.flexslider=function(b,c){var d=b;d.init=function(){d.vars=a.extend({},a.flexslider.defaults,c),d.data("flexslider",!0),d.container=a(".slides",d),d.slides=a(".slides > li",d),d.count=d.slides.length,d.animating=!1,d.currentSlide=d.vars.slideToStart,d.animatingTo=d.currentSlide,d.atEnd=d.currentSlide==0?!0:!1,d.eventType="ontouchstart"in document.documentElement?"touchstart":"click",d.cloneCount=0,d.cloneOffset=0,d.vars.controlsContainer!=""&&(d.controlsContainer=a(d.vars.controlsContainer).eq(a(".slides").index(d.container)),d.containerExists=d.controlsContainer.length>0),d.vars.manualControls!=""&&(d.manualControls=a(d.vars.manualControls,d.containerExists?d.controlsContainer:d),d.manualExists=d.manualControls.length>0),d.vars.randomize&&(d.slides.sort(function(){return Math.round(Math.random())-.5}),d.container.empty().append(d.slides)),d.vars.animation.toLowerCase()=="slide"?(d.css({overflow:"hidden"}),d.vars.animationLoop&&(d.cloneCount=2,d.cloneOffset=1,d.container.append(d.slides.filter(":first").clone().addClass("clone")).prepend(d.slides.filter(":last").clone().addClass("clone"))),d.container.width((d.count+d.cloneCount)*d.width()+2e3),d.newSlides=a(".slides > li",d),setTimeout(function(){d.newSlides.width(d.width()).css({"float":"left"}).show()},100),d.container.css({marginLeft:-1*(d.currentSlide+d.cloneOffset)*d.width()+"px"})):d.slides.css({width:"100%","float":"left",marginRight:"-100%"}).eq(d.currentSlide).fadeIn(400);if(d.vars.controlNav){if(d.manualExists)d.controlNav=d.manualControls;else{var b=a('<ol class="flex-control-nav"></ol>'),e=1;for(var f=0;f<d.count;f++)b.append("<li><a>"+e+"</a></li>"),e++;d.containerExists?(a(d.controlsContainer).append(b),d.controlNav=a(".flex-control-nav li a",d.controlsContainer)):(d.append(b),d.controlNav=a(".flex-control-nav li a",d))}d.controlNav.eq(d.currentSlide).addClass("active"),d.controlNav.bind(d.eventType,function(b){b.preventDefault(),a(this).hasClass("active")||d.flexAnimate(d.controlNav.index(a(this)),d.vars.pauseOnAction)})}if(d.vars.directionNav){var g=a('<ul class="flex-direction-nav"><li><a class="prev" href="#">'+d.vars.prevText+'</a></li><li><a class="next" href="#">'+d.vars.nextText+"</a></li></ul>");d.containerExists?(a(d.controlsContainer).append(g),d.directionNav=a(".flex-direction-nav li a",d.controlsContainer)):(d.append(g),d.directionNav=a(".flex-direction-nav li a",d)),d.vars.animationLoop||(d.currentSlide==0?d.directionNav.filter(".prev").addClass("disabled"):d.currentSlide==d.count-1&&d.directionNav.filter(".next").addClass("disabled")),d.directionNav.bind(d.eventType,function(b){b.preventDefault();var c=a(this).hasClass("next")?d.getTarget("next"):d.getTarget("prev");d.canAdvance(c)&&d.flexAnimate(c,d.vars.pauseOnAction)})}d.vars.keyboardNav&&a("ul.slides").length==1&&a(document).keyup(function(a){if(d.animating)return;if(a.keyCode!=39&&a.keyCode!=37)return;if(a.keyCode==39)var b=d.getTarget("next");else if(a.keyCode==37)var b=d.getTarget("prev");d.canAdvance(b)&&d.flexAnimate(b,d.vars.pauseOnAction)}),d.vars.slideshow&&(d.vars.pauseOnHover&&d.vars.slideshow&&d.hover(function(){d.pause()},function(){d.resume()}),d.animatedSlides=setInterval(d.animateSlides,d.vars.slideshowSpeed));if(d.vars.pausePlay){var h=a('<div class="flex-pauseplay"><span></span></div>');d.containerExists?(d.controlsContainer.append(h),d.pausePlay=a(".flex-pauseplay span",d.controlsContainer)):(d.append(h),d.pausePlay=a(".flex-pauseplay span",d));var i=d.vars.slideshow?"pause":"play";d.pausePlay.addClass(i).text(i=="pause"?d.vars.pauseText:d.vars.playText),d.pausePlay.click(function(b){b.preventDefault(),a(this).hasClass("pause")?d.pause():d.resume()})}d.vars.touchSwipe&&"ontouchstart"in document.documentElement&&d.each(function(){function c(){this.removeEventListener("touchmove",e),a=null,isMoving=!1}function e(e){if(isMoving){var f=e.touches[0].pageX,g=a-f;if(Math.abs(g)>=b){c();var h=g>0?d.getTarget("next"):d.getTarget("prev");d.canAdvance(h)&&d.flexAnimate(h,d.vars.pauseOnAction)}}}function f(b){b.touches.length==1&&(a=b.touches[0].pageX,isMoving=!0,this.addEventListener("touchmove",e,!1))}var a,b=20;isMoving=!1,"ontouchstart"in document.documentElement&&this.addEventListener("touchstart",f,!1)}),d.vars.animation.toLowerCase()=="slide"&&(d.sliderTimer,a(window).resize(function(){d.newSlides.width(d.width()),d.container.width((d.count+d.cloneCount)*d.width()+2e3),clearTimeout(d.sliderTimer),d.sliderTimer=setTimeout(function(){d.flexAnimate(d.currentSlide)},300)})),d.vars.start(d)},d.flexAnimate=function(a,b){d.animating||(d.animating=!0,d.animatingTo=a,d.vars.before(d),b&&d.pause(),d.vars.controlNav&&d.controlNav.removeClass("active").eq(a).addClass("active"),d.atEnd=a==0||a==d.count-1?!0:!1,!d.vars.animationLoop&&d.vars.directionNav&&(a==0?d.directionNav.removeClass("disabled").filter(".prev").addClass("disabled"):a==d.count-1?d.directionNav.removeClass("disabled").filter(".next").addClass("disabled"):d.directionNav.removeClass("disabled")),!d.vars.animationLoop&&a==d.count-1&&(d.pause(),d.vars.end(d)),d.vars.animation.toLowerCase()=="slide"?(d.currentSlide==0&&a==d.count-1&&d.vars.animationLoop?d.slideString="0px":d.currentSlide==d.count-1&&a==0&&d.vars.animationLoop?d.slideString=-1*(d.count+1)*d.slides.filter(":first").width()+"px":d.slideString=-1*(a+d.cloneOffset)*d.slides.filter(":first").width()+"px",d.container.animate({marginLeft:d.slideString},d.vars.animationDuration,function(){d.currentSlide==0&&a==d.count-1&&d.vars.animationLoop?d.container.css({marginLeft:-1*d.count*d.slides.filter(":first").width()+"px"}):d.currentSlide==d.count-1&&a==0&&d.vars.animationLoop&&d.container.css({marginLeft:-1*d.slides.filter(":first").width()+"px"}),d.animating=!1,d.currentSlide=a,d.vars.after(d)})):(d.slides.eq(d.currentSlide).fadeOut(d.vars.animationDuration),d.slides.eq(a).fadeIn(d.vars.animationDuration,function(){d.animating=!1,d.currentSlide=a,d.vars.after(d)})))},d.animateSlides=function(){if(!d.animating){var a=d.currentSlide==d.count-1?0:d.currentSlide+1;d.flexAnimate(a)}},d.pause=function(){clearInterval(d.animatedSlides),d.vars.pausePlay&&d.pausePlay.removeClass("pause").addClass("play").text(d.vars.playText)},d.resume=function(){d.animatedSlides=setInterval(d.animateSlides,d.vars.slideshowSpeed),d.vars.pausePlay&&d.pausePlay.removeClass("play").addClass("pause").text(d.vars.pauseText)},d.canAdvance=function(a){return!d.vars.animationLoop&&d.atEnd?d.currentSlide==0&&a==d.count-1&&d.direction!="next"?!1:d.currentSlide==d.count-1&&a==0&&d.direction=="next"?!1:!0:!0},d.getTarget=function(a){return d.direction=a,a=="next"?d.currentSlide==d.count-1?0:d.currentSlide+1:d.currentSlide==0?d.count-1:d.currentSlide-1},d.init()},a.flexslider.defaults={animation:"fade",slideshow:!0,slideshowSpeed:5e3,animationDuration:500,directionNav:!0,controlNav:!0,keyboardNav:!0,touchSwipe:!0,prevText:"Previous",nextText:"Next",pausePlay:!1,pauseText:"Pause",playText:"Play",randomize:!1,slideToStart:0,animationLoop:!0,pauseOnAction:!0,pauseOnHover:!1,controlsContainer:"",manualControls:"",start:function(){},before:function(){},after:function(){},end:function(){}},a.fn.flexslider=function(b){return this.each(function(){a(this).find(".slides li").length==1?a(this).find(".slides li").fadeIn(400):a(this).data("flexslider")!=1&&new a.flexslider(a(this),b)})}})(jQuery);
