(function(f){function q(a,d){if(a._isVer){var b=d[1];0>b-a._start?b=d[1]=a._start:b>a._end&&(b=d[1]=a._end)}else b=d[0],0>b-a._start?b=d[0]=a._start:b>a._end&&(b=d[0]=a._end);if(a._lastPos&&3>Math.abs(a._lastPos-b))return d;a._lastPos=b;return d}function r(a){var d=a.control,b=d.opts;a._steps=b.startStep;a._endStep=b.endStep-b.viewport;a._scale=d._scale;a._epos=d.epos;a._lastP=a._start;d._isVer?(a._isVer=!0,a._start=b.startPosition,f(d.eend).isVisible()?(a._end=d.eend.offsetTop+Math.ceil(a.handle.offsetHeight/
2),a._end>b.viewportSize+a._start&&(a._end=b.viewportSize+a._start)):a._end=b.viewportSize+a._start,a._end-=a.node.offsetHeight-d._gap):(a._isVer=!1,a._start=b.startPosition,f(d.eend).isVisible()?(a._end=d.eend.offsetLeft+Math.ceil(a.handle.offsetWidth/2),a._end>b.viewportSize+a._start&&(a._end=b.viewportSize+a._start)):a._end=b.viewportSize+a._start,a._end-=a.node.offsetWidth-d._gap);jq(a._epos).show().delay(200).fadeIn(500);a._timer&&clearTimeout(a._timer);var c,e=[],g=10,m=function(b){var h=f.parseFloat(a.node.style[b]),
l=h-f.parseFloat(a._epos.style[b]);if(c==h){if(e.push(a._lastSteps),4<e.length&&e.shift()==a._lastSteps){e[0]=a._lastSteps;clearTimeout(a._timer);a._timer=setTimeout(function(){m(b)},100);return}}else g=10;c=h;var n=0<l,p=n?Math.max(0,l/a._scale):Math.min(0,l/a._scale),k=Math.round(d.$class.easing(g/600,g,0,p,600));n?1<p&&(k=Math.max(1,k)):1<-p&&(k=Math.min(-1,k));0==l&&0==k&&(h==a._start?k=-a._steps:h==a._end&&(k=a._endStep-a._steps));a._steps+=k;n?a._steps>a._endStep&&(a._steps=a._endStep):0>a._steps&&
(a._steps=0);a._epos.style[b]=a._start+a._scale*a._steps+"px";g+=30;a._lastSteps!=a._steps&&(a._lastSteps=a._steps,h="top"==b?d.opts.onScrollY:d.opts.onScrollX,"function"==typeof h&&h.call(a.control.widget,a._steps+d.opts.offset));clearTimeout(a._timer);a._timer=setTimeout(function(){m(b)},30)};a._timer=setTimeout(function(){m(a._isVer?"top":"left")},50)}function t(a,d){d=a.control;a._timer&&clearTimeout(a._timer);if(a._isVer){var b=f.parseInt(a._epos.style.top);end=a._end;b>end&&(b=end);jq(a.node).animate({top:b+
"px"},400,"swing")}else b=f.parseInt(a._epos.style.left),end=a._end,b>end&&(b=end),jq(a.node).animate({left:b+"px"},400,"swing");d.opts.startStep=a._steps;d._syncButtonStatus();d=jq(a._epos).css("opacity");jq(a._epos).delay(300).fadeOut(500).css("opacity",d)}function u(a,d,b){return a.control.edragBody!=b.domTarget}zul.WScroll=f.$extends(f.Object,{_gap:0,$init:function(a,d){this.control=a;this.opts=f.$default(d,{orient:"horizontal",startPosition:0,startStep:0,offset:0});this.anchor=this.opts.anchor||
a.parentNode;this.widget=f.Widget.$(a);this.uid=this.widget.uuid;this.zcls=this.widget.getZclass();this._isVer="vertical"==d.orient;if(!d.viewportSize&&0!=d.viewportSize)throw"Handle required for a viewport size: {viewportSize: size}";this.redraw(this.anchor);this._initDragdrop();this._listenMouseEvent();!1!==this.opts.syncSize&&this.syncSize();this._syncButtonStatus()},syncSize:function(a){a&&(this.opts=f.copy(this.opts,a));this.edrag.style.display="";if(this._isVer){a=this.opts;var d=a.startPosition;
var b=a.startStep;var c=a.viewport;var e=a.endStep;var g=a.viewportSize;e-=c;c=this.edrag.offsetHeight-this._gap;0>=e?(this.eend.style.display=this.edrag.style.display="none","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,a.offset)):(g-=c,g>e?(this.epos.style.height=c+"px",this._scale=1,a=this.eend.style,a.display="",a.top=d+c+e+"px"):(a=g/e,this.epos.style.height=Math.max(c*a,5)+"px",this._scale=a,this.eend.style.display="none",10>g&&(this.edrag.style.display="none")),
b=d+this._scale*b,g=d+g,b>g&&(b=g),this.epos.style.top=this.edrag.style.top=b+"px")}else a=this.opts,d=a.startPosition,b=a.startStep,c=a.viewport,e=a.endStep,g=a.viewportSize,e-=c,c=this.edrag.offsetWidth-this._gap,0>=e?(this.eend.style.display=this.edrag.style.display="none","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,a.offset)):(g-=c,g>e?(this.epos.style.width=c+"px",this._scale=1,a=this.eend.style,a.display="",a.left=d+c+e+"px"):(a=g/e,this.epos.style.width=Math.max(c*
a,5)+"px",this._scale=a,this.eend.style.display="none",10>g&&(this.edrag.style.display="none")),b=d+this._scale*b,g=d+g,b>g&&(b=g),this.epos.style.left=this.edrag.style.left=b+"px")},_listenMouseEvent:function(){this._isVer?jq(this.control).mousewheel(this.proxy(this._mousewheelY)):11>f.ie&&f.opera||jq(this.control).mousewheel(this.proxy(this._mousewheelX));var a=jq(this.edrag);a.children("div").mouseover(this.proxy(this._mouseOver)).mouseout(this.proxy(this._mouseOut)).bind("mouseup",this.proxy(this._mouseUp)).bind("mousedown",
this.proxy(this._mouseDown));a.click(f.$void)},_unlistenMouseEvent:function(){this._isVer?jq(this.control).unmousewheel(this.proxy(this._mousewheelY)):11>f.ie&&f.opera||jq(this.control).unmousewheel(this.proxy(this._mousewheelX));var a=jq(this.edrag);a.children("div").unbind("mouseover",this.proxy(this._mouseOver)).unbind("mouseout",this.proxy(this._mouseOut)).unbind("mouseup",this.proxy(this._mouseUp)).unbind("mousedown",this.proxy(this._mouseDown));a.unbind("click",f.$void)},_mouseOver:function(a){a=
a.target.className;var d=a.lastIndexOf("-"),b=a.substring(d+1);d=jq(this.edrag);d.hasClass(a+"-clk")&&d.removeClass(a+"-clk");switch(b){case "home":case "up":0<this.opts.startStep&&d.addClass(a+"-over");break;case "down":case "end":b=this.opts,b.startStep<b.endStep-b.viewport&&d.addClass(a+"-over")}},_mouseOut:function(a){a=a.target.className;var d=jq(this.edrag);d.removeClass(a+"-over");d.hasClass(a+"-clk")&&d.removeClass(a+"-clk")},_mouseUp:function(a){jq(this.edrag).removeClass(a.target.className+
"-clk")},_mouseDown:function(a){a=a.target.className;var d=a.lastIndexOf("-");var b=a.substring(d+1);d=jq(this.edrag);if(d.hasClass(a+"-over")||f.mobile){d.addClass(a+"-clk");var c=this.opts;switch(b){case "home":0<c.startStep&&(c.startStep=0,this._isVer?(b=c.startPosition+"px",this.epos.style.top=b,d.animate({top:b},500),"function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,c.startStep+c.offset)):(b=c.startPosition+"px",this.epos.style.left=b,d.animate({left:b},500),"function"==
typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,c.startStep+c.offset)),d.removeClass(a+"-over"));break;case "up":if(0<c.startStep){--c.startStep;var e=c.startPosition+c.startStep*this._scale;this._isVer?(b=f(this.eend).isVisible()?this.eend.offsetTop:c.viewportSize+c.startPosition,b-=this.edrag.offsetHeight-this._gap,this.epos.style.top=e+"px",this.edrag.style.top=b<e?b+"px":e+"px","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,c.startStep+c.offset)):
(b=f(this.eend).isVisible()?this.eend.offsetLeft:c.viewportSize+c.startPosition,b-=this.edrag.offsetWidth-this._gap,this.epos.style.left=e+"px",this.edrag.style.left=b<e?b+"px":e+"px","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,c.startStep+c.offset));0==c.startStep&&d.removeClass(a+"-over")}break;case "down":c.startStep<c.endStep-c.viewport&&(c.startStep+=1,e=c.startPosition+c.startStep*this._scale,this._isVer?(b=f(this.eend).isVisible()?this.eend.offsetTop:c.viewportSize+
c.startPosition,b-=this.edrag.offsetHeight-this._gap,this.epos.style.top=e+"px",this.edrag.style.top=b<e?b+"px":e+"px","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,c.startStep+c.offset)):(b=f(this.eend).isVisible()?this.eend.offsetLeft:c.viewportSize+c.startPosition,b-=this.edrag.offsetWidth-this._gap,this.epos.style.left=e+"px",this.edrag.style.left=b<e?b+"px":e+"px","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,c.startStep+c.offset)),
c.startStep==c.endStep-c.viewport&&d.removeClass(a+"-over"));break;case "end":c.startStep<c.endStep-c.viewport&&(c.startStep=c.endStep-c.viewport,this._isVer?(b=f(this.eend).isVisible()?this.eend.offsetTop-(this.edrag.offsetHeight-this._gap):c.startPosition+c.viewportSize-(this.edrag.offsetHeight-this._gap),this.epos.style.top=b,d.animate({top:b},500),"function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,c.startStep+c.offset)):(b=f(this.eend).isVisible()?this.eend.offsetLeft-
(this.edrag.offsetWidth-this._gap):c.startPosition+c.viewportSize-(this.edrag.offsetWidth-this._gap),this.epos.style.left=b,d.animate({left:b},500),"function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,c.startStep+c.offset)),d.removeClass(a+"-over"))}this._syncButtonStatus()}},_mousewheelY:function(a,d,b,c){if(c){a.stop();a=this.opts;d=a.startStep;b=a.endStep-a.viewport;var e=this._scale,g=this.widget;0<c?(a.startStep-=Math.max(Math.round(g._cols/5),1),0>a.startStep&&(a.startStep=
0)):(a.startStep+=Math.max(Math.round(g._cols/5),1),a.startStep>b&&(a.startStep=b));d!=a.startStep&&(c=a.startPosition+a.startStep*e,d=f(this.eend).isVisible()?this.eend.offsetTop-(this.edrag.offsetHeight-this._gap):a.startPosition+a.viewportSize-(this.edrag.offsetHeight-this._gap),this.epos.style.top=c+"px",c>d&&(c=d),this.edrag.style.top=c+"px","function"==typeof this.opts.onScrollY&&this.opts.onScrollY.call(this.widget,a.startStep+a.offset),this._syncButtonStatus())}},_mousewheelX:function(a,d,
b,c){if(b){a.stop();a=this.opts;d=a.startStep;c=a.endStep-a.viewport;var e=this._scale,g=this.widget;0>b?(a.startStep-=Math.max(Math.round(g._cols/5),1),0>a.startStep&&(a.startStep=0)):(a.startStep+=Math.max(Math.round(g._cols/5),1),a.startStep>c&&(a.startStep=c));d!=a.startStep&&(b=a.startPosition+a.startStep*e,d=f(this.eend).isVisible()?this.eend.offsetLeft-(this.edrag.offsetWidth-this._gap):a.startPosition+a.viewportSize-(this.edrag.offsetWidth-this._gap),this.epos.style.left=b+"px",b>d&&(b=d),
this.edrag.style.left=b+"px","function"==typeof this.opts.onScrollX&&this.opts.onScrollX.call(this.widget,a.startStep+a.offset),this._syncButtonStatus())}},_initDragdrop:function(){this.node=jq(this.uid+"-"+(this._isVer?"v":"h")+"bar",f)[0];this.edrag=this.node.firstChild;this.edragBody=this.edrag.childNodes[2];this.epos=this.edrag.nextSibling;this.eend=this.node.lastChild;var a=this.epos.style,d=a.display;a.display="block";this._gap=this._isVer?this.edrag.offsetHeight-this.epos.offsetHeight:this.edrag.offsetWidth-
this.epos.offsetWidth;a.display=d;this.drag=new f.Draggable(this,this.edrag,{constraint:this._isVer?"vertical":"horizontal",snap:q,starteffect:r,zIndex:12E3,ignoredrag:u,endeffect:t});jq(this.epos).hide()},destroy:function(){this.drag.destroy();this._unlistenMouseEvent();jq(this.node).remove();this.node=this.edrag=this.epos=this.drag=null},redraw:function(a){var d=this._isVer?"vertical":"horizontal",b=this.uid+"-"+(this._isVer?"v":"h")+"bar",c=this.widget.$s("wscroll");jq(a).append('<div id="'+b+
'" class="'+c+"-"+d+'"><div class="'+c+'-drag"><div class="'+c+'-home" title="'+msgzul.WS_HOME+'"></div><div class="'+c+'-up" title="'+msgzul.WS_PREV+'"></div><div class="'+c+'-body"></div><div class="'+c+'-down" title="'+msgzul.WS_NEXT+'"></div><div class="'+c+'-end" title="'+msgzul.WS_END+'"></div></div><div class="'+c+'-pos"></div><div class="'+c+'-endbar"></div></div>')},_syncButtonStatus:function(){var a=this.zcls+"-wscroll",d=jq(this.edrag),b=this.opts;d.toggleClass(a+"-head",0==b.startStep);
d.toggleClass(a+"-tail",b.startStep==b.endStep-b.viewport)}},{easing:function(a,d,b,c,e){return-c*((d=d/e-1)*d*d*d-1)+b}})})(zk);
