﻿/*
** 2009-10-01 write for www.90jy.com
** Author:      linxi5167@hotmail.com
** Version:     1.0.0500
*/

        
        
        var tID;
        var tn;
        var nStopTime = 2000;
        var nSpeed = 50;
        var isMove = true;
        var nHeight = 20;
        var nS = 0;
        var nNewsCount = 0;

        var flag=1;

        function $get() { return document.getElementById(arguments[0]); }

        function getOs() {
            if (navigator.userAgent.indexOf("MSIE") > 0) return 1;
            if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) return 2;
            if (isSafari = navigator.userAgent.indexOf("Safari") > 0) return 3;
            if (isCamino = navigator.userAgent.indexOf("Camino") > 0) return 4;
            if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) return 5;
            return 0;
        }

        function getTopValue(parm) {
            if (getOs() == 1) {
                if (parm < -38)
                return (parm + 38) % nHeight == 0;
                else if (parm != -38) 
                return (parm - 2) % nHeight == 0;
            }
            else {
                if (parm != -35) {
                    if (parm < -18) {
                        return (parm - 5) % nHeight == 0;
                    }
                    else {
                        return (parm - 2) % nHeight == 0;
                    }
                }
            }
        }

        function getMax() {
            if (getOs() == 1) {
                return nNewsCount * nHeight * 2 - nHeight + 19;
            }
            else {
                return nNewsCount * nHeight * 2 - nHeight + 16;
            }
        }

        function getPos() {
            if (getOs() == 1) {
                return (nNewsCount - 1) * nHeight * -1 - 23;
            }
            else {
                return (nNewsCount - 1) * nHeight * -1 - 15;
            }
        }

        function moveT(n)
        {
            clearTimeout(tID);
            
            var noticev2 = document.getElementById("scrolltext");
            if (n) {
                noticev2.style.lineHeight = nHeight + "px";

                var theText = noticev2.innerHTML.toLowerCase();
                nNewsCount = theText.split("<li>").length - 1;    

                noticev2.innerHTML += "<br />" + noticev2.innerHTML; 
                
                tn = nHeight;
            }

            nS = nSpeed;
            if(isMove) {
                noticev2.style.marginTop = tn + "px";
                if (getTopValue(tn) == true) {
                    nS = nSpeed + nStopTime;
                }

                tn--;
                if (Math.abs(tn) == getMax()) {
                    tn = getPos();
                }
            }

            tID = setTimeout("moveT()", nS);
        }
        
        moveT(1);