function ScrollToTop(oWindowDiv){ oWindowDiv.scrollTop = 0; var oContentDiv = LayerGetFirstChild(oWindowDiv,'div'); if(oContentDiv!=null){ LayerMoveTo(oContentDiv,0,0); } } var iScrollBarW_ = -1; function FindScrollBarW(){ var oOuterDiv = document.createElement('DIV'); document.body.appendChild(oOuterDiv); oOuterDiv.id = 'oOuterDiv'; oOuterDiv.style.position='absolute'; LayerSetW(oOuterDiv,100); LayerSetX(oOuterDiv,-1000); var oInnerDiv = document.createElement('DIV'); oOuterDiv.appendChild(oInnerDiv); oInnerDiv.id = 'oInnerDiv'; LayerAddHTML(oInnerDiv,'-'); var iFullW = LayerGetW(oInnerDiv); oOuterDiv.style.overflow='scroll'; iScrollBarW_ = iFullW - LayerGetW(oInnerDiv); if(iScrollBarW_<10){ iScrollBarW_ = 17; } document.body.removeChild(oOuterDiv); } function GetScrollBarW(){ if(iScrollBarW_==-1){ FindScrollBarW(); } return iScrollBarW_; } function initScroll(oWindowDiv){ if(useScrollButtons(oWindowDiv)){ var oContentDiv = LayerGetFirstChild(oWindowDiv,'div'); if(oContentDiv!=null){ oContentDiv.style.position='absolute'; LayerMoveTo(oContentDiv,0,0); var ScrollBarW = GetScrollBarW(); var clipW = LayerGetW(oWindowDiv) - ScrollBarW; var clipH = LayerGetH(oWindowDiv) - ScrollBarW; oWindowDiv.style.clip = 'rect(0px,' + clipW + 'px,' + clipH + 'px,0px)'; var iOffsetHeight = LayerGetH(oContentDiv) - LayerGetH(oWindowDiv) + ScrollBarW; var oButtonUp = GetButtonUp(oWindowDiv); LayerSetY(oButtonUp,LayerGetY(oWindowDiv)); var oButtonDown = GetButtonDown(oWindowDiv); LayerSetY(oButtonDown,LayerGetY(oWindowDiv)+clipH-LayerGetH(oButtonDown)); var oScrollBar = GetScrollBar(oWindowDiv,oContentDiv); LayerSetX(oScrollBar,LayerGetX(oButtonUp)); LayerSetY(oScrollBar,LayerGetY(oButtonUp)+LayerGetH(oButtonUp)); LayerSetH(oScrollBar,LayerGetY(oButtonDown)-LayerGetY(oScrollBar)); LayerSetW(oScrollBar,LayerGetW(oButtonUp)); if(iOffsetHeight>0){ LayerShow(oButtonUp); LayerShow(oButtonDown); SetScrollBarPos(oWindowDiv,oContentDiv); LayerShow(oScrollBar); oWindowDiv.onscroll = windowDivScrollEwent; } else{ LayerHide(oButtonUp); LayerHide(oButtonDown); LayerHide(oScrollBar); } } } } function GetButton(oWindowDiv,name){ var oButton = GetObject(oWindowDiv.id + name); if(oButton==null){ oButton = document.createElement('DIV'); oWindowDiv.parentNode.appendChild(oButton); oButton.id = oWindowDiv.id + name; oButton.className = oWindowDiv.id + name; oButton.onmouseup = ScrollStop; oButton.onmouseout = ScrollStop; } return oButton; } function GetButtonUp(oWindowDiv){ var button = GetButton(oWindowDiv, 'Up'); button.onmousedown = ScrollUp; makeArrowUp(button); return button; } function GetButtonDown(oWindowDiv){ var button = GetButton(oWindowDiv, 'Down'); button.onmousedown = ScrollDown; makeArrowDown(button); return button; } function GetScrollBar(oWindowDiv,oContentDiv){ var oScrollBar = GetObject(oWindowDiv.id + 'ScrollBar'); if(oScrollBar==null){ oScrollBar = document.createElement('DIV'); oWindowDiv.parentNode.appendChild(oScrollBar); oScrollBar.id = oWindowDiv.id + 'ScrollBar'; oScrollBar.className = oWindowDiv.id + 'ScrollBar'; oScrollBar.onmousedown = ScrollBarMouseDown; oScrollBar.onmouseup = ScrollStop; oScrollBar.onmouseout = ScrollStop; } GetScrollBarPanel(oWindowDiv,oContentDiv,oScrollBar); return oScrollBar; } function ScrollBarMouseDown(e){ if(e==null){ e=event; } e.cancelBubble = true; var oElement = (e.target==null)?e.srcElement:e.target; var sId = (oElement.id!='')?oElement.id:oElement.parentNode.id; var sScrollBar = 'ScrollBar'; var sWindowDiv = sId.slice(0,sId.length-sScrollBar.length); var oScrollBarPanel = GetObject(sWindowDiv + 'ScrollBarPanel'); var y = e.clientY + document.body.scrollTop - LayerGetAbsoluteY(oElement); if(y > LayerGetY(oScrollBarPanel) + LayerGetH(oScrollBarPanel)){ ScrollDownI(sWindowDiv,20,false); } else{ ScrollUpI(sWindowDiv,20,false); } } function GetScrollBarPanel(oWindowDiv,oContentDiv,oScrollBar){ var oScrollBarPanel = GetObject(oWindowDiv.id + 'ScrollBarPanel'); if(oScrollBarPanel==null){ oScrollBarPanel = document.createElement('DIV'); oScrollBar.appendChild(oScrollBarPanel); oScrollBarPanel.id = oWindowDiv.id + 'ScrollBarPanel'; oScrollBarPanel.className = oWindowDiv.id + 'ScrollBarPanel'; oScrollBarPanel.onmousedown = ScrollPanelMouseDown; oScrollBar.bScroll_ = false; } LayerSetH(oScrollBarPanel,LayerGetH(oScrollBar)*(LayerGetH(oWindowDiv)-GetScrollBarW())/LayerGetH(oContentDiv)); LayerSetW(oScrollBarPanel,LayerGetW(oScrollBar)-2); return oScrollBarPanel; } var oScrollBarPanel_ = null; function ScrollPanelMouseDown(e){ if(e==null){ e=event; } e.cancelBubble = true; if(isLeftButton(e)){ var oElement = (e.target==null)?e.srcElement:e.target; oElement.bScroll_ = true; oElement.iOffsetY_ = e.clientY + document.body.scrollTop - LayerGetAbsoluteY(oElement); document.onmousemove = ScrollPanelDragEvent; document.onmouseup = ScrollPanelStopDragEvent; oScrollBarPanel_ = oElement; } } function ScrollPanelSetOffsetY(oScrollBarPanel,e){ oScrollBarPanel.iOffsetY_ = e.clientY + document.body.scrollTop - LayerGetAbsoluteY(oScrollBarPanel); } function ScrollPanelDragEvent(e){ if(e==null){ e=event; } e.cancelBubble = true; if(true || isLeftButton(e)){ var sScrollBar = 'ScrollBarPanel'; var sWindowDiv = oScrollBarPanel_.id.slice(0,oScrollBarPanel_.id.length-sScrollBar.length); var oWindowDiv = GetObject(sWindowDiv); var oContentDiv = LayerGetFirstChild(oWindowDiv,'div'); var oScrollBar = GetScrollBar(oWindowDiv,oContentDiv); var iMouseY = e.clientY + document.body.scrollTop - LayerGetAbsoluteY(oScrollBarPanel_); var dy = iMouseY - oScrollBarPanel_.iOffsetY_; var iNewY = LayerGetY(oScrollBarPanel_) + dy; SetScrollBarPosByValue(oScrollBar,oScrollBarPanel_,iNewY); ScrollToScrollBarPos(oWindowDiv,oContentDiv,oScrollBar,oScrollBarPanel_,dy>0); } return false; } function ScrollPanelStopDragEvent(e){ oScrollBarPanel_.bScroll_ = false; oScrollBarPanel_ = null; document.onmousemove = Nothing; document.onmouseup = Nothing; } function SetScrollBarPos(oWindowDiv,oContentDiv){ var oScrollBar = GetScrollBar(oWindowDiv,oContentDiv); var oScrollBarPanel = GetScrollBarPanel(oWindowDiv,oContentDiv,oScrollBar); var iContentDivY = -oWindowDiv.scrollTop; if(LayerGetY(oContentDiv)<0){ iContentDivY = LayerGetY(oContentDiv); } var iRelY = -iContentDivY/LayerGetH(oContentDiv); iScrollBarH = LayerGetH(oScrollBar); iNewY = iScrollBarH*iRelY; SetScrollBarPosByValue(oScrollBar,oScrollBarPanel,iNewY); } function SetScrollBarPosByValue(oScrollBar,oScrollBarPanel,iNewY){ iScrollBarH = LayerGetH(oScrollBar); iScrollBarPanelH = LayerGetH(oScrollBarPanel); if(iNewY<0){ LayerSetY(oScrollBarPanel,0); } else if(iScrollBarH > iNewY+iScrollBarPanelH){ LayerSetY(oScrollBarPanel,iNewY); } else{ LayerSetY(oScrollBarPanel,iScrollBarH-iScrollBarPanelH-2); } } function GetCurrentScrollY(oWindowDiv,oContentDiv){ var iContentDivY = -oWindowDiv.scrollTop; if(LayerGetY(oContentDiv)<0){ iContentDivY = LayerGetY(oContentDiv); } return iContentDivY; } function windowDivScrollEwent(e){ if(e==null){ e=event; } e.cancelBubble = true; var oWindowDiv = (e.target==null)?e.srcElement:e.target; var oContentDiv = LayerGetFirstChild(oWindowDiv,'div'); var oScrollBar = GetScrollBar(oWindowDiv,oContentDiv); var oScrollBarPanel = GetScrollBarPanel(oWindowDiv,oContentDiv,oScrollBar); if(!oScrollBarPanel.bScroll_){ SetScrollBarPos(oWindowDiv,oContentDiv); } } function ScrollToScrollBarPos(oWindowDiv,oContentDiv,oScrollBar,oScrollBarPanel,bDown){ iContentDivH = LayerGetH(oContentDiv); var iRelY = GetScrollBarPos(oScrollBar,oScrollBarPanel); var iNewY = iContentDivH*iRelY; var iCurrY = -GetCurrentScrollY(oWindowDiv,oContentDiv); var dy = iNewY - iCurrY; try{ if(dy>0 && bDown){ oWindowDiv.doScroll("scrollbarDown"); } else if(dy<0 && !bDown){ oWindowDiv.doScroll("up"); } } catch(x){ if(dy>=0 && bDown){ var iOffsetHeight = LayerGetH(oContentDiv) - LayerGetH(oWindowDiv) + GetScrollBarW(); if(iOffsetHeight<0){iOffsetHeight=0;} var iYleft = iOffsetHeight + LayerGetY(oContentDiv); if(true || iYleft>0){ if(iYleft<=dy){ LayerMoveTo(oContentDiv,null,-iOffsetHeight); } else{ LayerMoveBy(oContentDiv,null,-dy); } } } else if(dy<0 && !bDown){ if(LayerGetY(oContentDiv)>0 || LayerGetY(oContentDiv)>-dy){ LayerMoveTo(oContentDiv,null,0); } else{ LayerMoveBy(oContentDiv,null,-dy); } } } } function GetScrollBarPos(oScrollBar,oScrollBarPanel){ var iScrollBarPanelY = LayerGetY(oScrollBarPanel); var iScrollBarPanelH = LayerGetH(oScrollBarPanel); var iScrollBarH = LayerGetH(oScrollBar); var iRelY = iScrollBarPanelY/iScrollBarH; if(iScrollBarPanelY + iScrollBarPanelH >= iScrollBarH){ iRelY = 1; } return iRelY; } function ScrollUp(e){ if(e==null){ e=event; } e.cancelBubble = true; var oElement = (e.target==null)?e.srcElement:e.target; var sId = (oElement.id!='')?oElement.id:oElement.parentNode.id var sUp = 'Up'; var sWindowDiv = sId.slice(0,sId.length-sUp.length); ScrollUpI(sWindowDiv,20,true); } function ScrollUpI(sWindowDiv,iDY,bContinue){ var oWindowDiv = GetObject(sWindowDiv); var oContentDiv = LayerGetFirstChild(oWindowDiv,'div'); var iTimeout = 1; if(oContentDiv!=null){ try{ oWindowDiv.doScroll("up"); iTimeout = 100; } catch(x){ if(LayerGetY(oContentDiv)>0 || LayerGetY(oContentDiv)>-iDY){ LayerMoveTo(oContentDiv,null,0); bContinue = false; } else{ LayerMoveBy(oContentDiv,null,iDY); } } SetScrollBarPos(oWindowDiv,oContentDiv); if(bContinue){ aTimeout[aTimeout.length] = setTimeout("ScrollUpI('" + sWindowDiv + "'," + iDY + "," + true + ")",iTimeout); } } return false; } function ScrollDown(e){ if(e==null){ e=event; } e.cancelBubble = true; var oElement = (e.target==null)?e.srcElement:e.target; var sId = (oElement.id!='')?oElement.id:oElement.parentNode.id; var sDown = 'Down'; var sWindowDiv = sId.slice(0,sId.length-sDown.length); ScrollDownI(sWindowDiv,20,true); } function ScrollDownI(sWindowDiv,iDY,bContinue){ var oWindowDiv = GetObject(sWindowDiv); var oContentDiv = LayerGetFirstChild(oWindowDiv,'div'); var iTimeout = 1; if(oContentDiv!=null){ try{ oWindowDiv.doScroll("scrollbarDown"); iTimeout = 100; } catch(x){ var iOffsetHeight = LayerGetH(oContentDiv) - LayerGetH(oWindowDiv) + GetScrollBarW(); if(iOffsetHeight<0){iOffsetHeight=0;} var iYleft = iOffsetHeight + LayerGetY(oContentDiv); if(iYleft>0){ if(iYleft'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); } function makeArrowDown(oParentDiv){ var sColor = getCurrentStyle(oParentDiv,'color'); if(sColor==''){ sColor = '#FFFFFF'; } LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); LayerAddHTML(oParentDiv,'
'); }