nhn.StaticBanner=$Class({obj:null,bEnable:true,initTop:0,offsetTop:0,maxTop:0,moveTo:0,currTop:0,innerHeight:-1,$init:function(A,B){var E=document.body||document.documentElement;this.obj=$Element(A);this.option({animate:true,limitArea:null,track:"none",margin:0,padding:0,speed:1});this.option(B);if(!/^(none|top|bottom)$/.test(this._options.track)){this._options.track="none"}this._options.speed=Math.min(Math.max(this._options.speed,1),5);var D=this._options.padding;if(typeof D=="number"){this._options.padding=new Array(D,D)}this.initTop=parseInt(this.obj.css("top"));this.offsetTop=this.obj.offset().top;if(this._options.limitArea){var C=$Element(this._options.limitArea);this.maxTop=C.offset().top+C.height()}else{this.maxTop=E.scrollHeight}this.maxTop-=$Element(this.obj.$value().offsetParent).offset().top+this.obj.height();$Fn(this.onwindowscroll,this).attach(window,"scroll");$Fn(this.onwindowload,this).attach(window,"load");$Fn(this.onwindowresize,this).attach(window,"resize");this._animate_method=$Fn(this._animate,this).bind()},enable:function(A){if(typeof A=="undefined"){return this.bEnable}this.bEnable=!!A},onwindowscroll:function(B){if(!this.bEnable){return }var A=Math.max(document.body.scrollTop,document.documentElement.scrollTop);switch(this._options.track){case"top":this.moveTo=A+this.initTop-this.offsetTop+this._options.margin;break;case"bottom":this.moveTo=A+this.initTop-this.offsetTop+this.innerHeight-this.obj.height()-this._options.margin;break;default:this.moveTo=this.initTop+A;break}this.moveTo=Math.min(Math.max(this.moveTo,this.initTop+this._options.padding[0]),this.maxTop-this._options.padding[1]);if(this._options.animate){this.currTop=parseInt(this.obj.css("top"));this._animate()}else{this.obj.css("top",this.moveTo+"px")}},onwindowload:function(A){if(isNaN(this.initTop)){this.initTop=parseInt(this.obj.css("top"))}this.onwindowresize(A);if(this.moveTo!=this.currTop){this.currTop=this.moveTo;this.obj.css("top",this.moveTo+"px")}},onwindowresize:function(A){this.innerHeight=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;this.onwindowscroll(A)},_animate:function(){var C=(this.moveTo-this.currTop)/(100/this._options.speed);var A=(this.moveTo-this.currTop>0)?1:-1;var B=0.005;if(Math.abs(C)<B){C=B*A}this.currTop+=C;if((A==1&&this.currTop>this.moveTo)||(A==-1&&this.currTop<this.moveTo)){this.currTop=this.moveTo}this.obj.css("top",Math.floor(this.currTop)+"px");if(this.currTop!=this.moveTo){setTimeout(this._animate_method,20)}}}).extend(nhn.Component);