/**
 * @projectDescription 层的拖动.
 * @author ice deng
 */
var DargMessageDiv = {
	lastX:0,
	lastY:0,
	moveDiv:new Object(),
	init:function(ev,obj){
		ev = ev?ev:window.event;
		var parentObj = obj;
		this.moveDiv = parentObj;
		try{
			var tmp = this.getInfo(parentObj);
			this.lastX= ev.clientX-tmp.left;
			this.lastY= ev.clientY-tmp.top;
		}catch(e){alerts(e);}
	
		document.onmousemove = function(event){
        	DargMessageDiv.move(event);
      	}
		
      	document.onmouseup = function(){
	        document.onmousemove = null;
	        document.onmouseup = null;
      	}
	},
	move:function(ev){
		try{
			ev = ev?ev:window.event;
		    var cx = ev.clientX;
			var cy = ev.clientY;
		    DargMessageDiv.moveDiv.style.left = cx - this.lastX +'px';
		    DargMessageDiv.moveDiv.style.top  = cy - this.lastY +'px';
		}catch(e){alerts(e);}
	},
	getInfo:function(o){
		var to=new Object();
		to.left=to.right=to.top=to.bottom=0;
		var twidth=o.offsetWidth;
		var theight=o.offsetHeight;
		while(o!=document.body){
			try{
				to.left+=o.offsetLeft;
				to.top+=o.offsetTop;
				o=o.offsetParent;
			}catch(e){break;}
		}
		to.right=to.left+twidth;
		to.bottom=to.top+theight;
		return to;
	}
}