﻿
var Scroll = function () { };
function stop(Scro) {
    clearTimeout(Scro.timer);
}
Scroll.prototype = {
    //第一个参数定义要滚动的区域,第二个参数定义每次滚动的高度
    initialize: function (element, height, delay) {

        this.element = document.getElementById(element);
        this.object = $("#" + element + " div");
        this.object.html(this.object.html() + this.object.html());
        this.height = height;
        this.delay = delay * 1000;
        this.maxHeight = this.element.scrollHeight-height;
        this.counter = 0;
        this.top = 0;
        scroll(this);
        this.timer = "";
        this.element.onmouseover = function () { clearTimeout(_Scroll.timer); clearTimeout(this.timer) };
        this.element.onmouseout = function () { this.timer = setTimeout("scroll(_Scroll)", 1000); };
    }
}
function scroll(Scro) {

    if (Scro.top < Scro.maxHeight) {
        //alert(Scro.maxHeight)
        Scro.top++;
        Scro.counter++;
        Scro.object.css("top", "-" + Scro.top + "px");
        } else {
        Scro.top=0;
        Scro.counter = 0;
        }

    if (Scro.counter < Scro.height) {
        Scro.timer = setTimeout("scroll(_Scroll)", 20);
        } else {
        Scro.counter = 0;
        Scro.timer = setTimeout("scroll(_Scroll)", Scro.delay);
        }
    }
   

  

