function DragDecorator(subject) {
	this.subject = subject;
	this.subject.onmousedown = createContextFunction(this, "pickup");
}
DragDecorator.prototype.pickup = function (e) {
	e = (e) ? e : window.event;
	this.anchorX = e.clientX;
	this.anchorY = e.clientY;
	this.originX = calcX(this.subject);
	this.originY = calcY(this.subject);
/*
	this.ghost = this.subject.cloneNode(true);
	this.ghost.className = "dragged";
	this.ghost.style.left = this.originX+"px";
	this.ghost.style.top = this.originY+"px";
*/
	window.document.onmousemove = createContextFunction(this, "drag");
	window.document.onmouseup = createContextFunction(this, "drop");

//	this.ghost = document.body.appendChild(this.ghost);
	this.subject.style.cursor = "move";
}
DragDecorator.prototype.drag = function (e) {
	e = (e) ? e : window.event;
	this.subject.style.left = (this.originX + e.clientX - this.anchorX) + "px";
	this.subject.style.top  = (this.originY + e.clientY - this.anchorY) + "px";
}
DragDecorator.prototype.drop = function (e) {
	e = (e) ? e : window.event;
	window.document.onmousemove = null;
	window.document.onmouseup = null;
	this.subject.style.cursor = "default";
}
function calcX(o) {if (o) return o.offsetLeft + calcX(o.offsetParent); else return 0;}
function calcY(o) {if (o) return o.offsetTop + calcY(o.offsetParent); else return 0;}
function createContextFunction(context, method) {
	return (function(x){
		eval("context."+method+"(x)");
		return false;
    });
}
