var Marquee=function(){var d=navigator.userAgent.indexOf("AppleWebKit/")>-1,i=!!window.attachEvent,c=function(a){return typeof a=="string"?document.getElementById(a):a},h=function(a,c){for(var b in c)if(a[b]===undefined)a[b]=c[b];return a},a={observe:function(b,a,c){if(window.addEventListener)b.addEventListener(a,c,false);else b.attachEvent("on"+a,c)},stopObserving:function(b,a,c){if(window.removeEventListener)b.removeEventListener(a,c,false);else window.detachEvent&&b.detachEvent("on"+a,c)},pointer:function(a){return{x:a.pageX||a.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft),y:a.pageY||a.clientY+(document.documentElement.scrollTop||document.body.scrollTop)}},preventDefault:function(a){if(a.preventDefault)a.preventDefault();else a.returnValue=false;return false}},g=function(e){e=c(e);var a=e,b=[0,0];do{b[0]+=a.offsetLeft||0;b[1]+=a.offsetTop||0;a=a.offsetParent}while(a);a=e;do if(d&&a.tagName!="BODY"||!d&&a.tagName!="HTML"){b[1]-=a.scrollTop||0;b[0]-=a.scrollLeft||0}while(a=a.parentNode);return b},f=function(b){var a=Array.prototype.slice.call(arguments,1),c=a.shift();return function(){return b.apply(c,a.concat(Array.prototype.slice.call(arguments,0)))}},b=function(b){var a=Array.prototype.slice.call(arguments,1),c=a.shift();return function(d){return b.apply(c,[d||window.event].concat(a))}},e=function(g,f){this.box=c(g);this.content=this.box.firstChild.nodeType==1?this.box.firstChild:this.box.childNodes[1];this.coefDirc=1;this.options=h(f||{},this.options);if(this.options.btSpeedUp)this.options.btSpeedUp=c(this.options.btSpeedUp);if(this.options.btSpeedDown)this.options.btSpeedDown=c(this.options.btSpeedDown);this._speed=this.options.speed;this.inverseDirc=this.options.dirc=="bottom"||this.options.dirc=="right";this.horizontalDirc=this.options.dirc=="bottom"||this.options.dirc=="top";this.box.style.overflow="hidden";this.box.style.position="relative";this.content.style.position="relative";var d=this.box["client"+(this.horizontalDirc?"Height":"Width")],e=this.content["offset"+(this.horizontalDirc?"Height":"Width")];this.maxDim=this.inverseDirc?-d:-e;this.startStep=this.inverseDirc?e:d;this.currentStep=0;if(this.options.btSpeedUp||this.options.btSpeedDown)this.eventsBt=this.options.eventBt=="over"?["mouseover","mouseout"]:["mousedown","mouseup"];if(this.options.btSpeedUp){this.handlerActiveBtUp=b(this.onActiveBt,this,this.inverseDirc);a.observe(this.options.btSpeedUp,this.eventsBt[0],this.handlerActiveBtUp)}if(this.options.btSpeedDown){this.handlerActiveBtDown=b(this.onActiveBt,this,!this.inverseDirc,true);a.observe(this.options.btSpeedDown,this.eventsBt[0],this.handlerActiveBtDown)}if(this.options.stopOnOver){this.handlerStopOnOver=b(this.onMouseOverContent,this);a.observe(this.box,"mouseover",this.handlerStopOnOver);this.handlerActiveOnOut=b(this.onMouseOutContent,this);a.observe(this.box,"mouseout",this.handlerActiveOnOut)}if(this.options.scrollOnMove){this.middleDim=d/2;this.timeOut=false;this.handlerActiveScroll=b(this.onActiveScroll,this);a.observe(this.box,"mouseover",this.handlerActiveScroll);this.handlerInactiveScroll=b(this.onInactiveScroll,this);a.observe(this.box,"mouseout",this.handlerInactiveScroll);this.handlerMouseMove=b(this.scrollOnMove,this);a.observe(this.box,"mousemove",this.handlerMouseMove)}if(this.options.draggable){if(this.options.cursorOverDrag){this.handlerActveCursor=b(this.setCursorOverDrag,this);a.observe(this.box,"mouseover",this.handlerActveCursor);this.handlerInactveCursor=b(this.setCursorOverDrag,this,true);a.observe(this.box,"mouseout",this.handlerInactveCursor)}this.handlerActiveDrag=b(this.onActiveDrag,this);a.observe(this.box,"mousedown",this.handlerActiveDrag)}this.setInterval();this.eventUnload=b(this.onUnload,this);a.observe(window,"unload",this.eventUnload)};e.prototype={options:{speed:.5,speedActiveBt:10,dirc:"top",eventBt:"over",stopOnOver:false,draggable:false,maxSpeedOnMove:10,expoSpeedOnMove:2},onInactiveBt:function(f,b){this.options.speed=this._speed;var c=this.options["cssActiveBtSpeed"+(b?"Down":"Up")];if(c){var d=this.options["btSpeed"+(b?"Down":"Up")],e=d.className;d.className=e.replace(" "+c,"")}this.toogleSelect(f,true);a.stopObserving(document,"mouseup",this["handlerInctiveBt"+(b?"Down":"Up")])},onActiveBt:function(g,f,c){this.options.speed=f?-this.options.speedActiveBt:this.options.speedActiveBt;var e=this.options["cssActiveBtSpeed"+(c?"Down":"Up")];if(e)this.options["btSpeed"+(c?"Down":"Up")].className+=" "+e;var d="handlerInctiveBt"+(c?"Down":"Up");this[d]=b(this.onInactiveBt,this,c);a.observe(document,this.eventsBt[1],this[d]);this.toogleSelect(g)},onMouseOverContent:function(){this.clearInterval()},onMouseOutContent:function(){!this.isOndrag&&this.setInterval()},onActiveScroll:function(){if(this.timeOut)clearTimeout(this.timeOut);else{var a=g(this.box);this.coor=this.options.dirc=="top"||this.options.dirc=="bottom"?a[1]:a[0]}},onInactiveScroll:function(){this.timeOut=setTimeout(f(function(){this.timeOut=null;this.options.speed=this._speed},this),0)},scrollOnMove:function(d){var e=this.horizontalDirc?a.pointer(d).y:a.pointer(d).x,c=(this.middleDim-(e-this.coor))/this.middleDim,b=Math.pow(c,this.options.expoSpeedOnMove)*this.options.maxSpeedOnMove;this.options.speed=(c>0?b:b>0?-b:b)*(this.inverseDirc?-1:1)},onActiveDrag:function(c){this.isOndrag=true;this.clearInterval();this.coor=this.horizontalDirc?a.pointer(c).y:a.pointer(c).x;this.handlerInactiveDrag=b(this.onInactiveDrag,this);a.observe(document,"mouseup",this.handlerInactiveDrag);this.handlerDragOnMove=b(this.dragOnMove,this);a.observe(document,"mousemove",this.handlerDragOnMove);if(this.options.cursorOnDrag)document.documentElement.style.cursor="url("+this.options.cursorOnDrag+"), auto";this.toogleSelect(c)},onInactiveDrag:function(b){this.isOndrag=false;var c=this.horizontalDirc?a.pointer(b).y:a.pointer(b).x;this.currentStep=this.inverseDirc?this.currentStep-(c-this.coor):this.currentStep+(c-this.coor);if(this.isOutDrag&&this.options.cursorOnDrag)document.documentElement.style.cursor="auto";else if(this.options.cursorOverDrag)document.documentElement.style.cursor="url("+this.options.cursorOverDrag+"), auto";a.stopObserving(document,"mouseup",this.handlerInactiveDrag);a.stopObserving(document,"mousemove",this.handlerDragOnMove);this.toogleSelect(b,true);this.setInterval()},dragOnMove:function(d){var b=this.horizontalDirc?a.pointer(d).y:a.pointer(d).x,c=this.inverseDirc?this.currentStep-(b-this.coor):this.currentStep+(b-this.coor);this.content.style[this.options.dirc]=c+"px";if(c>this.startStep){this.currentStep=this.maxDim;this.coor=b}else if(c<this.maxDim){this.currentStep=this.startStep;this.coor=b}},setCursorOverDrag:function(b,a){if(!this.isOndrag)document.documentElement.style.cursor=a?"auto":"url("+this.options.cursorOverDrag+"), auto";else this.isOutDrag=a},setSteep:function(){var a=this.options.speed;this.content.style[this.options.dirc]=this.currentStep-a+"px";this.currentStep-=a;if(this.currentStep>this.startStep)this.currentStep=this.maxDim;else if(this.currentStep<this.maxDim)this.currentStep=this.startStep},setInterval:function(){if(!this.interval)this.interval=setInterval(f(this.setSteep,this),35)},clearInterval:function(){if(this.interval){clearInterval(this.interval);this.interval=null}},toogleSelect:function(c,b){if(b){document.onselectstart=null;document.ondragstart=null}else{document.onselectstart=function(){return false};document.ondragstart=function(){return false};a.preventDefault(c)}},onUnload:function(){this.clearInterval();this.options.btSpeedUp&&a.stopObserving(this.options.btSpeedUp,this.eventsBt[0],this.handlerActiveBtUp);this.options.btSpeedDown&&a.stopObserving(this.options.btSpeedDown,this.eventsBt[0],this.handlerActiveBtDown);if(this.options.stopOnOver){a.stopObserving(this.box,"mouseover",this.handlerStopOnOver);a.stopObserving(this.box,"mouseout",this.handlerActiveOnOut)}if(this.options.scrollOnMove){a.stopObserving(this.box,"mouseover",this.handlerActiveScroll);a.stopObserving(this.box,"mouseout",this.handlerInactiveScroll);a.stopObserving(this.box,"mousemove",this.handlerMouseMove)}if(this.options.draggable){if(this.options.cursorOverDrag){a.stopObserving(this.box,"mouseover",this.handlerActveCursor);a.stopObserving(this.box,"mouseout",this.handlerInactveCursor)}a.stopObserving(this.box,"mousedown",this.handlerActiveDrag)}}};return e}()
