﻿
var delta=0.15;
var collection;
var closeB=false;
var smartwebtabletop=0;
var objtimespan=new Object();
//var documentBody = document.documentElement.clientHeight>0 ? document.documentElement : document.body; //兼容w3c标准

var documentBody;
var arrtimespan=new Array();

function floaters() {
  
  this.items = [];
  this.addItem = function(id)
      {
     if(!isie())
     {
       smartwebtabletop=document.getElementById('SmartWebTable').offsetTop;
     }
    
     documentBody = document.body;
     var obj=document.getElementById(id);
     var newItem    = {};
     newItem.object   = obj;
//     newItem.x    = obj.offsetLeft;
//     newItem.y    = obj.offsetTop;
     newItem.x    = obj.style.left.px();
     newItem.y    = obj.style.top.px();
     this.items[this.items.length]  = newItem;
      }
      this.play = function(id)
      {
         collection    = this.items
         var obj=new Object();
         obj.id=id;         
         obj.timespan=window.setInterval('play()',30);
         arrtimespan.push(obj);
      }
      this.stop=function(id)
      {
        if (collection==null)return;
        var obj=document.getElementById('m_'+id);
        
        for(var i=0;i<arrtimespan.length;i++)
        {
          //if (arrtimespan[i].id==id)
          //{
            //document.title+=arrtimespan[i].id;
            window.clearInterval(arrtimespan[i].timespan);
          //}
        }     
      }
      this.myreload=function(id)
      {
         if (collection==null)return;
        var obj=document.getElementById('m_'+id);
        for(var i=0;i<collection.length;i++)
        {
          if(collection[i].object.id=='m_'+id)
          {
             var newItem    = {};
             newItem.object   = obj;
             newItem.x    = obj.style.left.px();
             newItem.y    = obj.style.top.px()-documentBody.scrollTop;
             this.items[i]=newItem;
             collection    = this.items
          }
           theFloaters.play();
        }
      }
  }

  
  
  function play()
  {
   if(screen.width<=800 || closeB)
   {
    for(var i=0;i<collection.length;i++)
    {
     collection[i].object.style.display = 'none';
    }
    return;
   }
   for(var i=0;i<collection.length;i++)
   {
    var followObj  = collection[i].object;
    var followObj_x  = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
    var followObj_y  = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

	
//    if(followObj.offsetLeft!=(documentBody.scrollLeft+followObj_x)) {
//     var dx=(documentBody.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
//     dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
//     followObj.style.left=(followObj.offsetLeft+dx) + "px";
//     }    
   
    
    if(followObj.offsetTop!=(documentBody.scrollTop+followObj_y+smartwebtabletop)) {
    if (document.getElementById("control_title"))
    {
       ShowBorder(false);//在移动的时候，隐藏设计页面的跟踪表格
    }
     var dy=(documentBody.scrollTop+followObj_y-followObj.offsetTop+smartwebtabletop)*delta;
     dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
     followObj.style.top=(followObj.offsetTop+dy) + "px";
     }
    followObj.style.display = 'block';
   }
  }
  function closeBanner()
  {
   closeB=true;
   return;
  }

var theFloaters  = new floaters();



