/*
 * Moving Boxes v2.2.5 minified
 * by Chris Coyier 
 * http://css-tricks.com/moving-boxes/
 */

(function(c){c.movingBoxes=function(h,i){var b,a=this;a.$el=c(h).addClass("mb-slider");a.el=h;a.$el.data("movingBoxes",a);a.init=function(){a.options=b=c.extend({},c.movingBoxes.defaultOptions,i);a.$el.wrap('<div class="movingBoxes mb-wrapper"><div class="mb-scroll" /></div>');a.$window=a.$el.parent();a.$wrap=a.$window.parent().prepend('<a class="mb-scrollButtons mb-left"></a>').append('<a class="mb-scrollButtons mb-right"></a><div class="mb-left-shadow"></div><div class="mb-right-shadow"></div>'); a.$panels=a.$el.children().addClass("mb-panel");a.runTime=c(".mb-slider").index(a.$el)+1;a.regex=RegExp("slider"+a.runTime+"=(\\d+)","i");a.initialized=!1;a.currentlyMoving=!1;a.curPanel=b.initAnimation?1:b.hashTags?a.getHash()||b.startPanel:b.startPanel;a.width=b.width?parseInt(b.width,10):a.$el.width();a.pWidth=b.panelWidth?2>=b.panelWidth?b.panelWidth*a.width:b.panelWidth:a.$panels.eq(0).width();a.$left=a.$wrap.find(".mb-left").click(function(){a.goBack();return!1});a.$right=a.$wrap.find(".mb-right").click(function(){a.goForward(); return!1});a.update(!1);c(window).load(function(){a.update(!1)});a.$el.delegate(".mb-panel","click",function(d){c(this).hasClass(b.currentPanel)||(d.preventDefault(),a.change(a.$panels.index(c(this))+a.adj))});a.$wrap.click(function(){a.active()});a.$panels.delegate("a","focus",function(){a.$panels.index(c(this).closest(".mb-panel"))+a.adj!==a.curPanel&&a.change(a.$panels.index(c(this).closest(".mb-panel"))+a.adj,{},!1)});c(document).keyup(function(b){if(!b.target.tagName.match("TEXTAREA|INPUT|SELECT"))switch(b.which){case 39:case 32:a.$wrap.is(".mb-active-slider")&& a.goForward();break;case 37:a.$wrap.is(".mb-active-slider")&&a.goBack()}});c.each("initialized initChange beforeAnimation completed".split(" "),function(d,e){c.isFunction(b[e])&&a.$el.bind(e+".movingBoxes",b[e])});a.curPanel=b.hashTags?a.getHash()||b.startPanel:b.startPanel;setTimeout(function(){a.change(a.curPanel,function(){a.initialized=!0;a.$el.trigger("initialized.movingBoxes",[a,a.curPanel])},!1)},2*b.speed)};a.update=function(d,e){a.$el.children(".cloned").remove();a.$panels=a.$el.children(); a.adj=b.wrap&&1<a.$panels.length?0:1;a.width=b.width?parseInt(b.width,10):a.width;a.$wrap.css("width",a.width);b.wrap&&1<a.$panels.length&&(a.$el.prepend(a.$panels.filter(":last").clone().addClass("cloned")),a.$el.append(a.$panels.filter(":first").clone().addClass("cloned")),a.$el.find(".cloned").each(function(){c(this).find("a,input,textarea,select,button,area").removeAttr("name").attr("disabled","disabled");c(this).find("[id]").andSelf().removeAttr("id")}));a.$panels=a.$el.children().addClass("mb-panel").css("margin", 0).each(function(){0===c(this).find(".mb-inside").length&&c(this).wrapInner('<div class="mb-inside" />')});a.totalPanels=a.$panels.filter(":not(.cloned)").length;a.curWidth=b.panelWidth?2>=b.panelWidth?b.panelWidth*a.width:b.panelWidth:a.pWidth;a.regWidth=a.curWidth*b.reducedSize;a.$panels.css({width:a.curWidth,fontSize:"1em"});a.$panels.eq(a.curPanel-a.adj).addClass(b.currentPanel);a.heights=a.$panels.map(function(a,b){return c(b).outerHeight(!0)}).get();a.returnToNormal(a.curPanel,0);a.growBigger(a.curPanel, 0,d);a.updateArrows(a.curPanel);a.$el.css({position:"absolute",width:(a.curWidth+100)*a.$panels.length+(a.width-a.curWidth)/2,height:Math.max.apply(this,a.heights)+10});a.$window.css({height:b.fixedHeight?Math.max.apply(this,a.heights):a.heights[a.curPanel-a.adj]});a.$panels.eq(0).css({"margin-left":(a.width-a.curWidth)/2});a.buildNav();a.change(a.curPanel,e,!1===d?!1:!0)};a.buildNav=function(){a.$nav&&a.$nav.remove();if(b.buildNav&&1<a.totalPanels){a.$nav=c('<div class="mb-controls"><a class="mb-testing"></a></div>').appendTo(a.$wrap); var d,e="",g=c.isFunction(b.navFormatter),f=0>parseInt(a.$nav.find(".mb-testing").css("text-indent"),10);a.$panels.filter(":not(.cloned)").each(function(a){d=a+1;e+='<a href="#" class="mb-panel'+d;g?(a=b.navFormatter(d,c(this)),e+=f?" "+b.tooltipClass+'" title="'+a:"",e+='">'+a+"</a> "):e+='">'+d+"</a> "});a.$nav.html(e).find("a").bind("click",function(){a.change(c(this).index()+1);return!1})}};a.returnToNormal=function(d,e){var c=a.$panels.not(":eq("+(d-a.adj)+")").removeClass(b.currentPanel);1=== b.reducedSize?c.css({width:a.regWidth}):c.animate({width:a.regWidth,fontSize:b.reducedSize+"em"},0===e?0:b.speed)};a.growBigger=function(d,c,g){var f=a.$panels.eq(d-a.adj);1===b.reducedSize?(f.css({width:a.curWidth}),a.completed(d,g)):f.animate({width:a.curWidth,fontSize:"1em"},0===c?0:b.speed,function(){a.completed(d,g)})};a.completed=function(d,c){a.$panels.eq(d-a.adj).addClass(b.currentPanel);!1!==c&&a.$el.trigger("completed.movingBoxes",[a,d])};a.goForward=function(){a.initialized&&a.change(a.curPanel+ 1)};a.goBack=function(){a.initialized&&a.change(a.curPanel-1)};a.change=function(d,c,g){if(1>a.totalPanels)"function"===typeof c&&c(a);else{var f,h=!1,g=!1!==g,d=parseInt(d,10);a.initialized&&g&&(a.active(),a.$el.trigger("initChange.movingBoxes",[a,d]));if(b.wrap)if(d>a.totalPanels)h=!0,d=1,a.returnToNormal(0,0),a.growBigger(0,0,!1),f=a.$panels.eq(0).position().left-(a.width-a.curWidth)/2,a.$window.scrollLeft(f);else if(0===d)h=!1,d=a.totalPanels,a.growBigger(d+1,0,!1),f=a.$panels.eq(d+1).position().left- (a.width-a.curWidth)/2,a.$window.scrollLeft(f);d<a.adj&&(d=b.wrap?a.totalPanels:1);d>a.totalPanels-a.adj&&(d=b.wrap?1:a.totalPanels);if(!a.currentlyMoving||!a.initialized){a.currentlyMoving=!0;a.$curPanel=a.$panels.eq(d-a.adj);f=a.$curPanel.position().left-(a.width-a.curWidth)/2;if(d>a.curPanel||h)f-=a.curWidth-a.regWidth;f=b.fixedHeight?{scrollLeft:f}:{scrollLeft:f,height:a.heights[d-a.adj]};a.curPanel=d;a.initialized&&g&&a.$el.trigger("beforeAnimation.movingBoxes",[a,d]);a.$window.animate(f,{queue:!1, duration:b.speed,easing:b.easing,complete:function(){a.initialized&&a.$window.scrollTop(0);a.currentlyMoving=!1;"function"===typeof c&&c(a)}});a.returnToNormal(d);a.growBigger(d,1,g);a.updateArrows(d);b.hashTags&&a.initialized&&a.setHash(d)}b.buildNav&&a.$nav.length&&a.$nav.find("a").removeClass(b.currentPanel).eq(d-1).addClass(b.currentPanel)}};a.updateArrows=function(d){a.$left.toggleClass(b.disabled,!b.wrap&&d===a.adj);a.$right.toggleClass(b.disabled,!b.wrap&&(d===a.totalPanels||0===a.totalPanels))}; a.getHash=function(){var b=window.location.hash.match(a.regex);return null===b?"":parseInt(b[1],10)};a.setHash=function(b){var c="slider"+a.runTime+"=",g=window.location.hash;if("undefined"!==typeof g)window.location.hash=0<g.indexOf(c)?g.replace(a.regex,c+b):g+"&"+c+b};a.active=function(){c(".mb-active-slider").removeClass("mb-active-slider");a.$wrap.addClass("mb-active-slider")};a.currentPanel=function(b,c){"undefined"!==typeof b&&a.change(b,c);return a.curPanel};a.init()};c.movingBoxes.defaultOptions= {startPanel:1,reducedSize:0.8,fixedHeight:!1,speed:500,initAnimation:!0,hashTags:!0,wrap:!1,buildNav:!1,navFormatter:null,easing:"swing",currentPanel:"current",tooltipClass:"tooltip",disabled:"disabled",initialized:null,initChange:null,beforeAnimation:null,completed:null};c.fn.movingBoxes=function(h,i){var b,a;return this.each(function(){a=c(this).data("movingBoxes");(typeof h).match("object|undefined")?a?a.update():new c.movingBoxes(this,h):/\d/.test(h)&&!isNaN(h)&&a&&(b="number"===typeof h?h:parseInt(c.trim(h), 10),1<=b&&b<=a.totalPanels&&a.change(b,i))})};c.fn.getMovingBoxes=function(){return this.data("movingBoxes")}})(jQuery);

