function iScroll(a,b){this.element=typeof a=="object"?a:document.getElementById(a);this.wrapper=this.element.parentNode;this.wrapper.style.overflow="hidden";this.wrapper.style.position="relative";this.element.style.webkitTransitionProperty="-webkit-transform";this.element.style.webkitTransitionTimingFunction="cubic-bezier(0,0,0.25,1)";this.element.style.webkitTransitionDuration="0";this.element.style.webkitTransform="translate3d(0,0,0)";this.options={bounce:true,hScrollBar:true,vScrollBar:true};if(typeof b==
"object")for(var c in b)this.options[c]=b[c];this.refresh();this.element.addEventListener("touchstart",this);this.element.addEventListener("touchmove",this);this.element.addEventListener("touchend",this);this.element.addEventListener("DOMSubtreeModified",this);window.addEventListener("orientationchange",this)}
iScroll.prototype={_x:0,_y:0,handleEvent:function(a){switch(a.type){case "touchstart":this.onTouchStart(a);break;case "touchmove":this.onTouchMove(a);break;case "touchend":this.onTouchEnd(a);break;case "webkitTransitionEnd":this.onTransitionEnd(a);break;case "orientationchange":this.refresh();break;case "DOMSubtreeModified":this.refresh()}},refresh:function(){this.element.style.webkitTransitionDuration="0";this.scrollWidth=this.wrapper.clientWidth;this.scrollHeight=this.wrapper.clientHeight;try{if(typeof LPFromWebsite!=
"undefined"&&typeof LPFromWebsite.ipad!="undefined"&&typeof $.tree!="undefined"){var a=0;if($.tree.focused().container.children().length==1&&$.tree.focused().container.children().children().length>0)a=$.tree.focused().container.children().children()[$.tree.focused().container.children().children().length-1].clientHeight;this.scrollHeight-=20+a}}catch(b){}this.maxScrollX=this.scrollWidth-this.element.offsetWidth;this.maxScrollY=this.scrollHeight-this.element.offsetHeight;a=this._x;var c=this._y;if(this.scrollX&&
this._x<this.maxScrollX)a=this.maxScrollX;if(this.scrollY&&this._y<this.maxScrollY)c=this.maxScrollY;this.scrollTo(a,c,"0");this.scrollX=this.element.offsetWidth>this.scrollWidth?true:false;this.scrollY=this.element.offsetHeight>this.scrollHeight?true:false;if(this.options.hScrollBar&&this.scrollX){this.scrollBarX=new scrollbar("horizontal",this.wrapper);this.scrollBarX.init(this.scrollWidth,this.element.offsetWidth)}else if(this.scrollBarX)this.scrollBarX=this.scrollBarX.remove();if(this.options.vScrollBar&&
this.scrollY){this.scrollBarY=new scrollbar("vertical",this.wrapper);this.scrollBarY.init(this.scrollHeight,this.element.offsetHeight)}else if(this.scrollBarY)this.scrollBarY=this.scrollBarY.remove()},setPosition:function(a,b){this._x=a!==null?a:this._x;this._y=b!==null?b:this._y;this.element.style.webkitTransform="translate3d("+this._x+"px,"+this._y+"px,0)";this.scrollBarX&&this.scrollBarX.setPosition(this.scrollBarX.maxScroll/this.maxScrollX*this._x);this.scrollBarY&&this.scrollBarY.setPosition(this.scrollBarY.maxScroll/
this.maxScrollY*this._y)},onTouchStart:function(a){if(a.targetTouches.length!=1)return false;a.preventDefault();a.stopPropagation();this.element.style.webkitTransitionDuration="0";if(this.scrollBarX)this.scrollBarX.bar.style.webkitTransitionDuration="0, 250ms";if(this.scrollBarY)this.scrollBarY.bar.style.webkitTransitionDuration="0, 250ms";var b=new WebKitCSSMatrix(window.getComputedStyle(this.element).webkitTransform);if(b.m41!=this._x||b.m42!=this._y)this.setPosition(b.m41,b.m42);this.touchStartX=
a.touches[0].pageX;this.scrollStartX=this._x;this.touchStartY=a.touches[0].pageY;this.scrollStartY=this._y;this.scrollStartTime=a.timeStamp;this.moved=false},onTouchMove:function(a){if(a.targetTouches.length!=1)return false;var b=this.scrollX===true?a.touches[0].pageX-this.touchStartX:0,c=this.scrollY===true?a.touches[0].pageY-this.touchStartY:0;if(this._x>0||this._x<this.maxScrollX)b=Math.round(b/4);if(this._y>0||this._y<this.maxScrollY)c=Math.round(c/4);this.scrollBarX&&!this.scrollBarX.visible&&
this.scrollBarX.show();this.scrollBarY&&!this.scrollBarY.visible&&this.scrollBarY.show();this.setPosition(this._x+b,this._y+c);this.touchStartX=a.touches[0].pageX;this.touchStartY=a.touches[0].pageY;this.moved=true;if(a.timeStamp-this.scrollStartTime>250){this.scrollStartX=this._x;this.scrollStartY=this._y;this.scrollStartTime=a.timeStamp}},onTouchEnd:function(a){if(a.targetTouches.length>0)return false;if(!this.moved){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",true,true,document.defaultView,
0,0,0,0,0,0,0,0,0,0,0,null);a.changedTouches[0].target.dispatchEvent(b);return false}a=a.timeStamp-this.scrollStartTime;b=this.scrollX===true?this.momentum(this._x-this.scrollStartX,a,-this._x+50,this._x+this.element.offsetWidth-this.scrollWidth+50):{dist:0,time:0};var c=this.scrollY===true?this.momentum(this._y-this.scrollStartY,a,-this._y+50,this._y+this.element.offsetHeight-this.scrollHeight+50):{dist:0,time:0};if(!b.dist&&!c.dist){this.onTransitionEnd();return false}a=Math.max(b.time,c.time);
b=this._x+b.dist;c=this._y+c.dist;this.element.addEventListener("webkitTransitionEnd",this);this.scrollTo(b,c,a+"ms");this.scrollBarX&&this.scrollBarX.scrollTo(this.scrollBarX.maxScroll/this.maxScrollX*b,a+"ms");this.scrollBarY&&this.scrollBarY.scrollTo(this.scrollBarY.maxScroll/this.maxScrollY*c,a+"ms")},onTransitionEnd:function(){this.element.removeEventListener("webkitTransitionEnd",this);this.resetPosition();this.scrollBarX&&this.scrollBarX.hide();this.scrollBarY&&this.scrollBarY.hide()},resetPosition:function(){var a=
resetY=null;if(this._x>0||this._x<this.maxScrollX)a=this._x>=0?0:this.maxScrollX;if(this._y>0||this._y<this.maxScrollY)resetY=this._y>=0?0:this.maxScrollY;if(a!==null||resetY!==null){this.scrollTo(a,resetY,"500ms");if(this.scrollBarX)this.scrollBarX.scrollTo(this.scrollBarX.maxScroll/this.maxScrollX*(a||this._x),"500ms");if(this.scrollBarY)this.scrollBarY.scrollTo(this.scrollBarY.maxScroll/this.maxScrollY*(resetY||this._y),"500ms")}},scrollTo:function(a,b,c){this.element.style.webkitTransitionDuration=
c||"400ms";this.setPosition(a,b)},momentum:function(a,b,c,e){friction=0.1;deceleration=1.5;var d=Math.abs(a)/b*1E3;b=d*d/(20*friction)/1E3;if(a>0&&c!==undefined&&b>c){d=d*c/b;b=c}if(a<0&&e!==undefined&&b>e){d=d*e/b;b=e}b*=a<0?-1:1;a=-d/-deceleration;if(a<1)a=1;return{dist:Math.round(b),time:Math.round(a)}}};
var scrollbar=function(a,b){this.dir=a;this.bar=document.createElement("div");this.bar.className="scrollbar "+a;this.bar.style.webkitTransitionTimingFunction="cubic-bezier(0,0,0.25,1)";this.bar.style.webkitTransform="translate3d(0,0,0)";this.bar.style.webkitTransitionProperty="-webkit-transform,opacity";this.bar.style.webkitTransitionDuration="0,250ms";this.bar.style.pointerEvents="none";this.bar.style.opacity="0";b.appendChild(this.bar)};
scrollbar.prototype={size:0,maxSize:0,maxScroll:0,visible:false,init:function(a,b){var c=this.dir=="horizontal"?this.bar.offsetWidth-this.bar.clientWidth:this.bar.offsetHeight-this.bar.clientHeight;this.maxSize=a-8;this.size=Math.round(this.maxSize*this.maxSize/b)+c;this.maxScroll=this.maxSize-this.size;this.bar.style[this.dir=="horizontal"?"width":"height"]=this.size-c+"px"},setPosition:function(a){if(a<0)a=0;else if(a>this.maxScroll)a=this.maxScroll;a=this.dir=="horizontal"?"translate3d("+Math.round(a)+
"px,0,0)":"translate3d(0,"+Math.round(a)+"px,0)";this.bar.style.webkitTransform=a},scrollTo:function(a,b){this.bar.style.webkitTransitionDuration=(b||"400ms")+",250ms";this.setPosition(a)},show:function(){this.visible=true;this.bar.style.opacity="1"},hide:function(){this.visible=false;this.bar.style.opacity="0"},remove:function(){this.bar.parentNode.removeChild(this.bar);return null}};
