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

(function(d){d.movingBoxes=function(f,i){var c,a=this;a.$el=d(f).addClass("mb-slider");a.el=f;a.$el.data("movingBoxes",a);a.init=function(){a.options=c=d.extend({},d.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().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=false;a.currentlyMoving=false;a.curPanel=1;a.$left=a.$wrap.find(".mb-left").click(function(){a.goBack();return false});a.$right=a.$wrap.find(".mb-right").click(function(){a.goForward();return false});a.update();d(window).load(function(){a.update(false)});a.$el.delegate(".mb-panel","click",function(){a.change(a.$panels.index(d(this))+a.adj)});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,{},false)});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 initChange beforeAnimation completed".split(" "), function(b,e){d.isFunction(c[e])&&a.$el.bind(e+".movingBoxes",c[e])});setTimeout(function(){a.change(b,function(){a.initialized=true;a.$el.trigger("initialized.movingBoxes",[a,b])})},c.speed*2)};a.update=function(b){var h;a.$el.children(".cloned").remove();a.$panels=a.$el.children();a.adj=c.wrap&&a.$panels.length>1?0:1;c.wrap&&a.$panels.length>1&&(a.$el.prepend(a.$panels.filter(":last").clone().removeAttr("id").addClass("cloned")),a.$el.append(a.$panels.filter(":first").clone().removeAttr("id").addClass("cloned")), a.$el.find(".cloned").each(function(){d(this).find("a,input,textarea,select,button,area").attr("disabled","disabled");d(this).find("[id]").removeAttr("id")}));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;a.totalPanels-=c.wrap&&a.totalPanels>1?2:0;h=a.$panels.eq(a.curPanel-a.adj);a.curWidth=a.curWidth||h.outerWidth();a.regWidth= a.curWidth*c.reducedSize;a.$panels.css({width:a.curWidth,fontSize:"1em"});a.$panels.eq(a.curPanel-a.adj).addClass(c.currentPanel);a.heights=a.$panels.map(function(a,b){return d(b).outerHeight(true)}).get();a.returnToNormal(a.curPanel,0);a.growBigger(a.curPanel,0,b);a.updateArrows(a.curPanel);a.$el.css({position:"absolute",width:(a.curWidth+100)*a.$panels.length+(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- a.adj]});a.$panels.eq(0).css({"margin-left":(c.width-a.curWidth)/2});a.buildNav();a.change(a.curPanel,null,true)};a.buildNav=function(){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,h="",e=d.isFunction(c.navFormatter),g=parseInt(a.$nav.find(".mb-testing").css("text-indent"),10)<0;a.$panels.filter(":not(.cloned)").each(function(a){b=a+1;h+='<a href="#" class="mb-panel'+b;e?(a=c.navFormatter(b,d(this)), h+=g?" "+c.tooltipClass+'" title="'+a:"",h+='">'+a+"</a> "):h+='">'+b+"</a> "});a.$nav.html(h).find("a").bind("click",function(){a.change(d(this).index()+1);return false})}};a.returnToNormal=function(b,d){var e=a.$panels.not(":eq("+(b-a.adj)+")").removeClass(c.currentPanel);c.reducedSize===1?e.css({width:a.regWidth}):e.animate({width:a.regWidth,fontSize:c.reducedSize+"em"},d===0?0:c.speed)};a.growBigger=function(b,d,e){var g=a.$panels.eq(b-a.adj);c.reducedSize===1?(g.css({width:a.curWidth}),a.initialized&& a.completed(b,e)):g.animate({width:a.curWidth,fontSize:"1em"},d===0?0:c.speed,function(){a.initialized&&a.completed(b,e)})};a.completed=function(b,d){a.$panels.eq(b-a.adj).addClass(c.currentPanel);d!==false&&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,e){if(a.totalPanels<1)typeof d==="function"&&d(a);else{var g,f=false,b=parseInt(b,10);a.initialized&&(a.active(), a.$el.trigger("initChange.movingBoxes",[a,b]));if(c.wrap)if(b>a.totalPanels)f=true,b=1,a.returnToNormal(0,0),a.growBigger(0,0,false),g=a.$panels.eq(0).position().left-(c.width-a.curWidth)/2,a.$window.scrollLeft(g);else if(b===0)f=false,b=a.totalPanels,a.growBigger(b+1,0,false),g=a.$panels.eq(b+1).position().left-(c.width-a.curWidth)/2,a.$window.scrollLeft(g);b<a.adj&&(b=c.wrap?a.totalPanels:1);b>a.totalPanels-a.adj&&(b=c.wrap?1:a.totalPanels);if(a.initialized&&a.curPanel===b&&!e)return false;if(!a.currentlyMoving|| !a.initialized){a.currentlyMoving=true;g=a.$panels.eq(b-a.adj).position().left-(c.width-a.curWidth)/2;if(b>a.curPanel||f)g-=a.curWidth-a.regWidth;e=c.fixedHeight?{scrollLeft:g}:{scrollLeft:g,height:a.heights[b-a.adj]};a.initialized&&a.$el.trigger("beforeAnimation.movingBoxes",[a,b]);a.$window.animate(e,{queue:false,duration:c.speed,easing:c.easing,complete:function(){a.curPanel=b;a.initialized&&a.$window.scrollTop(0);a.currentlyMoving=false;typeof d==="function"&&d(a)}});a.returnToNormal(b);a.growBigger(b); c.wrap||a.updateArrows(b);c.hashTags&&a.initialized&&a.setHash(b)}c.buildNav&&a.$nav&&a.$nav.find("a").removeClass(c.currentPanel).eq(b-1).addClass(c.currentPanel)}};a.updateArrows=function(b){a.$left.toggleClass(c.disabled,b===a.adj);a.$right.toggleClass(c.disabled,b===a.totalPanels||a.totalPanels===0)};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:false,speed:500,hashTags:true,wrap:false,buildNav:false,navFormatter:null,easing:"swing",currentPanel:"current",tooltipClass:"tooltip",disabled:"disabled", initialized:null,initChange:null,beforeAnimation:null,completed:null};d.fn.movingBoxes=function(f,i){var c,a;return this.each(function(){a=d(this).data("movingBoxes");(typeof f).match("object|undefined")?a?a.update():new d.movingBoxes(this,f):/\d/.test(f)&&!isNaN(f)&&a&&(c=typeof f==="number"?f:parseInt(d.trim(f),10),c>=1&&c<=a.totalPanels&&a.change(c,i))})};d.fn.getMovingBoxes=function(){return this.data("movingBoxes")}})(jQuery);

