/*
 * Moving Boxes v1.6.3 min
 * by Chris Coyier 
 * http://css-tricks.com/moving-boxes/
 */
(function(c){c.movingBoxes=function(f,h){var a=this;a.$el=c(f).addClass("movingBoxes");a.el=f;a.$el.data("movingBoxes",a);a.init=function(){a.options=c.extend({},c.movingBoxes.defaultOptions,h);a.$el.addClass("left-shadow").css({position:"relative",left:0,top:0,width:a.options.width}).wrapInner('<div class="scrollContainer" />').wrapInner('<div class="scroll right-shadow" />').prepend('<a class="scrollButtons left"></a>').append('<a class="scrollButtons right"></a>').find(".panel").wrapInner('<div class="inside" />').end().find(".scroll, .scrollContainer").css({position:"relative", overflow:"hidden",width:"100%"});a.$container=a.$el.find(".scrollContainer");a.$window=a.$el.find(".scroll");a.runTime=c(".movingBoxes").index(a.$el)+1;a.regex=RegExp("slider"+a.runTime+"=(\\d+)","i");a.$navLinks={};a.$panels=a.$el.find(".panel").css({width:a.options.width*a.options.panelWidth,"float":"left"});a.totalPanels=a.$panels.length;a.curWidth=a.$panels.outerWidth();a.curImgWidth=a.$panels.find("img").outerWidth(true);a.curImgHeight=a.curImgWidth/a.options.imageRatio;a.curTitleSize=parseInt(a.$panels.find(a.options.panelTitle).css("font-size"), 10);a.curParSize=parseInt(a.$panels.find(a.options.panelText).css("font-size"),10);a.regWidth=a.curWidth*a.options.reducedSize;a.regImgWidth=a.curImgWidth*a.options.reducedSize;a.regImgHeight=a.curImgHeight*a.options.reducedSize;a.regTitleSize=a.curTitleSize*a.options.reducedSize;a.regParSize=a.curParSize*a.options.reducedSize;a.$panels.find("img").css({height:a.curImgHeight});a.heights=a.$panels.map(function(d,e){return c(e).outerHeight(true)}).get();a.$container.css({position:"relative",width:(a.curWidth+ 50)*a.totalPanels,height:Math.max.apply(this,a.heights)});var b=a.options.hashTags?a.getHash()||a.options.startPanel:a.options.startPanel;a.initialized=false;a.currentlyMoving=false;a.curPanel=1;a.change(1);a.buildNav();setTimeout(function(){a.change(b);a.initialized=true},a.options.speed*2);a.$el.find(".right").click(function(){a.goForward();return false}).end().find(".left").click(function(){a.goBack();return false});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.change(a.$el.find(".panel").index(c(this).closest(".panel"))+1,false)});c(document).keyup(function(d){switch(d.which){case 39:case 32:a.$el.is(".active-slider")&&a.goForward();break;case 37:a.$el.is(".active-slider")&&a.goBack()}})};a.buildNav=function(){if(a.options.buildNav&&a.totalPanels>1){a.$nav=c('<div class="controls"><a class="testing"></a></div>').appendTo(a.$el);var b,d="",e=c.isFunction(a.options.navFormatter),i=parseInt(a.$nav.find(".testing").css("text-indent"), 10)<0;a.$panels.each(function(g){b=g+1;d+='<a href="#" class="'+a.options.tooltipClass+" panel"+b;if(e){g=a.options.navFormatter(b,c(this));d+=i?'" title="'+g:"";d+='">'+g+"</a> "}else d+='">'+b+"</a> "});a.$navLinks=a.$nav.html(d).find("a").bind("click",function(){a.change(a.$navLinks.index(c(this))+1);return false})}};a.returnToNormal=function(b){a.$panels.not(":eq("+(b-1)+")").removeClass("current").animate({width:a.regWidth},a.options.speed).find("img").animate({width:a.regImgWidth,height:a.regImgHeight}, a.options.speed).end().find(a.options.panelTitle).animate({fontSize:a.regTitleSize},a.options.speed).end().find(a.options.panelText).animate({fontSize:a.regParSize},a.options.speed)};a.growBigger=function(b){a.$panels.eq(b-1).addClass("current").animate({width:a.curWidth},a.options.speed).find("img").animate({width:a.curImgWidth,height:a.curImgHeight},a.options.speed).end().find(a.options.panelTitle).animate({fontSize:a.curTitleSize},a.options.speed).end().find(a.options.panelText).animate({fontSize:a.curParSize}, a.options.speed)};a.goForward=function(){a.change(a.curPanel+1)};a.goBack=function(){a.change(a.curPanel-1)};a.change=function(b,d){a.initialized&&a.active();b=parseInt(b,10);if(a.options.wrap){if(b<1)b=a.totalPanels;if(b>a.totalPanels)b=1}else{if(b<1)b=1;if(b>a.totalPanels)b=a.totalPanels}if(a.initialized&&a.curPanel==b&&!d)return false;if(!a.currentlyMoving){a.currentlyMoving=true;a.$window.scrollLeft(0);var e=(a.options.width-a.curWidth)/2-a.$panels.eq(b-1).position().left;if(b>a.curPanel)e+=a.curWidth- a.regWidth;a.$container.animate(a.options.fixedHeight?{left:e}:{left:e,height:a.heights[b-1]},{queue:false,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.scrollLeft(0);a.currentlyMoving=false}});a.$window.animate({scrollLeft:0},a.options.speed);a.returnToNormal(b);a.growBigger(b);a.options.hashTags&&a.setHash(b)}a.$el.find(".controls a").removeClass("current").eq(b-1).addClass("current")};a.getHash=function(){var b= window.location.hash.match(a.regex);return b===null?"":parseInt(b[1],10)};a.setHash=function(b){var d="slider"+a.runTime+"=",e=window.location.hash;if(typeof e!=="undefined")window.location.hash=e.indexOf(d)>0?e.replace(a.regex,d+b):e+"&"+d+b};a.active=function(){c(".active-slider").removeClass("active-slider");a.$el.addClass("active-slider")};a.currentPanel=function(b){typeof b!=="undefined"&&a.change(b);return a.curPanel};a.init()};c.movingBoxes.defaultOptions={startPanel:1,width:800,panelWidth:0.5, reducedSize:0.8,imageRatio:4/3,speed:500,fixedHeight:false,hashTags:true,wrap:false,buildNav:false,navFormatter:null,easing:"swing",tooltipClass:"tooltip",panelTitle:"h2",panelText:"p"};c.fn.movingBoxes=function(f){return this.each(function(){new c.movingBoxes(this,f)})};c.fn.getmovingBoxes=function(){this.data("movingBoxes")}})(jQuery);

