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

(function(d){d.movingBoxes=function(e,h){var c,a=this;a.$el=d(e).addClass("mb-slider");a.el=e;a.$el.data("movingBoxes",a);a.init=function(){a.options=c=d.extend({},d.movingBoxes.defaultOptions,h);a.$el.wrap('<div class="movingBoxes mb-wrapper"><div class="mb-scroll" /></div>');a.$window=a.$el.parent();a.$wrap=a.$window.parent().css({width:c.width}).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=d(".mb-slider").index(a.$el)+1;a.regex=RegExp("slider"+a.runTime+"=(\\d+)","i");a.initialized=!1;a.currentlyMoving=!1;a.curPanel=1;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();d(window).load(function(){a.update(!1)});a.$el.delegate(".mb-panel","click",function(){a.change(a.$panels.index(d(this))+1)});a.$wrap.click(function(){a.active()}); a.$panels.delegate("a","focus",function(){a.$panels.index(d(this).closest(".mb-panel"))+1!==a.curPanel&&a.change(a.$panels.index(d(this).closest(".mb-panel"))+1,{},!1)});d(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()}});var b=c.hashTags?a.getHash()||c.startPanel:c.startPanel;d.each("initialized.movingBoxes initChange.movingBoxes beforeAnimation.movingBoxes completed.movingBoxes".split(" "), function(b,f){var e=f.split(".")[0];d.isFunction(c[e])&&a.$el.bind(f,c[e])});setTimeout(function(){a.change(b,function(){a.initialized=!0;a.$el.trigger("initialized.movingBoxes",[a,b])})},c.speed*2)};a.update=function(b){var g;a.$panels=a.$el.children().addClass("mb-panel").css({width:c.width*c.panelWidth,margin:0}).each(function(){d(this).find(".mb-inside").length===0&&d(this).wrapInner('<div class="mb-inside" />')});a.totalPanels=a.$panels.length;g=a.$panels.eq(a.curPanel-1);a.curWidth=a.curWidth|| g.outerWidth();a.regWidth=a.curWidth*c.reducedSize;a.$panels.css({width:a.curWidth,fontSize:"1em"});a.$panels.eq(a.curPanel-1).addClass(c.currentPanel);a.heights=a.$panels.map(function(a,b){return d(b).outerHeight(!0)}).get();a.returnToNormal(a.curPanel,0);a.growBigger(a.curPanel,0,b);c.wrap||a.updateArrows(a.curPanel);a.$el.css({position:"absolute",width:(a.curWidth+100)*a.totalPanels+(c.width-a.curWidth)/2,height:Math.max.apply(this,a.heights)+10});a.$window.css({height:c.fixedHeight?Math.max.apply(this, a.heights):a.heights[a.curPanel-1]});a.$panels.eq(0).css({"margin-left":(c.width-a.curWidth)/2});a.buildNav();a.change(a.curPanel,{},!1)};a.buildNav=function(){a.$navLinks={};a.$nav&&a.$nav.remove();if(c.buildNav&&a.totalPanels>1){a.$nav=d('<div class="mb-controls"><a class="mb-testing"></a></div>').appendTo(a.$wrap);var b,g="",f=d.isFunction(c.navFormatter),e=parseInt(a.$nav.find(".mb-testing").css("text-indent"),10)<0;a.$panels.each(function(a){b=a+1;g+='<a href="#" class="mb-panel'+b;f?(a=c.navFormatter(b, d(this)),g+=e?" "+c.tooltipClass+'" title="'+a:"",g+='">'+a+"</a> "):g+='">'+b+"</a> "});a.$navLinks=a.$nav.html(g).find("a").bind("click",function(){a.change(a.$navLinks.index(d(this))+1);return!1})}};a.returnToNormal=function(b,d){var f=a.$panels.not(":eq("+(b-1)+")").removeClass(c.currentPanel);c.reducedSize===1?f.css({width:a.regWidth}):f.animate({width:a.regWidth,fontSize:c.reducedSize+"em"},d===0?d:c.speed)};a.growBigger=function(b,d,f){var e=a.$panels.eq(b-1);c.reducedSize===1?(e.css({width:a.curWidth}), a.initialized&&a.completed(b,f)):e.animate({width:a.curWidth,fontSize:"1em"},d===0?d:c.speed,function(){a.initialized&&a.completed(b,f)})};a.completed=function(b,d){a.$panels.eq(b-1).addClass(c.currentPanel);d!==!1&&a.$el.trigger("completed.movingBoxes",[a,b])};a.goForward=function(){a.initialized&&a.change(a.curPanel+1)};a.goBack=function(){a.initialized&&a.change(a.curPanel-1)};a.change=function(b,d,f){b=parseInt(b,10);a.initialized&&(a.active(),a.$el.trigger("initChange.movingBoxes",[a,b]));if(c.wrap){if(b< 1)b=a.totalPanels;b>a.totalPanels&&(b=1)}else if(b<1&&(b=1),b>a.totalPanels)b=a.totalPanels;if(a.initialized&&a.curPanel===b&&!f)return!1;if(!a.currentlyMoving||!a.initialized)a.currentlyMoving=!0,f=a.$panels.eq(b-1).position().left-(c.width-a.curWidth)/2,b>a.curPanel&&(f-=a.curWidth-a.regWidth),f=c.fixedHeight?{scrollLeft:f}:{scrollLeft:f,height:a.heights[b-1]},a.initialized&&a.$el.trigger("beforeAnimation.movingBoxes",[a,b]),a.$window.animate(f,{queue:!1,duration:c.speed,easing:c.easing,complete:function(){a.curPanel= b;a.initialized&&a.$window.scrollTop(0);a.currentlyMoving=!1;typeof d==="function"&&d(a)}}),a.returnToNormal(b),a.growBigger(b),c.wrap||a.updateArrows(b),c.hashTags&&a.initialized&&a.setHash(b);a.$wrap.find(".mb-controls a").removeClass(c.currentPanel).eq(b-1).addClass(c.currentPanel)};a.updateArrows=function(b){a.$left.toggleClass(c.disabled,b===1);a.$right.toggleClass(c.disabled,b===a.totalPanels)};a.getHash=function(){var b=window.location.hash.match(a.regex);return b===null?"":parseInt(b[1],10)}; a.setHash=function(b){var c="slider"+a.runTime+"=",d=window.location.hash;if(typeof d!=="undefined")window.location.hash=d.indexOf(c)>0?d.replace(a.regex,c+b):d+"&"+c+b};a.active=function(){d(".mb-active-slider").removeClass("mb-active-slider");a.$wrap.addClass("mb-active-slider")};a.currentPanel=function(b,c){typeof b!=="undefined"&&a.change(b,c);return a.curPanel};a.init()};d.movingBoxes.defaultOptions={startPanel:1,width:800,panelWidth:0.5,reducedSize:0.8,fixedHeight:!1,speed:500,hashTags:!0,wrap:!1, buildNav:!1,navFormatter:null,easing:"swing",currentPanel:"current",tooltipClass:"tooltip",disabled:"disabled",initialized:null,initChange:null,beforeAnimation:null,completed:null};d.fn.movingBoxes=function(e,h){var c,a=this.data("movingBoxes");return this.each(function(){(typeof e).match("object|undefined")?a?a.update():new d.movingBoxes(this,e):/\d/.test(e)&&!isNaN(e)&&a&&(c=typeof e==="number"?e:parseInt(d.trim(e),10),c>=1&&c<=a.totalPanels&&a.change(c,h))})};d.fn.getMovingBoxes=function(){return this.data("movingBoxes")}})(jQuery);

