// JavaScript Document

//添加跟滚动条滚动的层
/*
使用例子
var D = Js_DOM
D.move(id)    /(例对象具有可移动性)/id为须要移动的对象ID或本身
D.hidden(id)  /(隐藏显示对象)/
*/
function Js_DOM()
{
    var   currentMoveObj   =   null;         //当前拖动对象   
  	var   relLeft;         //鼠标按下位置相对对象位置   
  	var   relTop;   
	var   obj_self = this;
//////////主调函数//////////////////////////////////////////////////
     //功能一对象移动
    this.move = function(id,top,left)
	{
	    var obj = $(id);
		var top = top;
		var left = left;
		obj.style.position   =   "absolute";
		obj.style.top = obj.offsetTop;       //获取控的位置
		obj.style.left = obj.offsetLeft;
        obj.attachEvent("onmousedown",function(){obj_self.m_down(obj)});
        obj.attachEvent("onmousemove",function(){obj_self.m_move()});
        obj.attachEvent("onmouseup",function(){obj_self.m_up()});
	}
	
	//功能二对象隐藏
	this.hidden = function(id)
	{
		var obj = $(id);
		if(obj!=null){
		    if(obj.style.display=="none"){
			   obj.style.display="";
			}else{
			   obj.style.display="none";
			}
		}
	 }
	 
	 this.createHtml = function(tagName,id)     //建HTML标签并追加到指定对象 
	 {
		var html_obj = document.createElement(tagName);
		html_obj.style.position   =   "absolute";
        //oDiv.id = "dialogCase";
		if(id!=undefined){
			var append_obj = $(id)
		    append_obj.appendChild(html_obj);
		}else{
		    document.body.appendChild(html_obj);
		}
		return html_obj;
	 }
/////////次调函数////////////////////////////////////////////////////
	this.m_down = function(obj){
    	currentMoveObj   =   obj;                 //当对象被按下时，记录该对象  
        currentMoveObj.style.position   =   "absolute";   
        relLeft   =   event.x   -   currentMoveObj.style.pixelLeft;   
        relTop   =   event.y   -   currentMoveObj.style.pixelTop; 
	}
	this.m_move = function(){
      	if(currentMoveObj   !=   null){ 
        	currentMoveObj.style.pixelLeft=event.x-relLeft;   
         	currentMoveObj.style.pixelTop=event.y-relTop;   
      	}   
	}
	this.m_up = function(){
	    currentMoveObj   =   null;	
	}
	
}
var D = new Js_DOM();
