/*************************************************\
    功能       : 垂直跑馬燈
    版本       : 1.2
    適用瀏覽器 : >= IE 5, >= NS 6
    出產日期   : 2004/03/09
    作者       : gaga
    電郵1      : charles@ttnet.net
    電郵2      : charlemagnechen@pchome.com.tw

參考 roll1.htm , roll2.htm
new Roller(物件名, 高度, 滾動速度(毫秒), 停格時間(毫秒), 內容個數)
\*************************************************/
function Roller(nme, cHeight, rollspeed, waittime, total){
    this.nme = nme;
    this.cHeight = cHeight;
    this.rollspeed = rollspeed;
    this.waittime = waittime;
    this.total = total;
    this.pause_yn = 1;
    this.whichNext = "";
    
    this.start = start;
    this.rollgo = rollgo;
    this.rollpause = rollpause;
    
    function start(){
    	if (document.layers) {
    		document[this.nme+"a"].document.open();
    		document[this.nme+"a"].document.write("Suggest you upgrade to Netscape 7.1");
            document[this.nme+"a"].document.close();
        }else{
            //this.rollgo(1, this.cHeight);
            this.rollgo(1, 1);
        }
    }

    function rollgo(which,pos){
        if (this.pause_yn == 0){
            setTimeout(this.nme+".rollgo("+which+","+pos+")", 100);
            return;
        }
        if (which == this.total){
            this.whichNext = 1;    
        }else{
            this.whichNext = which*1+1;
        }

        pos -= 1;
        document.getElementById(this.nme+""+which).style.top = pos;
        document.getElementById(this.nme+""+this.whichNext).style.top = pos*1 + this.cHeight*1;

        if (pos == this.cHeight*-1){
            document.getElementById(this.nme+""+which).style.top = this.cHeight;
            which++;
            if (which > this.total) {
                which = 1;
            } 
            this.rollgo(which,1);
            return;
        }
        else if (pos == 0){
            setTimeout(this.nme+".rollgo("+which+",0)", this.waittime);
            return;    
        }
        else if (pos > this.cHeight*-1){
            setTimeout(this.nme+".rollgo("+which+","+pos+")", this.rollspeed);
            return;
        }
    }

    function rollpause(pause_ornot){
        this.pause_yn = pause_ornot; 
    }
}
