NG.Scroller=function(){};NG.Scroller.prototype.Enable=function(f,e,b){if(f.offsetHeight<f.scrollHeight){e.style.display="block";b.style.display="block"}this.scrolling=false;this.content=f;this.content.style.overflow="hidden";this.bar=e;this.nodule=b;b.scroller=this;e.scroller=this;if(NG.getElementsByClassName(e,"arrow-up").length>0){b.style.marginTop=NG.getElementsByClassName(e,"arrow-up")[0].offsetHeight+"px"}if(NG.getElementsByClassName(e,"arrow-down").length>0){b.style.marginBottom=NG.getElementsByClassName(e,"arrow-down")[0].offsetHeight+"px"}if(NG.getElementsByClassName(e,"arrow-left").length>0){b.style.marginLeft=NG.getElementsByClassName(e,"arrow-left")[0].offsetHeight+"px"}if(NG.getElementsByClassName(e,"arrow-right").length>0){b.style.marginRight=NG.getElementsByClassName(e,"arrow-right")[0].offsetHeight+"px"}f.scroller=this;if(document.NGDefaultScroller==null){document.NGDefaultScroller=this}var d=this;NG.addEventListener(f,"mousewheel",function(g){d.Scroll("wheel",g);NG.stopPropagation()});NG.addEventListener(e,"click",function(g){d.Scroll("click",g);NG.stopPropagation()});NG.addEventListener(b,"mousedown",function(g){d.Start(g)});if(document.NGDefaultScroller==this){NG.addEventListener(document,"mousewheel",function(g){d.Scroll("wheel",g);NG.stopPropagation()})}this.moveHandler=function(g){d.Scroll("move",g)};this.stopHandler=function(g){d.Stop(g)};this.stretchers=new Array;var a=this.content.getElementsByTagName("img");for(var c=0;c<a.length;c++){if(NG.hasClass(a[c],"scroll-stretch")){a[c].originalHeight=a[c].offsetHeight;a[c].originalWidth=a[c].offsetWidth;this.stretchers[this.stretchers.length]=a[c]}}if(this.content.scrollHeight>this.content.clientHeight){this.bar.style.display="block"}};NG.Scroller.prototype.Scroll=function(g,b){switch(g){case"wheel":var e=b.detail?b.detail:b.wheelDelta/-40;this.Scroll("delta",{x:e*2,y:e*2});break;case"click":this.Scroll("absolute",{x:b.clientX-(this.nodule.marginTop?this.nodule.marginTop:0),y:b.clientY-(this.nodule.marginLeft?this.nodule.marginLeft:0)});break;case"move":if(this.scrolling){this.Scroll("absolute",{x:b.clientX-(this.nodule.marginTop?this.nodule.marginTop:0),y:b.clientY-(this.nodule.marginLeft?this.nodule.marginLeft:0)})}break;case"top":this.Scroll("to",{x:0,y:0});break;case"bottom":if(NG.hasClass(scrolling.bar,"horizontal")){this.Scroll("to",{x:0,y:this.bar.offsetWidth})}else{this.Scroll("to",{x:0,y:this.bar.offsetHeight})}break;case"absolute":var c=this.GetOffset();b.y=b.y-NG.getPagePos(this.bar).y+c.y;b.x=b.x-NG.getPagePos(this.bar).x+c.x;this.Scroll("to",b);break;case"delta":var k={x:(this.nodule.style.left?parseInt(this.nodule.style.left.replace(/px/,"")):0)+b.x,y:(this.nodule.style.top?parseInt(this.nodule.style.top.replace(/px/,"")):0)+b.y};this.Scroll("to",k);break;default:case"to":var j=b.x;var h=b.y;if(NG.hasClass(this.bar,"horizontal")){if(j>this.bar.offsetWidth-this.nodule.offsetWidth-this.GetNoduleMargins()){this.nodule.style.left=this.bar.offsetLeft+this.bar.offsetWidth-this.nodule.offsetWidth-this.GetNoduleMargins()+"px"}else{if(j<0){this.nodule.style.left=this.bar.offsetLeft+"px"}else{this.nodule.style.left=this.bar.offsetLeft+j+"px"}}this.content.scrollTop=(this.content.scrollHeight-this.content.offsetHeight)*this.PointToPercentage({x:j,y:0}).x;var f=(j/(this.bar.offsetWidth-this.nodule.GetNoduleMargins()-this.nodule.offsetWidth));if(f<0){f=0}if(f>100){f=100}if(f<1){for(var d=0;d<this.stretchers.length;d++){var a=this.stretchers[d];a.style.width=(a.originalWidth+this.content.scrollTop)+"px"}}}else{if(h>this.bar.offsetHeight-this.nodule.offsetHeight-this.GetNoduleMargins()){this.nodule.style.top=this.bar.offsetHeight-this.nodule.offsetHeight-this.GetNoduleMargins()+"px"}else{if(h<0){this.nodule.style.top=0+"px"}else{this.nodule.style.top=h+"px"}}this.content.scrollTop=(this.content.scrollHeight-this.content.offsetHeight)*this.PointToPercentage({x:0,y:h}).y;var f=(h/(this.bar.offsetHeight-this.GetNoduleMargins()-this.nodule.offsetHeight));if(f<0){f=0}if(f>1){f=1}if(f<1){if(this.stretchers.length>0){this.stretchers[0].style.height=(this.stretchers[0].originalHeight+this.content.scrollTop)+"px"}}}break}};NG.Scroller.prototype.GetNoduleMargins=function(){if(NG.hasClass(this.bar,"horizontal")){return(this.nodule.style.marginLeft?parseInt(this.nodule.style.marginLeft.replace(/px/,"")):0)+(this.nodule.style.marginRight?parseInt(this.nodule.style.marginRight.replace(/px/,"")):0)}else{return(this.nodule.style.marginTop?parseInt(this.nodule.style.marginTop.replace(/px/,"")):0)+(this.nodule.style.marginBottom?parseInt(this.nodule.style.marginBottom.replace(/px/,"")):0)}};NG.Scroller.prototype.GetOffset=function(){var a=new Object;a.x=0;a.y=0;if(document.documentElement&&(document.documentElement.scrollTop||document.documentElement.scrollLeft)){a.x=document.documentElement.scrollLeft;a.y=document.documentElement.scrollTop}else{if(document.body&&(document.body.scrollTop||document.body.scrollLeft)){a.x=document.body.scrollLeft;a.y=document.body.scrollTop}else{if(window.pageYOffset||window.pageXOffset){a.x=window.pageXOffset;a.y=window.pageYOffset}else{if(window.scrollX||window.scrollY){a.x=window.scrollX;a.y=window.scrollY}}}}return a};NG.Scroller.prototype.Start=function(a){this.scrolling=true;NG.addEventListener(document,"mouseup",this.stopHandler);NG.addEventListener(document,"mousemove",this.moveHandler)};NG.Scroller.prototype.Stop=function(a){NG.removeEventListener(document,"mouseup",this.stopHandler);NG.removeEventListener(document,"mousemove",this.moveHandler);this.scrolling=false};NG.Scroller.prototype.PointToPercentage=function(a){a.x=(a.x/(this.bar.offsetWidth-this.nodule.offsetWidth-(NG.hasClass(this.bar,"horizontal")?this.GetNoduleMargins():0)));a.y=(a.y/(this.bar.offsetHeight-this.nodule.offsetHeight-(!NG.hasClass(this.bar,"horizontal")?this.GetNoduleMargins():0)));if(a.x<0){a.x=0}if(a.y<0){a.y=0}if(a.x>100){a.x=100}if(a.y>100){a.y=100}return a};