<!--
var Floating = function(myname) {
// 使预制的元素飘动。

    var new_obj = new Object();
    new_obj.name             = (myname==null?"":myname);   // 对象名
    new_obj.floatingDelay    = 30;                         // 飘动延时
    new_obj.floatingElements = new Array();                // 飘动元素数组
    
    new_obj.add_floatingElement = function(e, t, l)              // 添加一个飘动元素，并使之从指定位置处开始飘动。
    {
        var f_obj = new Object();
        f_obj.root            = e;                       // 飘动元素
        f_obj.floatingStep    = 1;                       // 每次的飘动像素
        f_obj.floatingTop     = (t==null||t<0?0:t);      // 当前距顶像素
        f_obj.floatingLeft    = (l==null||l<0?0:l);      // 当前距左像素
        f_obj.topDirection    = 1;                       // 垂直飘动方向
        f_obj.leftDirection   = 1;                       // 水平飘动方向
        f_obj.floatingObject  = null;                    // 飘动对象
       
        f_obj.open = function()       // 打开（显示）当前元素飘动
        {
            this.root.style.display = "block";
        }
        f_obj.close = function()      // 关闭（隐藏）当前元素飘动，并停止飘动。
        {
            this.root.style.display = "none";
            this.stop();
        }
        f_obj.stop = function()      // 停止当前元素飘动
        {
            if (this.floatingObject) 
            {
                clearInterval(this.floatingObject);
                this.floatingObject = null;
            }
        }
        f_obj.floating = function()    // 当前元素飘动一次
        {
            var max_w = document.body.clientWidth;
            var max_h = document.body.clientHeight;
            var w = this.root.offsetWidth;
            var h = this.root.offsetHeight;
            this.floatingTop  += this.topDirection  * this.floatingStep;
            this.floatingLeft += this.leftDirection * this.floatingStep;
            if (this.floatingTop>=max_h-h)
            {
                this.floatingTop = max_h - h;
                this.topDirection = -1;
            }
            if (this.floatingTop<0)
            {
                this.floatingTop = 0;
                this.topDirection = 1;
            }
            if (this.floatingLeft>=max_w-w)
            {
                this.floatingLeft = max_w - w;
                this.leftDirection = -1;
            }
            if (this.floatingLeft<0)
            {
                this.floatingLeft = 0;
                this.leftDirection = 1;
            }
            this.root.style.top  = this.floatingTop  + document.body.scrollTop;
            this.root.style.left = this.floatingLeft + document.body.scrollLeft;
        }
        
        f_obj.root.style.display = "block";
        f_obj.root.style.position = "absolute";
        f_obj.floatingObject  = setInterval(this.name+".floatingElements["+this.floatingElements.length+"].floating()", this.floatingDelay);
        this.floatingElements[this.floatingElements.length] = f_obj;
    }
    new_obj.open = function(n)    // 打开（显示）指定飘动元素，并启动飘动。
    {
        if (n>=0 && n<this.floatingElements.length)
        {
            this.floatingElements[n].open();
            this.start(n);
        }
    }
    new_obj.close = function(n)    // 关闭（隐藏）指定飘动元素
    {
        if (n>=0 && n<this.floatingElements.length)
        {
            this.floatingElements[n].close();
        }
    }
    new_obj.start = function(n)    // 飘动指定元素
    {
        if (n>=0 && n<this.floatingElements.length)
        {
            if (this.floatingElements[n].floatingObject==null)
            {
                this.floatingElements[n].floatingObject = setInterval(this.name+".floatingElements["+n+"].floating()", this.floatingDelay);
            }
        }
    }
    new_obj.stop = function(n)    // 停止指定元素飘动
    {
        if (n>=0 && n<this.floatingElements.length)
        {
            this.floatingElements[n].stop();
        }
    }

    if (new_obj.name!="") {eval(new_obj.name+"=new_obj");}
    return new_obj;
}

//-->