/*
 * jQuery Plus Slider 1.4.5
 * By Jamy Golden
 * http://css-plus.com
 * @jamygolden
 *
 * Copyright 2011
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 */

(function(a){a.plusSlider=function(b,c){var d=this;d.$el=a(b);d.el=b;d.$el.data("plusSlider",d);d.init=function(){d.options=a.extend({},a.plusSlider.defaults,c);d.$el.addClass("plusslider-container").wrap('<div class="plusslider '+d.$el.attr("id")+'" />');d.$wrap=d.$el.parent();d.$slides=d.$el.children();d.$wrapContainer=d.$wrap.parent();d.slideCount=d.$slides.length;d.slideIndexCount=d.slideCount-1;d.sliderWidth=0;d.animating=false;d.wrapContainerWidth=d.$wrapContainer.width();d.wrapContainerHeight=d.$wrapContainer.height();d.currentSlideIndex=d.options.defaultSlide;d.$currentSlide=d.$slides.eq(d.currentSlideIndex);d.currentSlideWidth=d.$currentSlide.outerWidth();d.currentSlideHeight=d.$currentSlide.outerHeight();d.calculateSliderWidth=function(){for(var a=0;a<d.slideCount;a++){if(a==0)d.sliderWidth=0;d.sliderWidth+=d.$slides.eq(a).outerWidth()}};d.beginTimer=function(){d.timer=window.setInterval(function(){d.toSlide("next")},d.options.displayTime)};d.clearTimer=function(){if(d.timer){window.clearInterval(d.timer)}};d.setSliderDimensions=function(){d.calculateSliderWidth();d.currentSlideWidth=d.$currentSlide.outerWidth();d.currentSlideHeight=d.$currentSlide.outerHeight();if(d.options.fullWidth){d.sliderWidth=d.wrapContainerWidth*d.slideCount;d.wrapContainerWidth=d.$wrapContainer.width();d.$slides.width(d.wrapContainerWidth);d.calculateSliderWidth();d.$wrap.width(d.wrapContainerWidth).height(d.currentSlideHeight);d.$el.width(d.sliderWidth).css("left",d.$currentSlide.position().left*-1+"px")}else if(d.options.sliderType=="slider"){d.$wrap.width(d.currentSlideWidth);d.$wrap.height(d.currentSlideHeight)}};d.toSlide=function(a){if(d.animating==false){d.animating=true;if(a==="next"||a===""){d.currentSlideIndex+=1}else if(a==="prev"){d.currentSlideIndex-=1}else{d.currentSlideIndex=parseInt(a)}if(d.options.disableLoop=="first"||d.options.disableLoop=="both"&&d.currentSlideIndex<0||d.options.disableLoop=="last"||d.options.disableLoop=="both"&&d.currentSlideIndex>d.slideIndexCount){return}if(d.currentSlideIndex>d.slideIndexCount){d.currentSlideIndex=0}else if(d.currentSlideIndex<0){d.currentSlideIndex=d.slideIndexCount}d.$currentSlide=d.$slides.eq(d.currentSlideIndex);d.currentSlideWidth=d.$currentSlide.width();d.currentSlideHeight=d.$currentSlide.height();if(d.options.onSlide&&typeof d.options.onSlide=="function")d.options.onSlide(d);if(d.options.sliderType=="slider"){if(d.options.createPagination){d.$sliderControls.find("li").removeClass("current").eq(d.currentSlideIndex).addClass("current")}d.$el.animate({height:d.$currentSlide.outerHeight(),left:d.$currentSlide.position().left*-1+"px"},d.options.speed,d.options.sliderEasing,function(){d.animating=false;if(d.options.afterSlide&&typeof d.options.afterSlide=="function")d.options.afterSlide(d);if(d.options.onSlideEnd&&typeof d.options.onSlideEnd=="function"&&d.currentSlideIndex==d.slideIndexCount)d.options.onSlideEnd(d)});d.$wrap.animate({height:d.$currentSlide.outerHeight(),width:d.$currentSlide.outerWidth()},d.options.speed,d.options.sliderEasing);d.$slides.removeClass("current").eq(d.currentSlideIndex).addClass("current")}else{if(d.options.createPagination){d.$sliderControls.find("li").removeClass("current").eq(d.currentSlideIndex).addClass("current")}d.$slides.removeClass("current").eq(d.currentSlideIndex).addClass("current").fadeIn(d.options.speed,function(){d.$slides.not(".current").hide();d.animating=false;if(d.options.afterSlide&&typeof d.options.afterSlide=="function")d.options.afterSlide(d);if(d.options.onSlideEnd&&typeof d.options.onSlideEnd=="function"&&d.currentSlideIndex==d.slideIndexCount)d.options.onSlideEnd(d)})}}if(d.options.autoPlay){d.clearTimer();d.beginTimer()}};if(d.slideCount===1){d.options.autoPlay=false;d.options.createArrows=false;d.options.createPagination=false}if(d.options.sliderType=="fader")d.options.fullWidth=false;d.$slides.addClass("child").eq(d.currentSlideIndex).addClass("current");d.setSliderDimensions();if(d.options.width)d.$wrap.width(d.options.width);if(d.options.height)d.$wrap.height(d.options.height);d.currentSlideWidth=d.$currentSlide.outerWidth();d.currentSlideHeight=d.$currentSlide.outerHeight();if(d.options.sliderType=="slider"){d.calculateSliderWidth();d.$wrap.addClass("plustype-slider").find(d.$el).width(d.sliderWidth);if(d.options.fullWidth){d.setSliderDimensions();a(window).resize(function(){d.clearTimer();d.beginTimer();d.setSliderDimensions()})}d.$slides.show();d.$el.css("left",d.$currentSlide.position().left*-1+"px")}else{d.$wrap.addClass("plustype-fader");d.$slides.eq(0).show()}if(d.options.createPagination){d.$sliderControls=a("<ul />",{"class":"plusslider-pagination"});switch(d.options.paginationPosition){case"before":d.$sliderControls.insertBefore(d.$wrap);break;case"prepend":d.$sliderControls.prependTo(d.$wrap);break;case"after":d.$sliderControls.insertAfter(d.$wrap);break;default:d.$sliderControls.appendTo(d.$wrap);break}d.$sliderControls.wrap('<div class="plusslider-pagination-wrapper" />');for(var b=0;b<d.slideCount;b++){a("<li />",{"data-index":b,text:d.options.paginationTitle?d.$slides.eq(b).attr("data-title"):b+1}).appendTo(d.$sliderControls)}if(d.options.paginationWidth)d.$sliderControls.width(d.$sliderControls.find("li").outerWidth(true)*d.slideCount);d.$sliderControls.find("li").click(function(){var b=a(this).index();d.toSlide(b)}).eq(d.currentSlideIndex).addClass("current")}if(d.options.createArrows){d.$arrows=a("<ul />",{"class":"plusslider-arrows"});switch(d.options.arrowsPosition){case"before":d.$arrows.insertBefore(d.$wrap);break;case"append":d.$arrows.appendTo(d.$wrap);break;case"after":d.$arrows.insertAfter(d.$wrap);break;default:d.$arrows.prependTo(d.$wrap);break}d.$arrows.wrap('<div class="plusslider-arrows-wrapper" />');a("<li />",{"class":"next",text:d.options.nextText}).prependTo(d.$arrows);a("<li />",{"class":"prev",text:d.options.prevText}).prependTo(d.$arrows);d.$arrows.find(".next").click(function(){d.toSlide("next")});d.$arrows.find(".prev").click(function(){d.toSlide("prev")})}if(d.options.autoPlay){d.beginTimer();if(d.options.pauseOnHover){d.$el.hover(function(){d.clearTimer()},function(){d.beginTimer()})}}if(d.options.keyboardNavigation){d.$el.click(function(){a(".active-plusslider").removeClass("active-plusslider");a(this).addClass("active-plusslider")});a(window).keyup(function(a){if(d.$el.is(".active-plusslider")){if(a.keyCode==39){d.toSlide("next")}else if(a.keyCode==37){d.toSlide("prev")}}})}if(d.options.onInit&&typeof d.options.onInit=="function")d.options.onInit(d)};d.init()};a.plusSlider.defaults={sliderType:"slider",disableLoop:false,fullWidth:false,width:null,height:null,defaultSlide:0,displayTime:4e3,sliderEasing:"linear",speed:500,autoPlay:true,keyboardNavigation:true,pauseOnHover:true,createArrows:true,arrowsPosition:"prepend",nextText:"Next",prevText:"Previous",createPagination:true,paginationPosition:"append",paginationWidth:false,paginationTitle:false,onInit:null,onSlide:null,afterSlide:null,onSlideEnd:null};a.fn.plusSlider=function(b){return this.each(function(){new a.plusSlider(this,b)})}})(jQuery)