/*
 * Moving Boxes v2.0.1 min
 * by Chris Coyier 
 * http://css-tricks.com/moving-boxes/
 */
(function(c){c.movingBoxes=function(e,h){var a=this;a.$el=c(e).addClass("movingBoxes");a.el=e;a.$el.data("movingBoxes",a);a.init=function(){a.options=c.extend({},c.movingBoxes.defaultOptions,h);a.$el.css({width:a.options.width}).wrapInner('<div class="mb-scrollContainer" />').wrapInner('<div class="mb-scroll" />').prepend('<a class="mb-scrollButtons mb-left"></a>').append('<a class="mb-scrollButtons mb-right"></a>').find(".mb-scrollContainer "+a.options.panelType).addClass("mb-panel").wrapInner('<div class="mb-inside" />'); a.$container=a.$el.find(".mb-scrollContainer");a.$window=a.$el.find(".mb-scroll");a.runTime=c(".movingBoxes").index(a.$el)+1;a.regex=RegExp("slider"+a.runTime+"=(\\d+)","i");a.$navLinks={};a.$panels=a.$el.find(".mb-panel").css({width:a.options.width*a.options.panelWidth});a.totalPanels=a.$panels.length;a.curWidth=a.$panels.outerWidth();a.curImgWidth=a.$panels.find("img").outerWidth(!0);a.curImgHeight=a.curImgWidth/a.options.imageRatio;a.regWidth=a.curWidth*a.options.reducedSize;a.regImgWidth=a.curImgWidth* a.options.reducedSize;a.regImgHeight=a.curImgHeight*a.options.reducedSize;a.$panels.find("img").css({height:a.curImgHeight});a.heights=a.$panels.map(function(a,b){return c(b).outerHeight(!0)}).get();a.$container.css({position:"absolute",width:(a.curWidth+100)*a.totalPanels,height:Math.max.apply(this,a.heights)});a.$window.css({height:Math.max.apply(this,a.heights)});a.$panels.eq(0).css({"margin-left":(a.options.width-a.curWidth)/2});var b=a.options.hashTags?a.getHash()||a.options.startPanel:a.options.startPanel; a.initialized=!1;a.currentlyMoving=!1;a.curPanel=1;a.change(1);a.buildNav();a.$el.find(".mb-right").click(function(){a.goForward();return!1}).end().find(".mb-left").click(function(){a.goBack();return!1});a.$panels.click(function(){a.change(a.$panels.index(c(this))+1)});a.$el.click(function(){a.active()});a.$panels.find("a").focus(function(){a.$el.find(".mb-panel").index(c(this).closest(".mb-panel"))+1!==a.curPanel&&a.change(a.$el.find(".mb-panel").index(c(this).closest(".mb-panel"))+1,{},!1)});c(document).keyup(function(b){if(!b.target.tagName.match("TEXTAREA|INPUT|SELECT"))switch(b.which){case 39:case 32:a.$el.is(".mb-active-slider")&& a.goForward();break;case 37:a.$el.is(".mb-active-slider")&&a.goBack()}});setTimeout(function(){a.change(b,function(){c.each("initialized.movingBoxes initChange.movingBoxes beforeAnimation.movingBoxes completed.movingBoxes".split(" "),function(b,d){var e=d.split(".")[0];c.isFunction(a.options[e])&&a.$el.bind(d,a.options[e])});a.initialized=!0;a.$el.trigger("initialized.movingBoxes",[a,b])})},a.options.speed*2)};a.buildNav=function(){if(a.options.buildNav&&a.totalPanels>1){a.$nav=c('<div class="mb-controls"><a class="mb-testing"></a></div>').appendTo(a.$el); var b,f="",d=c.isFunction(a.options.navFormatter),e=parseInt(a.$nav.find(".mb-testing").css("text-indent"),10)<0;a.$panels.each(function(g){b=g+1;f+='<a href="#" class="mb-panel'+b;d?(g=a.options.navFormatter(b,c(this)),f+=e?" "+a.options.tooltipClass+'" title="'+g:"",f+='">'+g+"</a> "):f+='">'+b+"</a> "});a.$navLinks=a.$nav.html(f).find("a").bind("click",function(){a.change(a.$navLinks.index(c(this))+1);return!1})}};a.returnToNormal=function(b){a.$panels.not(":eq("+(b-1)+")").removeClass(a.options.currentPanel).animate({width:a.regWidth, fontSize:a.options.reducedSize+"em"},a.options.speed).find("img").animate({width:a.regImgWidth,height:a.regImgHeight},a.options.speed)};a.growBigger=function(b){a.$panels.eq(b-1).addClass(a.options.currentPanel).animate({width:a.curWidth,fontSize:"1em"},a.options.speed).find("img").animate({width:a.curImgWidth,height:a.curImgHeight},a.options.speed,function(){a.initialized&&a.$el.trigger("completed.movingBoxes",[a,b])})};a.goForward=function(){a.change(a.curPanel+1)};a.goBack=function(){a.change(a.curPanel- 1)};a.change=function(b,c,d){b=parseInt(b,10);a.initialized&&(a.active(),a.$el.trigger("initChange.movingBoxes",[a,b]));if(a.options.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&&!d)return!1;if(!a.currentlyMoving)a.currentlyMoving=!0,d=a.$panels.eq(b-1).position().left-(a.options.width-a.curWidth)/2,b>a.curPanel&&(d-=a.curWidth-a.regWidth),d=a.options.fixedHeight?{scrollLeft:d}:{scrollLeft:d,height:a.heights[b- 1]},a.initialized&&a.$el.trigger("beforeAnimation.movingBoxes",[a,b]),a.$window.animate(d,{queue:!1,duration:a.options.speed,easing:a.options.easing,complete:function(){a.curPanel=b;a.initialized&&(a.$panels.eq(b-1).find("a").focus(),a.$window.scrollTop(0));a.currentlyMoving=!1;typeof c==="function"&&c(a)}}),a.returnToNormal(b),a.growBigger(b),a.options.hashTags&&a.setHash(b);a.$el.find(".mb-controls a").removeClass(a.options.currentPanel).eq(b-1).addClass(a.options.currentPanel)};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(){c(".mb-active-slider").removeClass("mb-active-slider");a.$el.addClass("mb-active-slider")};a.currentPanel=function(b,c){typeof b!=="undefined"&&a.change(b,c);return a.curPanel};a.init()};c.movingBoxes.defaultOptions={startPanel:0,width:800, panelWidth:0.5,reducedSize:0.8,imageRatio:4/3,fixedHeight:!1,speed:500,hashTags:!0,wrap:!1,buildNav:!1,navFormatter:null,easing:"swing",currentPanel:"current",tooltipClass:"tooltip",panelType:"> div",initialized:null,initChange:null,beforeAnimation:null,completed:null};c.fn.movingBoxes=function(e){return this.each(function(){new c.movingBoxes(this,e)})};c.fn.getMovingBoxes=function(){return this.data("movingBoxes")}})(jQuery);

