/*
 * Moving Boxes v1.5 packed
 * by Chris Coyier 
 * http://css-tricks.com/moving-boxes/
 */

(function($){$.movingBoxes=function(d,f){var g=this;g.$el=$(d).addClass('movingBoxes');g.el=d;g.$el.data('movingBoxes',g);g.init=function(){g.options=$.extend({},$.movingBoxes.defaultOptions,f);g.$el.addClass('left-shadow').css({position:'relative',left:0,top:0,width:'100%'}).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%'});g.$container=g.$el.find('.scrollContainer');g.$window=g.$el.find('.scroll');g.runTime=$('.movingBoxes').index(g.$el)+1;g.regex=new RegExp('slider'+g.runTime+'=(\\d+)','i');g.$panels=g.$el.find('.panel').css({width:g.options.width*g.options.panelWidth,float:'left'});g.totalPanels=g.$panels.length;g.curWidth=g.$panels.outerWidth();g.curImgWidth=g.$panels.find('img').outerWidth(true);g.curImgHeight=g.curImgWidth/g.options.imageRatio;g.curTitleSize=parseInt(g.$panels.find('h2').css('font-size'),10);g.curParSize=parseInt(g.$panels.find('p').css('font-size'),10);g.regWidth=g.curWidth*g.options.reducedSize;g.regImgWidth=g.curImgWidth*g.options.reducedSize;g.regImgHeight=g.curImgHeight*g.options.reducedSize;g.regTitleSize=g.curTitleSize*g.options.reducedSize;g.regParSize=g.curParSize*g.options.reducedSize;g.$panels.find('img').css({height:g.curImgHeight});g.heights=g.$panels.map(function(i,e){return $(e).outerHeight(true)}).get();g.$container.css({position:'relative',width:(g.curWidth+50)*g.totalPanels,height:g.heights[0]});var a=(g.options.hashTags)?g.getHash()||g.options.startPanel:g.options.startPanel;g.initialized=false;g.currentlyMoving=false;g.curPanel=1;g.change(1);setTimeout(function(){g.change(a)},g.options.speed*2);g.initialized=true;$(window).load(function(){g.$el.find('.scrollButtons').css({top:(g.$el.innerHeight()-g.$el.find('.scrollButtons').height())/2})});g.$el.find('.right').click(function(){g.goForward();return false}).end().find('.left').click(function(){g.goBack();return false});g.$panels.click(function(){g.change(g.$panels.index($(this))+1)});g.$el.click(function(){g.active($(this))}).find('a').focus(function(){var s=$(this).closest('.slider');g.active(s);g.change(s.find('.panel').index($(this).closest('.panel'))+1,false)});$(document).keyup(function(e){switch(e.which){case 39:case 32:if(g.$el.is('.active-slider')){g.goForward()}break;case 37:if(g.$el.is('.active-slider')){g.goBack()}break}})};g.returnToNormal=function(a){g.$panels.not(':eq('+(a-1)+')').animate({width:g.regWidth},g.options.speed).find('img').animate({width:g.regImgWidth,height:g.regImgHeight},g.options.speed).end().find('h2').animate({fontSize:g.regTitleSize},g.options.speed).end().find('p').animate({fontSize:g.regParSize},g.options.speed)};g.growBigger=function(a){g.$panels.eq(a-1).animate({width:g.curWidth},g.options.speed).find('img').animate({width:g.curImgWidth,height:g.curImgHeight},g.options.speed).end().find('h2').animate({fontSize:g.curTitleSize},g.options.speed).end().find('p').animate({fontSize:g.curParSize},g.options.speed)};g.goForward=function(){g.change(g.curPanel+1)};g.goBack=function(){g.change(g.curPanel-1)};g.change=function(a,b){if(g.initialized&&g.curPanel==a&&!b){return false}if(!g.currentlyMoving){g.currentlyMoving=true;g.$window.scrollLeft(0);if(g.options.wrap){if(a<1){a=g.totalPanels}if(a>g.totalPanels){a=1}}else{if(a<1){a=1}if(a>g.totalPanels){a=g.totalPanels}}var c=(g.options.width-g.curWidth)/2-g.$panels.eq(a-1).position().left;if(a>g.curPanel){c+=(g.curWidth-g.regWidth)}g.$container.animate({height:g.heights[a-1],left:c},{queue:false,duration:g.options.speed,complete:function(){g.curPanel=a;g.$panels.eq(a-1).find('a').focus();g.$window.scrollLeft(0);g.currentlyMoving=false}});g.$window.animate({scrollLeft:0},g.options.speed);g.returnToNormal(a);g.growBigger(a);if(g.options.hashTags){g.setHash(a)}}};g.getHash=function(){var n=window.location.hash.match(g.regex);return(n===null)?'':parseInt(n[1],10)};g.setHash=function(n){var s='slider'+g.runTime+"=",h=window.location.hash;if(typeof h!=='undefined'){window.location.hash=(h.indexOf(s)>0)?h.replace(g.regex,s+n):h+"&"+s+n}};g.active=function(a){$('.active-slider').removeClass('active-slider');a.addClass('active-slider')};g.currentPanel=function(a){if(typeof(a)!=='undefined'){g.change(parseInt(a,10))}return g.curPanel};g.init()};$.movingBoxes.defaultOptions={startPanel:1,width:800,panelWidth:0.9,reducedSize:1,imageRatio:4/3,speed:500,hashTags:true,wrap:false};$.fn.movingBoxes=function(a){return this.each(function(){(new $.movingBoxes(this,a))})};$.fn.getmovingBoxes=function(){this.data('movingBoxes')}})(jQuery);

