	
	
function DragDrop (id, move)
{
	this.BOOLMOVE = 0;
	this.id = id;
	this.move = move;
}

DragDrop.prototype = {
	init : function (parentobj)
	{
		if (!parentobj) parentobj = document.body;
		this.obj = getObj(this.id);
		this.parent = parentobj;
		
		var DD = this;
			/* addEvent(parentobj, 'mousedown', function (e) {DD.initMove(e)});	*/
			addEvent(this.obj, 'mousedown', function (e) {DD.initMove(e)});
		
		this._moveStart = function (e) {DD.moveStart(e)}
		this._moveStop = function (e) {DD.moveStop(e)}
		
		return false;
	},
	
	initMove : function (e) {
		
		Jss.textSelect(false);
		
		if(document.all) e = event;
		/* this.obj = this.obj.parentNode.appendChild(this.obj);	*/
		this.BOOLMOVE = 0;
		this.startMousePosX = e.clientX;
		this.startMousePosY = e.clientY;
		this.startPosElmX = this.obj.offsetLeft - this.parent.scrollLeft;
		this.startPosElmY = this.obj.offsetTop - this.parent.scrollTop;
		
		var DD = this;
		addEvent(document, 'mousemove', this._moveStart);
		addEvent(document, 'mouseup', this._moveStop);
		
		this.moveTime();
	},
	
	
	moveStart : function (e) {
		if(document.all) e = event;
			if(this.BOOLMOVE >= 10) {
				if (this.move) {
					if (this.move!='Y') this.obj.style.left = this.startPosElmX + e.clientX - this.startMousePosX + this.parent.scrollLeft + 'px';
					if (this.move!='X') this.obj.style.top = this.startPosElmY + e.clientY - this.startMousePosY + this.parent.scrollTop  + 'px';
				}
			}
			
		this.onMove();
	},
	
	
	moveTime : function () {
		var DD = this;
		
		if(this.BOOLMOVE >= 0 && this.BOOLMOVE<10) {
			this.BOOLMOVE++;
			setTimeout(function () {
				DD.moveTime();
			}, 20);
		}
	},


	moveStop : function () {
		this.BOOLMOVE = -1;
		
		var DD = this;
		delEvent(document, 'mousemove', this._moveStart);
		delEvent(document, 'mouseup', this._moveStop);
		
		Jss.textSelect(true);
		
		this.onMoveStop();
	},
	
	onMoveStop : function () {},
	onMove : function () {}
	
}