var ctBlockScrollerConfig={buttonHoldTimeout:0.3,buttonHoldScrollStep:2,buttonHoldScrollTimeout:0.01,mouseScrollingTimeout:0.6,scrollerJump:{horizontal:'5%',vertical:'5%'},navigationEffectAppear:{to:0.7,delay:0.3,duration:0.5},navigationEffectFade:{delay:0,duration:0.5},horizontal:{manualScroll:false,isPersistent:false,resizeScroller:true,element:null,back:null,forward:null},vertical:{manualScroll:false,isPersistent:false,resizeScroller:true,element:null,back:null,forward:null}};var CtBlockScroller_Navigation_Button=Class.create({element:null,timer:null,config:null,initialize:function(htmlElement,config){this.config=config;if(htmlElement){this.element=$(htmlElement);}else{this.element=new Element('div',{className:'ctBlockScroller-navigation-button'});this.element.setStyle({position:'absolute',zIndex:20,overflow:'hidden'});}
this.timer=null;Event.observe(this.element,'mouseover',this.mouseoverHandler.bindAsEventListener(this));Event.observe(this.element,'mouseout',this.mouseoutHandler.bindAsEventListener(this));Event.observe(this.element,'mousedown',this.mousedownHandler.bindAsEventListener(this));Event.observe(this.element,'click',Event.stop);},mousedownHandler:function(event){Event.stop(event);Event.observe(document,'mouseup',this.mouseupHandler.bindAsEventListener(this));this.timer=setTimeout(this.mousedownDelayed.bind(this),this.config.buttonHoldTimeout*1000);this.element.addClassName('CtBlockScroller-navigation-button-pressed');},mousedownDelayed:function(){this.timer=null;this.element.fire('CtBlockScroller_Navigation_Button:press');},mouseupHandler:function(event){if(this.timer){clearTimeout(this.timer);this.timer=null;this.element.fire('CtBlockScroller_Navigation_Button:click');}else{this.element.fire('CtBlockScroller_Navigation_Button:release');}
Event.stopObserving(document,'mouseup');this.element.removeClassName('ctBlockScroller-navigation-button-pressed');},mouseoverHandler:function(event){this.element.addClassName('ctBlockScroller-navigation-button-hovered');},mouseoutHandler:function(event){this.element.removeClassName('ctBlockScroller-navigation-button-hovered');},hide:function(){var effectConfig=Object.clone(this.config.navigationEffectFade);effectConfig.sync=true;return new Effect.Fade(this.element,effectConfig);},show:function(){var effectConfig=Object.clone(this.config.navigationEffectAppear);effectConfig.sync=true;return new Effect.Appear(this.element,effectConfig);}});var CtBlockScroller_Navigation_Scroller=Class.create({element:null,offsetMin:0,offsetMax:0,offsetLength:0,offsetJump:0,offsetCurrent:0,position:0,config:null,initialize:function(htmlElement,config){this.config=config;this.offsetMin=0;this.offsetMax=0;this.offsetCurrent=0;this.offsetLength=0;this.offsetJump=0;this.position=0;if(htmlElement){this.element=$(htmlElement);}
if(!this.element){this.element=new Element('div',{className:'ctBlockScroller-navigation-scroller'});}
this.element.setStyle({position:'absolute',zIndex:20});Event.observe(this.element,'mouseover',this.mouseoverHandler.bindAsEventListener(this));Event.observe(this.element,'mouseout',this.mouseoutHandler.bindAsEventListener(this));Event.observe(this.element,'mousedown',this.mousedownHandler.bindAsEventListener(this));Event.observe(this.element,'click',Event.stop);},mouseoverHandler:function(event){this.element.addClassName('ctBlockScroller-navigation-scroller-hovered');},mouseoutHandler:function(event){this.element.removeClassName('ctBlockScroller-navigation-scroller-hovered');},mousedownHandler:function(event){Event.stop(event);Event.observe(document,'mousemove',this.documentMousemoveHandler.bindAsEventListener(this));Event.observe(document,'mouseup',this.documentMouseupHandler.bindAsEventListener(this));this.element.addClassName('ctBlockScroller-navigation-scroller-pressed');this.element.fire('CtBlockScroller_Navigation_Scroller:moveStart',{position:this.position});},documentMouseupHandler:function(event){Event.stop(event);Event.stopObserving(document,'mousemove');Event.stopObserving(document,'mouseup');this.element.removeClassName('ctBlockScroller-navigation-scroller-pressed');this.element.fire('CtBlockScroller_Navigation_Scroller:moveFinish',{position:this.position});},documentMousemoveHandler:function(event){throw'CtBlockScroller_Navigation_Scroller:documentMousemoveHandler must be redefined';},preparePosition:function(newOffset){if(newOffset>this.offsetMax){newOffset=this.offsetMax;}
if(newOffset<this.offsetMin){newOffset=this.offsetMin;}
this.offsetCurrent=newOffset;this.position=(this.offsetCurrent-this.offsetMin)/this.offsetLength;},updatePosition:function(){throw'CtBlockScroller_Navigation_Scroller:updatePosition must be redefined';},moveBack:function(){this.scroll(-this.config.buttonHoldScrollStep);},moveForward:function(){this.scroll(this.config.buttonHoldScrollStep);},jumpBack:function(){this.jumpToOffset(this.offsetCurrent-this.offsetJump);},jumpForward:function(){this.jumpToOffset(this.offsetCurrent+this.offsetJump);},scroll:function(delta){if((delta<0&&this.offsetCurrent<=this.offsetMin)||(delta>0&&this.offsetCurrent>=this.offsetMax)){return;}
this.mouseStart+=delta;var newOffset=this.offsetCurrent+delta;this.moveToOffset(newOffset);},scrollTo:function(position){var newOffset=position*this.offsetLength+this.offsetMin;this.jumpToOffset(newOffset);},moveToOffset:function(newOffset){this.preparePosition(newOffset);this.updatePosition();this.element.fire('CtBlockScroller_Navigation_Scroller:move',{position:this.position});},jumpToOffset:function(newOffset){this.preparePosition(newOffset);this.updatePosition();this.element.fire('CtBlockScroller_Navigation_Scroller:jump',{position:this.position});}});var CtBlockScroller_Navigation_Scroller_Horizontal=Class.create(CtBlockScroller_Navigation_Scroller,{mousedownHandler:function($super,event){$super(event),this.mouseStart=Event.pointerX(event);},documentMousemoveHandler:function(event){Event.stop(event);this.scroll(Event.pointerX(event)-this.mouseStart);},updatePosition:function(){this.element.setStyle({left:Math.round(this.offsetCurrent)+'px'});}});var CtBlockScroller_Navigation_Scroller_Vertical=Class.create(CtBlockScroller_Navigation_Scroller,{mousedownHandler:function($super,event){$super(event),this.mouseStart=Event.pointerY(event);},documentMousemoveHandler:function(event){Event.stop(event);this.scroll(Event.pointerY(event)-this.mouseStart);},updatePosition:function(){this.element.setStyle({top:Math.round(this.offsetCurrent)+'px'});}});var CtBlockScroller_Navigation=Class.create({element:null,back:null,forward:null,scroller:null,isPersistent:false,periodicalExecuter:null,timer:null,isWheelScrolling:false,config:null,initialize:function(){var pos=Element.getStyle(this.element,'position');var style={zIndex:15};if(pos=='static'||!pos){style.position='absolute';}
this.element.setStyle(style);if(this.config&&this.config.back){this.back=new CtBlockScroller_Navigation_Button(this.config.back,this.config);}else if(this.config&&this.config.back===false){this.back=null;}else{this.back=new CtBlockScroller_Navigation_Button(this.element.down('div.ctBlockScroller-navigation-button-back'),this.config);}
if(this.back){this.back.element.addClassName('ctBlockScroller-navigation-button-back');if(!this.back.element.up(0)){this.element.appendChild(this.back.element);}
Event.observe(this.back.element,'CtBlockScroller_Navigation_Button:click',this.backClickHandler.bindAsEventListener(this));Event.observe(this.back.element,'CtBlockScroller_Navigation_Button:press',this.backPressHandler.bindAsEventListener(this));Event.observe(this.back.element,'CtBlockScroller_Navigation_Button:release',this.backReleaseHandler.bindAsEventListener(this));}
if(this.config&&this.config.forward){this.forward=new CtBlockScroller_Navigation_Button(this.config.forward,this.config);}else if(this.config&&this.config.forward===false){this.forward=null;}else{this.forward=new CtBlockScroller_Navigation_Button(this.element.down('div.ctBlockScroller-navigation-button-forward'),this.config);}
if(this.forward){this.forward.element.addClassName('ctBlockScroller-navigation-button-forward');if(!this.forward.element.up(0)){this.element.appendChild(this.forward.element);}
Event.observe(this.forward.element,'CtBlockScroller_Navigation_Button:click',this.forwardClickHandler.bindAsEventListener(this));Event.observe(this.forward.element,'CtBlockScroller_Navigation_Button:press',this.forwardPressHandler.bindAsEventListener(this));Event.observe(this.forward.element,'CtBlockScroller_Navigation_Button:release',this.forwardReleaseHandler.bindAsEventListener(this));}
if(!this.scroller.element.up(0)){this.element.appendChild(this.scroller.element);}
Event.observe(this.element,'click',this.clickHandler.bindAsEventListener(this));Event.observe(this.scroller.element,'CtBlockScroller_Navigation_Scroller:jump',this.scrollerJumpHandler.bindAsEventListener(this));Event.observe(this.scroller.element,'CtBlockScroller_Navigation_Scroller:move',this.scrollerMoveHandler.bindAsEventListener(this));Event.observe(this.scroller.element,'CtBlockScroller_Navigation_Scroller:moveStart',this.scrollerMoveStartHandler.bindAsEventListener(this));Event.observe(this.scroller.element,'CtBlockScroller_Navigation_Scroller:moveFinish',this.scrollerMoveFinishHandler.bindAsEventListener(this));this.periodicalExecuter=null;this.timer=null;this.isWheelScrolling=false;this.isWheelScrollingPossible=false;this.isPersistent=(this.config&&this.config.isPersistent)?this.config.isPersistent:false;this.updateStyles();},hide:function(){var effectConfig=Object.clone(this.config.navigationEffectFade);effectConfig.sync=true;return new Effect.Fade(this.element,effectConfig);},show:function(){var effectConfig=Object.clone(this.config.navigationEffectAppear);effectConfig.sync=true;return new Effect.Appear(this.element,effectConfig);},prepareMousewheelEvents:function(){if(!this.timer){this.timer=setTimeout(this.mousewheelDelay.bind(this),500);if(!this.isWheelScrolling){this.isWheelScrolling=true;this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});}}else if(this.isWheelScrolling){clearTimeout(this.timer);this.timer=setTimeout(this.mousewheelDelay.bind(this),500);}else{clearTimeout(this.timer);this.timer=null;}},mousewheelDelay:function(){this.timer=null;this.isWheelScrolling=false;},mousewheelMozillaHandler:function(event){Event.stop(event);this.prepareMousewheelEvents();if(event.detail>0){this.scroller.jumpForward();}else{this.scroller.jumpBack();}},mousewheelOtherHandler:function(event){Event.stop(event);this.prepareMousewheelEvents();if(event.wheelDelta<0){this.scroller.jumpForward();}else{this.scroller.jumpBack();}},clickHandler:function(event){throw'CtBlockScroller_Navigation:clickHandler must be redefined';},backClickHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});this.scroller.jumpBack();},backPressHandler:function(event){Event.stop(event);this.periodicalExecuter=new PeriodicalExecuter(this.scroller.moveBack.bind(this.scroller),this.config.buttonHoldScrollTimeout);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});},backReleaseHandler:function(event){Event.stop(event);if(this.periodicalExecuter){this.periodicalExecuter.stop();this.periodicalExecuter=null;this.element.fire('CtBlockScroller_Navigation:scrollFinish',{position:this.scroller.position});}},forwardClickHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});this.scroller.jumpForward();},forwardPressHandler:function(event){Event.stop(event);this.periodicalExecuter=new PeriodicalExecuter(this.scroller.moveForward.bind(this.scroller),this.config.buttonHoldScrollTimeout);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});},forwardReleaseHandler:function(event){Event.stop(event);if(this.periodicalExecuter){this.periodicalExecuter.stop();this.periodicalExecuter=null;this.element.fire('CtBlockScroller_Navigation:scrollFinish',{position:this.scroller.position});}},updateScroller:function(){throw'CtBlockScroller_Navigation:updateScroller must be redefined';},scrollerMoveStartHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});},scrollerMoveFinishHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scrollFinish',{position:this.scroller.position});},scrollerMoveHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scroll',{position:this.scroller.position});},scrollerJumpHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:jump',{position:this.scroller.position});},scrollTo:function(position){this.scroller.scrollTo(position);}});var CtBlockScroller_Navigation_Horizontal=Class.create(CtBlockScroller_Navigation,{initialize:function($super,config){this.config=config;if(this.config.element){this.element=$(this.config.element);}else{this.element=new Element('div',{className:'ctBlockScroller-navigation ctBlockScroller-navigation-horizontal'});}
if(this.config.scroller){this.scroller=new CtBlockScroller_Navigation_Scroller_Horizontal(this.config.scroller,this.config);}else{this.scroller=new CtBlockScroller_Navigation_Scroller_Horizontal(this.element.down('div.ctBlockScroller-navigation-scroller'),this.config);}
$super();},updateScroller:function(containerSize,wrapperSize){var backWidth=(this.back&&!this.config.back)?this.back.element.getWidth():0;var forwardWidth=(this.forward&&!this.config.forward)?this.forward.element.getWidth():0;var scrollerWidth=0;if(this.config&&this.config.resizeScroller){var scrollerWidthMax=this.scroller.element.up(0).getWidth()-backWidth-forwardWidth;var scrollerWidthMin=this.scroller.element.getWidth();scrollerWidth=Math.round(containerSize/wrapperSize*scrollerWidthMax);if(scrollerWidth<scrollerWidthMin){scrollerWidth=scrollerWidthMin;}}else{scrollerWidth=this.scroller.element.getWidth();}
this.scroller.offsetMin=backWidth;this.scroller.offsetMax=this.scroller.element.up(0).getWidth()-forwardWidth-scrollerWidth;this.scroller.offsetLength=this.scroller.offsetMax-this.scroller.offsetMin;this.scroller.offsetCurrent=this.scroller.offsetMin;var offsetJump=this.config.scrollerJump.horizontal;if(typeof(offsetJump)=='number'){this.scroller.offsetJump=this.scroller.offsetLength*offsetJump;}else if(offsetJump.search('px')!=-1){this.scroller.offsetJump=(offsetJump.replace('px','')*1)/(wrapperSize-containerSize)*this.scroller.offsetLength;}else if(offsetJump.search('%')!=-1){this.scroller.offsetJump=this.scroller.offsetLength*(offsetJump.replace('%','')*0.01);}
this.scroller.element.setStyle({width:scrollerWidth+'px',left:Math.round(this.scroller.offsetCurrent)+'px'});},clickHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});var elementWidth=this.element.getWidth();var backWidth=(this.back&&!this.config.back)?this.back.element.getWidth():0;var forwardWidth=(this.forward&&!this.config.forward)?this.forward.element.getWidth():0;var position=(Event.pointerX(event)-this.element.cumulativeOffsetFixed().left-backWidth)/(elementWidth-backWidth-forwardWidth);this.scroller.scrollTo(position);},updateStyles:function(){if(this.back&&!this.config.back){this.back.element.setStyle({bottom:0,left:0});}
if(this.forward&&!this.config.forward){this.forward.element.setStyle({bottom:0,right:0});}}});var CtBlockScroller_Navigation_Vertical=Class.create(CtBlockScroller_Navigation,{initialize:function($super,config){this.config=config;if(this.config.element){this.element=$(this.config.element);}else{this.element=new Element('div',{className:'ctBlockScroller-navigation ctBlockScroller-navigation-vertical'});}
if(this.config.scroller){this.scroller=new CtBlockScroller_Navigation_Scroller_Vertical(this.config.scroller,this.config);}else{this.scroller=new CtBlockScroller_Navigation_Scroller_Vertical(this.element.down('div.ctBlockScroller-navigation-scroller'),this.config);}
$super();},updateScroller:function(containerSize,wrapperSize){var backHeight=(this.back)?this.back.element.getHeight():0;var forwardHeight=(this.forward)?this.forward.element.getHeight():0;var scrollerHeight=0;if(this.config.resizeScroller){var scrollerHeightMax=this.scroller.element.up(0).getHeight()-backHeight-forwardHeight;var scrollerHeightMin=this.scroller.element.getHeight();scrollerHeight=Math.round(containerSize/wrapperSize*scrollerHeightMax);if(scrollerHeight<scrollerHeightMin){scrollerHeight=scrollerHeightMin;}}else{scrollerHeight=this.scroller.element.getHeight();}
this.scroller.offsetMin=backHeight;this.scroller.offsetMax=this.scroller.element.up(0).getHeight()-forwardHeight-scrollerHeight;this.scroller.offsetLength=this.scroller.offsetMax-this.scroller.offsetMin;this.scroller.offsetCurrent=this.scroller.offsetMin;var offsetJump=this.config.scrollerJump.vertical;if(typeof(offsetJump)=='number'){this.scroller.offsetJump=this.scroller.offsetLength*offsetJump;}else if(offsetJump.search('px')!=-1){this.scroller.offsetJump=(offsetJump.replace('px','')*1)/(wrapperSize-containerSize)*this.scroller.offsetLength;}else if(offsetJump.search('%')!=-1){this.scroller.offsetJump=this.scroller.offsetLength*(offsetJump.replace('%','')*0.01);}
this.scroller.element.setStyle({height:scrollerHeight+'px',top:Math.round(this.scroller.offsetCurrent)+'px'});},clickHandler:function(event){Event.stop(event);this.element.fire('CtBlockScroller_Navigation:scrollStart',{position:this.scroller.position});var elementHeight=this.element.getHeight();var backHeight=this.back?this.back.element.getHeight():0;var forwardHeight=this.forward?this.forward.element.getHeight():0;var position=(Event.pointerY(event)-this.element.cumulativeOffsetFixed().top-backHeight)/(elementHeight-backHeight-forwardHeight);this.scroller.scrollTo(position);},updateStyles:function(){if(this.back){this.back.element.setStyle({top:0,right:0});}
if(this.forward){this.forward.element.setStyle({bottom:0,right:0});}}});var CtBlockScroller_Element=Class.create({element:null,id:null,scrollType:null,wrapper:null,horizontal:null,vertical:null,timer:null,config:null,initialize:function(htmlElement,config){this.config=config;this.element=$(htmlElement);this.element.setStyle({position:'relative',overflow:'hidden'});this.id=this.element.identify();this.scrollType=null;this.wrapper=null;this.horizontal=null;this.vertical=null;this.timer=null;if(this.element.hasClassName('ctBlockScroller-horizontal')){this.scrollType='h';}else if(this.element.hasClassName('ctBlockScroller-vertical')){this.scrollType='v';}else{this.scrollType='b';}
this.wrapper=new Element('div',{className:'ctBlockScroller-wrapper'});var dimensions=this.element.getDimensions();this.element.width=dimensions.width;this.element.height=dimensions.height;var style={position:'relative'};if(this.scrollType=='h'){style.height=this.element.height+'px';}else if(this.scrollType=='v'){style.width=this.element.width+'px';}
this.wrapper.setStyle(style);var children=this.element.immediateDescendants();for(var i=0;i<children.length;i++){this.wrapper.appendChild(children[i]);}
this.element.appendChild(this.wrapper);this.updateWrapper();switch(this.scrollType){case'v':if(this.wrapper.height<=this.element.height){this.scrollType=null;}
break;case'h':if(this.wrapper.width<=this.element.width){this.scrollType=null;}
break;case'b':if(this.wrapper.height<=this.element.height&&this.wrapper.width<=this.element.width){this.scrollType=null;}else if(this.wrapper.height<=this.element.height){this.scrollType='h';}else if(this.wrapper.width<=this.element.width){this.scrollType='v';}
break;default:break;}
if((this.scrollType=='v'||!this.scrollType)&&this.config&&this.config.horizontal&&this.config.horizontal.element){var el=$(this.config.horizontal.element);if(el){el.addClassName('ctBlockScroller-navigation-disabled');}}
if((this.scrollType=='h'||!this.scrollType)&&this.config&&this.config.vertical&&this.config.vertical.element){var el=$(this.config.vertical.element);if(el){el.addClassName('ctBlockScroller-navigation-disabled');}}
if(!this.scrollType){return;}
this.createNavigation();Event.observe(this.element,'CtBlockScroller:scrollTo',this.scrollTo.bindAsEventListener(this));},scrollTo:function(event){var verticalPosition=this.vertical?this.vertical.scroller.position:0;var horizontalPosition=this.horizontal?this.horizontal.scroller.position:0;this.element.fire('CtBlockScroller:scrollStart',{position:{top:verticalPosition,left:horizontalPosition}});if(this.vertical){var offset=this.wrapper.height*event.memo.position.top+event.memo.correction.top;var position=(this.wrapper.height*event.memo.position.top+event.memo.correction.top)/this.wrapper.maxOffsetV;if(offset>this.wrapper.maxOffsetV){offset=this.wrapper.maxOffsetV;}else if(offset<0){offset=0;}
this.vertical.scrollTo(position);}
if(this.horizontal){var offset=this.wrapper.width*event.memo.position.left+event.memo.correction.left;if(offset>this.wrapper.maxOffsetH){offset=this.wrapper.maxOffsetH;}else if(offset<0){offset=0;}
var position=offset/this.wrapper.maxOffsetH;this.horizontal.scrollTo(position);}},scrollRetranslate:function(event){Event.stop(event);var verticalPosition=this.vertical?this.vertical.scroller.position:0;var horizontalPosition=this.horizontal?this.horizontal.scroller.position:0;var top=this.wrapper.maxOffsetV*verticalPosition;var left=this.wrapper.maxOffsetH*horizontalPosition;this.element.fire('CtBlockScroller:scroll',{position:{top:verticalPosition,left:horizontalPosition}});this.wrapper.setStyle({left:-Math.round(left)+'px',top:-Math.round(top)+'px'});},jumpRetranslate:function(event){Event.stop(event);Effect.Queues.get(this.id+'-smoothSlide').each(function(effect){effect.cancel();});var verticalPosition=this.vertical?this.vertical.scroller.position:0;var horizontalPosition=this.horizontal?this.horizontal.scroller.position:0;var top=this.wrapper.maxOffsetV*verticalPosition;var left=this.wrapper.maxOffsetH*horizontalPosition;new Effect.Move(this.wrapper,{x:-Math.round(left),y:-Math.round(top),duration:0.5,mode:'absolute',transition:Effect.Transitions.spring,afterFinish:function(){this.element.fire('CtBlockScroller:scroll',{position:{top:verticalPosition,left:horizontalPosition}});this.element.fire('CtBlockScroller:scrollFinish',{position:{top:verticalPosition,left:horizontalPosition}});}.bind(this),queue:{scope:this.id+'-smoothSlide',position:'end'}});},scrollStartRetranslate:function(event){Event.stop(event);var verticalPosition=this.vertical?this.vertical.scroller.position:0;var horizontalPosition=this.horizontal?this.horizontal.scroller.position:0;this.element.fire('CtBlockScroller:scrollStart',{position:{top:verticalPosition,left:horizontalPosition}});},scrollFinishRetranslate:function(event){Event.stop(event);var verticalPosition=this.vertical?this.vertical.scroller.position:0;var horizontalPosition=this.horizontal?this.horizontal.scroller.position:0;this.element.fire('CtBlockScroller:scrollFinish',{position:{top:verticalPosition,left:horizontalPosition}});},createNavigation:function(){var configSection=this.id.camelize();if(this.scrollType=='v'||this.scrollType=='b'){var verticalConfig=Object.extend(this.config,this.config.vertical?this.config.vertical:{});this.vertical=new CtBlockScroller_Navigation_Vertical(verticalConfig);if(!this.vertical.element.up(0)){this.element.appendChild(this.vertical.element);}
Event.observe(this.vertical.element,'CtBlockScroller_Navigation:scrollStart',this.scrollStartRetranslate.bindAsEventListener(this));Event.observe(this.vertical.element,'CtBlockScroller_Navigation:scrollFinish',this.scrollFinishRetranslate.bindAsEventListener(this));Event.observe(this.vertical.element,'CtBlockScroller_Navigation:scroll',this.scrollRetranslate.bindAsEventListener(this));Event.observe(this.vertical.element,'CtBlockScroller_Navigation:jump',this.jumpRetranslate.bindAsEventListener(this));}
if(this.scrollType=='h'||this.scrollType=='b'){var horizontalConfig=Object.extend(this.config,this.config.horizontal?this.config.horizontal:{});this.horizontal=new CtBlockScroller_Navigation_Horizontal(horizontalConfig);if(!this.horizontal.element.up(0)){this.element.appendChild(this.horizontal.element);}
Event.observe(this.horizontal.element,'CtBlockScroller_Navigation:scrollStart',this.scrollStartRetranslate.bindAsEventListener(this));Event.observe(this.horizontal.element,'CtBlockScroller_Navigation:scrollFinish',this.scrollFinishRetranslate.bindAsEventListener(this));Event.observe(this.horizontal.element,'CtBlockScroller_Navigation:scroll',this.scrollRetranslate.bindAsEventListener(this));Event.observe(this.horizontal.element,'CtBlockScroller_Navigation:jump',this.jumpRetranslate.bindAsEventListener(this));}
if(this.scrollType=='v'||this.scrollType=='b'){var height=this.vertical.element.getStyle('height');var matches=height.match(new RegExp('^([0-9]*).*'));if(matches[1]){height=matches[1]*1;}else{height=0;}
if(!height||(typeof(height)=='string'&&(height.replace('px','')*1)==0)){height=this.element.height;if(this.scrollType=='b'){height-=this.horizontal.element.getHeight();}
this.vertical.element.setStyle({height:height+'px'});}
this.vertical.updateScroller(this.element.getHeight(),this.wrapper.getHeight());}
if(this.scrollType=='h'||this.scrollType=='b'){var width=this.horizontal.element.getStyle('width');var matches=width.match(new RegExp('^([0-9]*).*'));if(matches[1]){width=matches[1]*1;}else{width=0;}
if(!width){width=this.element.width;if(this.scrollType=='b'){width-=this.vertical.element.getWidth();}
this.horizontal.element.setStyle({width:width+'px'});}
this.horizontal.updateScroller(this.element.getWidth(),this.wrapper.getWidth());}
if((this.scrollType=='v'||this.scrollType=='b')&&!this.vertical.isPersistent){this.vertical.element.setStyle({display:'none'});}
if((this.scrollType=='h'||this.scrollType=='b')&&!this.horizontal.isPersistent){this.horizontal.element.setStyle({display:'none'});}
Event.observe(this.element,'mouseover',this.mouseoverHandler.bindAsEventListener(this));Event.observe(this.element,'mouseout',this.mouseoutHandler.bindAsEventListener(this));},startMouseListening:function(){var startListening=false;if(this.vertical&&!this.config.vertical.manualScroll){Event.observe(this.element,'DOMMouseScroll',this.vertical.mousewheelMozillaHandler.bindAsEventListener(this.vertical));Event.observe(this.element,'mousewheel',this.vertical.mousewheelOtherHandler.bindAsEventListener(this.vertical));startListening=true;}else if(this.horizontal&&!this.config.horizontal.manualScroll){Event.observe(this.element,'DOMMouseScroll',this.horizontal.mousewheelMozillaHandler.bindAsEventListener(this.horizontal));Event.observe(this.element,'mousewheel',this.horizontal.mousewheelOtherHandler.bindAsEventListener(this.horizontal));startListening=true;}
if(startListening){Event.observe(document,'DOMMouseScroll',Event.stop);Event.observe(document,'mousewheel',Event.stop);}},stopMouseListening:function(){Event.stopObserving(document,'DOMMouseScroll');Event.stopObserving(document,'mousewheel');Event.stopObserving(this.element,'DOMMouseScroll');Event.stopObserving(this.element,'mousewheel');},mouseoverHandler:function(event){if(event.relatedTarget==null||event.relatedTarget==this.element||Element.descendantOf(event.relatedTarget,this.element)==true){return;}
Effect.Queues.get(this.id).each(function(effect){effect.cancel();});var effects=[];if((this.scrollType=='v'||this.scrollType=='b')&&!this.vertical.isPersistent&&!this.config.vertical.manualScroll){if(this.config.vertical.back&&this.config.vertical.forward){effects.push(this.vertical.back.show());effects.push(this.vertical.forward.show());}
effects.push(this.vertical.show());}
if((this.scrollType=='h'||this.scrollType=='b')&&!this.horizontal.isPersistent&&!this.config.horizontal.manualScroll){if(this.config.horizontal.back&&this.config.horizontal.forward){effects.push(this.horizontal.back.show());effects.push(this.horizontal.forward.show());}
effects.push(this.horizontal.show());}
if(effects.length>0){new Effect.Parallel(effects,{delay:this.config.navigationEffectAppear.delay,duration:this.config.navigationEffectAppear.duration,queue:{scope:this.id,position:'end',limit:1}});}
this.timer=setTimeout(this.startMouseListening.bind(this),this.config.mouseScrollingTimeout*1000);},mouseoutHandler:function(event){if(!event.relatedTarget||event.relatedTarget==this.element||Element.descendantOf(event.relatedTarget,this.element)==true){return;}
clearTimeout(this.timer);this.stopMouseListening();Effect.Queues.get(this.id).each(function(effect){effect.cancel();});var effects=[];if((this.scrollType=='v'||this.scrollType=='b')&&!this.vertical.isPersistent&&!this.vertical.manualScroll){if(this.config.vertical.back&&this.config.vertical.forward&&event.relatedTarget!=this.vertical.back.element&&!Element.descendantOf(event.relatedTarget,this.vertical.back.element)&&event.relatedTarget!=this.vertical.forward.element&&!Element.descendantOf(event.relatedTarget,this.vertical.forward.element)){effects.push(this.vertical.back.hide());effects.push(this.vertical.forward.hide());}
effects.push(this.vertical.hide());}
if((this.scrollType=='h'||this.scrollType=='b')&&!this.horizontal.isPersistent&&!this.horizontal.manualScroll){if(this.config.horizontal.back&&this.config.horizontal.forward&&event.relatedTarget!=this.horizontal.back.element&&!Element.descendantOf(event.relatedTarget,this.horizontal.back.element)&&event.relatedTarget!=this.horizontal.forward.element&&!Element.descendantOf(event.relatedTarget,this.horizontal.forward.element)){effects.push(this.horizontal.back.hide());effects.push(this.horizontal.forward.hide());}
effects.push(this.horizontal.hide());}
if(effects.length>0){new Effect.Parallel(effects,{delay:this.config.navigationEffectFade.delay,duration:this.config.navigationEffectFade.duration,queue:{scope:this.id,position:'end',limit:1}});}},updateWrapper:function(){var dimensions=this.wrapper.getDimensions();this.wrapper.width=dimensions.width;this.wrapper.height=dimensions.height;this.wrapper.maxOffsetV=this.wrapper.height-this.element.height;var firstDescendant=this.wrapper.firstDescendant();if(firstDescendant){var width=firstDescendant.getWidth();this.wrapper.width=width;this.wrapper.setStyle({width:width+'px'});this.wrapper.maxOffsetH=width-this.element.width;}else{this.wrapper.maxOffsetH=0;}}});var CtBlockScroller=Class.create({elements:[],initialize:function(){var elements=$$('.ctBlockScroller');for(var i=0;i<elements.length;i++){var id=elements[i].identify().camelize();var config=Object.clone(Object.extend(ctBlockScrollerConfig,(ctBlockScrollerConfig[id])?ctBlockScrollerConfig[id]:{}));var ctBlockScrollerElement=new CtBlockScroller_Element(elements[i],config);this[id]=ctBlockScrollerElement;this.elements.push(ctBlockScrollerElement);}}});CtPage.registerScript("CtBlockScroller");
