
function IScrollbar(idScrollArea,idScrollContent,idScrollControls,idScrollHandle,idScrollHandleBG,idScrollButtonUp,idScrollButtonDown,fIframeMode,cyStepsOnButton,cyStepsOnWheel,fHandleShowHideControls){this.idScrollHandle=idScrollHandle;this.idScrollHandleBG=idScrollHandleBG;if(fIframeMode){this.elScrollArea=document.getElementById(idScrollArea);this.elScrollContent=this.elScrollArea.contentWindow.document.documentElement;}else{this.elScrollContent=document.getElementById(idScrollContent);this.elScrollArea=document.getElementById(idScrollArea);}
this.fIframeMode=fIframeMode;this.cyStepsOnButton=cyStepsOnButton
this.cyStepsOnWheel=cyStepsOnWheel;this.scrollEffect=null;this.fHasMouseDown=false;this.lastDirectionUp=false;this.lastVerticalStep=0;this.yScrollerDragStart=0;this.yScrollerDragHandleOffset=0;this.cScrollerWheelUpEvents=0;this.cScrollerWheelDownEvents=0;this.fWheelBusy=false;var self=this;this.fnDoDrag=function(e){self.doDrag(e)};this.fnEndDrag=function(e){self.endDrag(e)};var el=this.elScrollContent;if(el.addEventListener){el.addEventListener("DOMMouseScroll",function(e){self.onMouseWheel(e)},false);}
dw_Event.add(el,"mousewheel",function(e){self.onMouseWheel(e);return false;},false);var elButtonUp=document.getElementById(idScrollButtonUp);var elButtonDown=document.getElementById(idScrollButtonDown);elButtonUp.onmousedown=function(e){self.scrollUpMouseDown(e);return false;};elButtonUp.onmouseout=function(e){self.mouseUp(e);return false;};elButtonUp.onmouseup=function(e){self.mouseUp(e);return false;};elButtonDown.onmousedown=function(e){self.scrollDownMouseDown(e);return false;};elButtonDown.onmouseout=function(e){self.mouseUp(e);return false;};elButtonDown.onmouseup=function(e){self.mouseUp(e);return false;};var elScrollHandle=document.getElementById(idScrollHandle);dw_Event.add(elScrollHandle,"mousedown",function(e){self.catchHandle(e);return false;},false);var elScrollHandleBG=document.getElementById(idScrollHandleBG);dw_Event.add(elScrollHandleBG,"click",function(e){self.handleTrackClick(e);return false;},false);if(fHandleShowHideControls){if(this.isScrollerNeeded()){setElementsByIdsVisible(idScrollControls);}else{setElementsByIdsHidden(idScrollControls);}}}
IScrollbar.prototype.getAreaHeight=function(){return this.elScrollArea.clientHeight;}
IScrollbar.prototype.getContentHeight=function(){if(this.fIframeMode){var scrollHeight=this.elScrollArea.contentWindow.document.body.scrollHeight;if(this.elScrollArea.contentWindow.document.documentElement.clientHeight>scrollHeight)
scrollHeight=this.elScrollArea.contentWindow.document.documentElement.clientHeight;if(this.elScrollArea.contentWindow.document.documentElement.scrollHeight>scrollHeight)
scrollHeight=this.elScrollArea.contentWindow.document.documentElement.scrollHeight;return scrollHeight;}else{var scrollHeight=this.elScrollContent.scrollHeight;if(this.elScrollContent.clientHeight>scrollHeight)
scrollHeight=this.elScrollContent.clientHeight;return scrollHeight;}}
IScrollbar.prototype.getContentOffsetTop=function(){if(this.fIframeMode){var scrollTop=this.elScrollArea.contentWindow.document.documentElement.scrollTop||this.elScrollArea.contentWindow.document.body.scrollTop;if(this.elScrollArea.contentWindow.pageYOffset)
scrollTop=this.elScrollArea.contentWindow.pageYOffset;return scrollTop;}else{var scrollTop=this.elScrollContent.offsetTop;if(scrollTop<0)
scrollTop=-1*scrollTop;return scrollTop;}}
IScrollbar.prototype.setScrollPos=function(x,y){if(this.fIframeMode){this.elScrollArea.contentWindow.scrollTo(0,y);}else{this.elScrollContent.style.marginTop=(-1*y)+"px";}}
IScrollbar.prototype.scroll=function(up,cyScrollStep,wheel){if(!this.isScrollerNeeded())
return;this.lastDirectionUp=up;this.lastVerticalStep=cyScrollStep;if(wheel){if(this.fWheelBusy){if(up)
this.cScrollerWheelUpEvents++;else
this.cScrollerWheelDownEvents++;return;}
this.cScrollerWheelUpEvents=0;this.cScrollerWheelDownEvents=0;}
var scrollTop=this.getContentOffsetTop();var scrollHeight=this.getContentHeight();var cyArea=this.getAreaHeight();if(!this.scrollEffect){var self=this;this.scrollEffect=new ScrollElementEffect(this.fIframeMode?this.elScrollArea.contentWindow:this.elScrollContent,0,0,function(){self.scrollEffectDoneCallback()},function(){self.scrollHandler()},this.fIframeMode);}
if(up){if(scrollTop>0){var to=scrollTop-(cyScrollStep);if(to<0)
to=0;this.scrollEffect.startScrollEffect(scrollTop,to);if(wheel)
this.fWheelBusy=true;}}else{if(scrollTop+cyArea<scrollHeight){var to=scrollTop+cyScrollStep;if(to>scrollHeight-cyArea)
to=scrollHeight-cyArea;this.scrollEffect.startScrollEffect(scrollTop,to);if(wheel)
this.fWheelBusy=true;}}}
IScrollbar.prototype.isScrollerNeeded=function(){return this.getAreaHeight()<this.getContentHeight();}
IScrollbar.prototype.scrollEffectDoneCallback=function(){if(this.fHasMouseDown){this.scroll(this.lastDirectionUp,this.lastVerticalStep);}else if(this.fWheelBusy){if(this.cScrollerWheelUpEvents>0){this.cScrollerWheelUpEvents--;this.scroll(true,this.cyStepsOnWheel,false);}else if(this.cScrollerWheelDownEvents>0){this.cScrollerWheelDownEvents--;this.scroll(false,this.cyStepsOnWheel,false);}
this.fWheelBusy=false;}}
IScrollbar.prototype.scrollHandler=function(){var elHandle=document.getElementById(this.idScrollHandle);var cyHandleArea=elHandle.parentNode.clientHeight-elHandle.clientHeight;var y=Math.floor(cyHandleArea*(this.getContentOffsetTop()/(this.getContentHeight()-this.getAreaHeight())));try{elHandle.style.top=y+"px";}catch(e){}}
IScrollbar.prototype.contentUpdated=function(fShowHideControls){if(this.isScrollerNeeded()){var scrollTop=this.getContentOffsetTop();var scrollHeight=this.getContentHeight();var cyArea=this.getAreaHeight();if(scrollTop>0&&scrollHeight-scrollTop<cyArea){var y=scrollHeight-cyArea;if(y<0)
y=0;this.setScrollPos(0,y);}
this.scrollHandler();if(fShowHideControls)
setElementsByIdsVisible("cart_scrollcontrols");}else{this.setScrollPos(0,0);if(fShowHideControls)
setElementsByIdsHidden("cart_scrollcontrols");this.scrollHandler();}}
IScrollbar.prototype.scrollPage=function(up){this.scroll(up,this.getAreaHeight());}
IScrollbar.prototype.scrollUp=function(){this.scroll(true,this.cyStepsOnButton);}
IScrollbar.prototype.scrollDown=function(){this.scroll(false,this.cyStepsOnButton);}
IScrollbar.prototype.scrollUpMouseDown=function(){this.fHasMouseDown=true;this.scrollUp();}
IScrollbar.prototype.scrollDownMouseDown=function(){this.fHasMouseDown=true;this.scrollDown();}
IScrollbar.prototype.mouseUp=function(){this.fHasMouseDown=false;}
IScrollbar.prototype.handleTrackClick=function(e){var elHandle=document.getElementById(this.idScrollHandle);var yClick=e.pageY||(e.clientY+getPageScrollTop()[1]);var yOff=yClick-getElementAbsoluteOffsetTop(elHandle);if(yOff>0&&yOff<elHandle.clientHeight)
return;this.scrollPage(yOff<0);}
IScrollbar.prototype.catchHandle=function(e){e=dw_Event.DOMit(e);if(this.isScrollerNeeded()){var elHandle=document.getElementById(this.idScrollHandle);var yClick=e.pageY||(e.clientY+getPageScrollTop()[1]);var yHandle=getElementAbsoluteOffsetTop(elHandle);this.yScrollerDragHandleOffset=yClick-yHandle;this.yScrollerDragStart=yClick;var self=this;dw_Event.add(document,"mousemove",this.fnDoDrag,true);dw_Event.add(document,"mouseup",this.fnEndDrag,true);}
e.stopPropagation();e.preventDefault();}
IScrollbar.prototype.doDrag=function(e){e=dw_Event.DOMit(e);var y=e.pageY||(e.clientY+getPageScrollTop()[1]);var elHandle=document.getElementById(this.idScrollHandle);var elHandleBg=document.getElementById(this.idScrollHandleBG);var scrollHeight=this.getContentHeight();var cyArea=this.getAreaHeight();var cyHandleArea=elHandle.parentNode.clientHeight-elHandle.clientHeight;var percentage=(y-getElementAbsoluteOffsetTop(elHandleBg)-this.yScrollerDragHandleOffset)/cyHandleArea;if(percentage<0)
percentage=0;var yTo=(scrollHeight-cyArea)*percentage;if(yTo<0)
yTo=0;if(yTo>scrollHeight-cyArea)
yTo=scrollHeight-cyArea;this.setScrollPos(0,yTo);var y=Math.floor(cyHandleArea*(yTo/(scrollHeight-cyArea)));elHandle.style.top=y+"px";e.stopPropagation();e.preventDefault();return false;}
IScrollbar.prototype.endDrag=function(e){var self=this;dw_Event.remove(document,"mousemove",this.fnDoDrag,true);dw_Event.remove(document,"mouseup",this.fnEndDrag,true);}
IScrollbar.prototype.onMouseWheel=function(e){var delta=0;if(!e)e=window.event;e=dw_Event.DOMit(e);if(e.wheelDelta){delta=e.wheelDelta/120;}else if(e.detail){delta=-e.detail/3;}
if(delta){this.scroll(delta>0,this.cyStepsOnWheel,true);}
e.stopPropagation();e.preventDefault();return false;}
var dw_Event={add:function(obj,etype,fp,cap){cap=cap||false;if(obj.addEventListener)obj.addEventListener(etype,fp,cap);else if(obj.attachEvent)obj.attachEvent("on"+etype,fp);},remove:function(obj,etype,fp,cap){cap=cap||false;if(obj.removeEventListener)obj.removeEventListener(etype,fp,cap);else if(obj.detachEvent)obj.detachEvent("on"+etype,fp);},DOMit:function(e){e=e?e:window.event;if(!e.target)e.target=e.srcElement;if(!e.preventDefault)e.preventDefault=function(){e.returnValue=false;return false;}
if(!e.stopPropagation)e.stopPropagation=function(){e.cancelBubble=true;}
return e;}}
function addLoadEvent(func){var oldQueue=window.onload?window.onload:function(){};window.onload=function(){oldQueue();func();}}