<!--
var Scroll_Div = function(name, e_div, e_title) {
// 使预制的 <div> 元素可拖动，并可同步滚动。
// 只须在 window.onscroll、window.onresize 中加入本对象的 .scroll() 方法即可。
// name：本对象的名；e_div：要滚动的主层元素；e_title：点击其上即可进行拖动的元素。

      var new_obj = new Object();
      new_obj.name = (name==null?"":name);                 // 对象名
      new_obj.root  = e_div;                               // 主层元素
      new_obj.drag_element = (e_title?e_title:null);       // 用于拖动的元素
      new_obj.isMoving = false;                            // 当前是否正在拖动
      new_obj.clickX = 0;                                  // 最初点击的水平位置
      new_obj.clickY = 0;                                  // 最初点击的垂直位置
      new_obj.oldT = 0;                                    // 原距顶位置
      new_obj.oldL = 0;                                    // 原距左位置

      new_obj.move = function(x, y) {
            this.oldL = x;
            this.oldT = y;
            this.open();
            this.scroll();
      }
      new_obj.open = function() {
            this.root.style.display = "block";
      }
      new_obj.close = function() {
            this.root.style.display = "none";
      }
      new_obj.getCoordinate = function(byObj, sw) {     // 获取指定元素的指定角（缺省：左上角）的坐标位置。
            sw = (sw?sw:"lt");                          // lt：左上角；lb：左下角；rt：右上角；rb：右下角。
            var e = byObj;
            var obj = new Object();
            obj.top  = 0;
            obj.left = 0;
            while (e) {obj.top += e.offsetTop; obj.left += e.offsetLeft; e = e.offsetParent;}
            if (sw.indexOf("r")>=0 || sw.indexOf("R")>=0) {    // 是右上角或右下角
                  obj.left += byObj.offsetWidth;
            }
            if (sw.indexOf("b")>=0 || sw.indexOf("B")>=0) {    // 是左下角或右下角
                  obj.top += byObj.offsetHeight;
            }
            return obj;
      }
      new_obj.hang = function(obj, left_offset, top_offset) {        // 将标签挂在指定元素之下。并进行一定的偏移。
            var coor = this.getCoordinate(obj, "FB");
            this.open();
            this.move( coor.left + (left_offset==null?0:left_offset), coor.top  + (top_offset==null?0:top_offset) );
      }
      new_obj.scroll = function() {          // 同步滚动
            if (!this.isMoving) {
                  if (this.oldT > document.body.clientHeight-this.root.offsetHeight) {
                        this.oldT = document.body.clientHeight - this.root.offsetHeight;
                  }
                  if (this.oldL > document.body.clientWidth-this.root.offsetWidth) {
                        this.oldL = document.body.clientWidth - this.root.offsetWidth;
                  }
                  if (this.oldT < 0) {this.oldT = 0;}
                  if (this.oldL < 0) {this.oldL = 0;}
                  this.root.style.left = document.body.scrollLeft + this.oldL;
                  this.root.style.top  = document.body.scrollTop  + this.oldT;
            }
      }
      new_obj.dragBegin = function(o) {               // 拖动控制面板开始
            this.isMoving = true;
            o.setCapture();                          // 锁定标题栏对象
            this.clickX = event.clientX;
            this.clickY = event.clientY;
      }
      new_obj.drag = function() {               // 拖动控制面板
            if (this.isMoving) {
                  var l = this.oldL + event.clientX - this.clickX;
                  var t = this.oldT + event.clientY - this.clickY;
                  if (t > document.body.clientHeight-this.root.offsetHeight) {
                        t = document.body.clientHeight - this.root.offsetHeight;
                  }
                  if (l > document.body.clientWidth-this.root.offsetWidth) {
                        l = document.body.clientWidth - this.root.offsetWidth;
                  }
                  if (t < 0) {t = 0;}
                  if (l < 0) {l = 0;}
                  this.root.style.left = document.body.scrollLeft + l;
                  this.root.style.top  = document.body.scrollTop  + t;
            }
      }
      new_obj.dragEnd = function(o) {               // 拖动控制面板结束
            if (this.isMoving) {
                  this.oldL = parseInt(this.root.style.left,10) - document.body.scrollLeft;
                  this.oldT = parseInt(this.root.style.top, 10) - document.body.scrollTop;
                  o.releaseCapture();           // 释放标题栏对象
                  this.isMoving = false;
            }
      }
      new_obj.init = function() {
            if (this.drag_element) {
                  this.drag_element.style.cursor = "move";
                  this.drag_element.onmousedown = new Function(this.name+".dragBegin(this);");
                  this.drag_element.onmouseup   = new Function(this.name+".dragEnd(this);");
                  this.drag_element.onmousemove = new Function(this.name+".drag();");
                  this.drag_element.title = "拖动菜单";
            }
            this.root.style.display = "block";
            this.root.style.position = "absolute";
            var curr_location = this.getCoordinate(this.root);
            this.oldT = curr_location.top  - document.body.scrollTop;
            this.oldL = curr_location.left - document.body.scrollLeft;
            this.scroll();
      }

      new_obj.init();
      if (new_obj.name!="") {eval(new_obj.name+"=new_obj");}
      return new_obj;
}

//-->