function Drag(dragger,drag_content,$vars){
	
	var _this = this;
    _this.dragger = dragger;	
	if(drag_content == ''){
		_this.drag_content = dragger;
	}	else{
		_this.drag_content = drag_content;
	}
	_this.top_bound 	= 0;
	_this.right_bound 	= screen_width;
	_this.bottom_bound 	= screen_height;
	_this.left_bound 	= 0;
	
	if($vars){
		for(var a in $vars){
			if(a == "bounds"){
				var bound = $vars[a];
				_this.top_bound 	= bound[0];
				_this.right_bound 	= bound[1];
				_this.bottom_bound 	= bound[2];
				_this.left_bound 	= bound[3];
			}	else{
				_this[a] = $vars[a];
			}
		}
	}
	
	_this.detectEdgeClick = function(e){
		var edgeClick = "";
		_this.offsetEdge = 12;
		var offset = getOffsetMousePosition(_this.drag_content,e);		
		
		if(offset.y < _this.offsetEdge){
			edgeClick = "T";
		}
		if(_this.drag_content.offsetHeight - offset.y < _this.offsetEdge){
			edgeClick = "B";
		}
		if(offset.x < _this.offsetEdge){
			edgeClick = edgeClick+"L";
		}	
		if(_this.drag_content.offsetWidth - offset.x < _this.offsetEdge){
			edgeClick = edgeClick+"R";
		}

		switch(edgeClick){
			case 'T':
			_this.drag_content.style.cursor = 'n-resize';
			break;
			
			case 'B':
			_this.drag_content.style.cursor = 's-resize';
			break;	
			
			case 'R':
			_this.drag_content.style.cursor = 'e-resize';
			break;	
			
			case 'L':
			_this.drag_content.style.cursor = 'w-resize';
			break;
			
			case 'BL':
			_this.drag_content.style.cursor = 'sw-resize';
			break;
			
			case 'TL':
			_this.drag_content.style.cursor = 'nw-resize';
			break;
						
			case 'BR':
			_this.drag_content.style.cursor = 'se-resize';
			break;
						
			case 'TR':
			_this.drag_content.style.cursor = 'ne-resize';
			break;
						
			default:
			_this.drag_content.style.cursor = 'move';
			break;
		}
		return edgeClick;
		
	}
	

	_this.startDrag = function(e){
		
		_this.offset = getOffsetMousePosition(_this.drag_content,e);
		_this.edgeClick = _this.detectEdgeClick(e);
		if(_this.edgeClick != '' && _this["resizable"] == true){
			_this.initMousePos = getScreenMousePosition(e);
			_this.initDragContentPos = getElementPosition(_this.drag_content);
			_this.initDragContentSize = new Object();
			_this.initDragContentSize.w = _this.drag_content.offsetWidth;
			_this.initDragContentSize.h = _this.drag_content.offsetHeight;
			addEvent(document,	'mousemove', _this.goResize);
			addEvent(document,	'mouseup', _this.stopResize);
		}	else{
			if(_this["startCallback"]){
				_this["startCallback"].apply(this);
			}
			
			if(_this["container"]){
				var parentPos = getElementPosition(_this["container"]);
				_this.offset.x = _this.offset.x + parentPos.x;
				_this.offset.y = _this.offset.y + parentPos.y;
			}
			
			removeEvent(_this.dragger,	'mousedown', _this.startDrag);		
			addEvent(document,	'mousemove',	_this.goDrag);
			addEvent(document,	'mouseup',	_this.stopDrag);
		}
		
		disableTextSelection();
	}
	
	_this.goResize = function(e){
				
		var mouse_pos = getScreenMousePosition(e);
		var drag_content_pos = getElementPosition(_this.drag_content);
		
		var x_move = mouse_pos.x - _this.initMousePos.x;
		var y_move = mouse_pos.y - _this.initMousePos.y;
		var x_move_backward = _this.initMousePos.x-mouse_pos.x;
		var y_move_backward = _this.initMousePos.y-mouse_pos.y;		
		var new_w = _this.initDragContentSize.w+x_move;
		var new_h = _this.initDragContentSize.h+y_move;
		var new_w_backward = _this.initDragContentSize.w+x_move_backward;
		var new_h_backward = _this.initDragContentSize.h+y_move_backward;	
		
		if(_this.edgeClick.lastIndexOf('T') != -1){
			if(mouse_pos.y-_this.offset.y >  _this.top_bound && new_h_backward>=30){
				_this.drag_content.style.top = mouse_pos.y-_this.offset.y+'px';
				_this.drag_content.style.height = new_h_backward+'px';
			}		
		}
		if(_this.edgeClick.lastIndexOf('R') != -1){
			if(drag_content_pos.x+new_w <  _this.right_bound && new_w>=30){
			_this.drag_content.style.width = new_w+'px';
			}
		}		
		if(_this.edgeClick.lastIndexOf('B') != -1){
			if(_this.drag_content.offsetTop+new_h <  _this.bottom_bound && new_h>=30){
				_this.drag_content.style.height = new_h+'px';
			}
		}	 
		if(_this.edgeClick.lastIndexOf('L') != -1){
			if(mouse_pos.x-_this.offset.x >  _this.left_bound && new_w_backward>=30){
				_this.drag_content.style.left = mouse_pos.x-_this.offset.x+'px';
				_this.drag_content.style.width = new_w_backward+'px';
			}
		}		
		if(_this["dragCallback"]){
				_this["dragCallback"].apply(this);
		}
	}
	
	_this.stopResize = function(e){
		removeEvent(document,	'mousemove', _this.goResize);
		removeEvent(document,	'mouseup',	_this.stopResize);
		addEvent(_this.dragger,	'mousedown',	_this.startDrag);
		enableTextSelection();
		if(_this["stopCallback"]){
			_this["stopCallback"].apply(this);
		}	
	}
	
	_this.goDrag = function(e){
		
		if(_this["moveCallback"]){
			_this["moveCallback"].apply(this);
		}		
		var mouse_pos = getScreenMousePosition(e);
		_this.drag_content.style.left = Math.min(
												 Math.max(_this.left_bound , Math.round(mouse_pos.x - _this.offset.x)),
												 Math.round(_this.right_bound-_this.drag_content.offsetWidth)
												 ) +'px';
												
		_this.drag_content.style.top  = Math.min(
												 Math.max(_this.top_bound , Math.round(mouse_pos.y - _this.offset.y)),
												 Math.round(_this.bottom_bound-_this.drag_content.offsetHeight)
												 ) 
												+'px';
	}
	

	_this.stopDrag = function(e){
	
		removeEvent(document,	'mousemove', _this.goDrag);
		removeEvent(document,	'mouseup',	_this.stopDrag);
		addEvent(_this.dragger,	'mousedown',	_this.startDrag);
		
		enableTextSelection();
		
		if(_this["stopCallback"]){
			
			_this["stopCallback"].apply(this);
			
		}	
	}
	

	_this.destroy = function(){
		
		removeEvent(document,	'mousemove', _this.goDrag);
		removeEvent(document,	'mouseup',	_this.stopDrag);
		removeEvent(_this.dragger,	'mousedown', _this.startDrag);
		_this = null;
		
	}
	
	if(_this["resizable"]){
		addEvent(_this.dragger,	'mousemove', _this.detectEdgeClick);
	}
	
	addEvent(_this.dragger,	'mousedown', _this.startDrag);

}
