var iFrames = 0; var iSpeed = 100; var iPause = 4000; var iInterval = 2; var sDirection = "UP"; var iOver = 0; var m_iInterval; function StartPos() { // count all the frames var bNoneLeft = 0; var i = 0; var oCurFrame; if(document.getElementById("scroller")){ while(bNoneLeft == 0){ i++; var oCurFrame = document.getElementById("scroll-"+i); if(oCurFrame){ iFrames++; }else{ bNoneLeft = 1; } } if(iFrames == 0){return} //Position all frames i= 0; for(i=1;i<=iFrames;i++){ oCurFrame = document.getElementById("scroll-"+i); oCurFrame.style.position= "absolute"; oCurFrame.style.top = ((i-1)*parseInt(oCurFrame.height))+"px"; oCurFrame.style.left = "0px"; oCurFrame.onmouseover = oMouseOver; oCurFrame.onmouseout = oMouseOut; } m_iInterval = setInterval(ontimer, iPause); if(document.getElementById("scroll-up")){ document.getElementById("scroll-up").onmouseover = oUpOver; document.getElementById("scroll-up").onmouseout = oUpOut; } if(document.getElementById("scroll-down")){ document.getElementById("scroll-down").onmouseover = oDownOver; document.getElementById("scroll-down").onmouseout = oDownOut; } } } function ontimer() { oClearInt(); var i = 0; var iPauseIt = 0; var oLastFrame; var iLowest = 1000; var iHighest = -1000; var oCurFrame; for(i=iFrames;i>=1;i--){ oCurFrame = document.getElementById("scroll-"+i); if(sDirection == "UP"){ if(parseInt(oCurFrame.style.top) <= -parseInt(oCurFrame.height)) { iPauseIt = 1; oLastFrame = oCurFrame; }else{ oCurFrame.style.top = (parseInt(oCurFrame.style.top) - iInterval)+"px"; if(parseInt(oCurFrame.style.top) > iHighest){ iHighest = parseInt(oCurFrame.style.top); } } }else{ if(parseInt(oCurFrame.style.top) >= ((oCurFrame.height*iFrames)-oCurFrame.height)) { oLastFrame = oCurFrame; }else{ oCurFrame.style.top = (parseInt(oCurFrame.style.top) + iInterval)+"px"; if(parseInt(oCurFrame.style.top) < iLowest){ iLowest = parseInt(oCurFrame.style.top); } } } } if(sDirection == "UP"){ if(oLastFrame){ iHighest += parseInt(oLastFrame.height); oLastFrame.style.top = iHighest+"px"; } }else{ if(oLastFrame){ iLowest -= parseInt(oLastFrame.height); oLastFrame.style.top = iLowest+"px"; } } if(iPauseIt == 1 && iOver != 1){ m_iInterval = setInterval(ontimer, iPause); }else{ m_iInterval = setInterval(ontimer, iSpeed); } } function oMouseOver(){ oClearInt(); } function oMouseOut(){ oSetInt(); } function oUpOver(){ iInterval = 20; iOver = 1; } function oUpOut(){ iInterval = 2; iOver = 0; } function oDownOver(){ sDirection = "DOWN"; iInterval = 20; iOver = 1; } function oDownOut(){ sDirection = "UP"; iInterval = 2; iOver = 0; } function oSetInt(){ m_iInterval = setInterval(ontimer, iSpeed); } function oClearInt() { clearInterval(m_iInterval); } addLoadEvent(StartPos); //window.onload=StartPos;