/*
    anythingSlider v1.2
    
    By Chris Coyier: http://css-tricks.com
    with major improvements by Doug Neiner: http://pixelgraphics.us/
    based on work by Remy Sharp: http://jqueryfordesigners.com/


	To use the navigationFormatter function, you must have a function that
	accepts two paramaters, and returns a string of HTML text.
	
	index = integer index (1 based);
	panel = jQuery wrapped LI item this tab references
	@return = Must return a string of HTML/Text
	
	navigationFormatter: function(index, panel){
		return index + " Panel"; // This would have each tab with the text 'X Panel' where X = index
	}
*/
(function($){$.anythingSlider=function(a,b){var c=this;c.$el=$(a);c.el=a;c.currentPage=1;c.timer=null;c.playing=false;c.$el.data("AnythingSlider",c);c.init=function(){c.options=$.extend({},$.anythingSlider.defaults,b);c.$wrapper=c.$el.find("> div").css("overflow","hidden");c.$slider=c.$wrapper.find("> ul");c.$items=c.$slider.find("> li");c.$single=c.$items.filter(":first");if(c.options.buildNavigation){c.buildNavigation()}c.singleWidth=c.$single.outerWidth();c.pages=c.$items.length;c.$items.filter(":first").before(c.$items.filter(":last").clone().addClass("cloned"));c.$items.filter(":last").after(c.$items.filter(":first").clone().addClass("cloned"));c.$items=c.$slider.find("> li");c.buildNextBackButtons();if(c.options.autoPlay){c.playing=!c.options.startStopped;c.buildAutoPlay()}if(c.options.pauseOnHover){c.$el.hover(function(){c.clearTimer()},function(){c.startStop(c.playing)})}if((c.options.hashTags==true&&!c.gotoHash())||c.options.hashTags==false){c.setCurrentPage(1)}};c.gotoPage=function(d,e){if(e!==true){e=false}if(typeof (d)=="undefined"||d==null){d=1;c.setCurrentPage(1)}if(d>c.pages+1){d=c.pages}if(d<0){d=1}var f=d<c.currentPage?-1:1,n=Math.abs(c.currentPage-d),g=c.singleWidth*f*n;c.$wrapper.filter(":not(:animated)").animate({scrollLeft:"+="+g},c.options.animationTime,c.options.easing,function(){if(d==0){c.$wrapper.scrollLeft(c.singleWidth*c.pages);d=c.pages}else{if(d>c.pages){c.$wrapper.scrollLeft(c.singleWidth);d=1}}c.setCurrentPage(d)})};c.setCurrentPage=function(d,e){if(c.options.buildNavigation){c.$nav.find(".cur").removeClass("cur");$(c.$navLinks[d-1]).addClass("cur")}if(e!==false){c.$wrapper.scrollLeft(c.singleWidth*d)}c.currentPage=d};c.goForward=function(d){if(d!==true){d=false}c.gotoPage(c.currentPage+1,d)};c.goBack=function(){c.gotoPage(c.currentPage-1)};c.gotoHash=function(){if(/^#?panel-\d+$/.test(window.location.hash)){var d=parseInt(window.location.hash.substr(7));var e=c.$items.filter(":eq("+d+")");if(e.length!=0){c.setCurrentPage(d);return true}}return false};c.buildNavigation=function(){c.$nav=$("<div id='thumbNav'></div>").appendTo(c.$el);c.$items.each(function(i,d){var e=i+1;var f=$("<a href='#'></a>");if(typeof (c.options.navigationFormatter)=="function"){f.html(c.options.navigationFormatter(e,$(this)))}else{f.text(e)}f.click(function(g){c.gotoPage(e);if(c.options.hashTags){c.setHash("panel-"+e)}g.preventDefault()});c.$nav.append(f)});c.$navLinks=c.$nav.find("> a")};c.buildNextBackButtons=function(){var d=$('<a class="arrow forward"></a>'),e=$('<a class="arrow back"></a>');e.click(function(f){c.goBack();f.preventDefault()});d.click(function(f){c.goForward();f.preventDefault()});c.$wrapper.after(e).after(d)};c.buildAutoPlay=function(){c.$startStop=$("<a href='#' id='start-stop'></a>").html(c.playing?c.options.stopText:c.options.startText);c.$el.append(c.$startStop);c.$startStop.click(function(e){c.startStop(!c.playing);e.preventDefault()});c.startStop(c.playing)};c.startStop=function(d){if(d!==true){d=false}c.playing=d;if(c.options.autoPlay){c.$startStop.toggleClass("playing",d).html(d?c.options.stopText:c.options.startText)}if(d){c.clearTimer();c.timer=window.setInterval(function(){c.goForward(true)},c.options.delay)}else{c.clearTimer()}};c.clearTimer=function(){if(c.timer){window.clearInterval(c.timer)}};c.setHash=function(d){if(typeof window.location.hash!=="undefined"){if(window.location.hash!==d){window.location.hash=d}}else{if(location.hash!==d){location.hash=d}}return d};c.init()};$.anythingSlider.defaults={easing:"swing",autoPlay:true,startStopped:false,delay:3000,animationTime:600,hashTags:true,buildNavigation:true,pauseOnHover:true,startText:"Start",stopText:"Stop",navigationFormatter:null};$.fn.anythingSlider=function(a){if(typeof (a)=="object"){return this.each(function(i){(new $.anythingSlider(this,a));a.hashTags=false})}else{if(typeof (a)=="number"){return this.each(function(i){var b=$(this).data("AnythingSlider");if(b){b.gotoPage(a)}})}}}})(jQuery)