var btnArrowLeft = document.getElementById("btnArrowLt"); var btnArrowRight = document.getElementById("btnArrowRt"); //assign event handlers btnArrowLeft.onclick = scrollLt; btnArrowLeft.onmouseover = toggleLtArrow; btnArrowLeft.onmouseout = toggleLtArrow; btnArrowRight.onclick = scrollRt; btnArrowRight.onmouseover = toggleRtArrow; btnArrowRight.onmouseout = toggleRtArrow; var morePanel = document.getElementById("divBIFrame"); var arrMoreRows = morePanel.getElementsByTagName("div"); var moreItemWidth = 240; var morePos = morePanel.scrollLeft; var moreStart = 0; var moreEnd = moreItemWidth*(arrMoreRows.length-1); var moreLength = moreItemWidth; var moreIncrement = 10; var r, l; //set default left arrow to disabled btnArrowLeft.src = "/images/btnArrowLt_disabled.gif"; btnArrowLeft.style.cursor = "default"; if (arrMoreRows.length < 2) { btnArrowRight.src = "/images/btnArrowRt_disabled.gif"; btnArrowRight.style.cursor = "default"; } function scrollRt() { if ( (morePos < moreEnd) && (morePos < moreStart+moreLength) ) { morePos = morePos + moreIncrement; morePanel.scrollLeft = morePos; r = setTimeout(scrollRt, 1); } else { moreStart = morePanel.scrollLeft; clearTimeout(r); if (morePos > 0) { btnArrowLeft.src = "/images/btnArrowLt.gif"; btnArrowLeft.style.cursor = "pointer"; } if (morePos > (moreEnd-moreLength)) { btnArrowRight.src = "/images/btnArrowRt_disabled.gif"; btnArrowRight.style.cursor = "default"; } } } function scrollLt() { if ( (morePos > 0) && (morePos > moreStart-moreLength) ) { morePos = morePos - moreIncrement; morePanel.scrollLeft = morePos; l = setTimeout(scrollLt, 1); } else { moreStart = morePanel.scrollLeft; clearTimeout(l); if (morePos === 0 ) { btnArrowLeft.src = "/images/btnArrowLt_disabled.gif"; btnArrowLeft.style.cursor = "default"; } if (morePos < moreEnd) { btnArrowRight.src = "/images/btnArrowRt.gif"; btnArrowRight.style.cursor = "pointer"; } } } function toggleLtArrow(ev) { var imgPath; if (morePos === 0) { imgPath = this.src.substring(this.src.indexOf("/images"), this.src.length); if (imgPath !== "/images/btnArrowLt_disabled.gif") { this.src="/images/btnArrowLt_disabled.gif"; } } else { ev = ev || window.event; if (ev.type === "mouseover") { this.src="/images/btnArrowLt_over.gif"; } else if (ev.type === "mouseup") { this.src="/images/btnArrowLt_over.gif"; } else { this.src="/images/btnArrowLt.gif"; } } } function toggleRtArrow(ev) { var imgPath; if (morePos > (moreEnd-moreLength)) { imgPath = this.src.substring(this.src.indexOf("/images"), this.src.length); if (imgPath !== "/images/btnArrowRt_disabled.gif") { this.src="/images/btnArrowRt_disabled.gif"; } } else { ev = ev || window.event; if (ev.type === "mouseover") { this.src="/images/btnArrowRt_over.gif"; } else if (ev.type === "mouseup") { this.src="/images/btnArrowRt_over.gif"; } else { this.src="/images/btnArrowRt.gif"; } } }