var Dragger = Class.create();
Dragger.prototype = {
	initialize : function(option) {
		Object.extend(this, option);
		this.isDrag = false;
		this.targetElem = this.target.element;
		this.targetElem.setStyle({ position: "absolute" });
		this.src.setStyle({ cursor: "move" });
		this.attachMouseDownEventHandler();
		this.attachMouseUpEventHandler();
		this.attachMouseMoveEventHandler();
	},
	attachMouseDownEventHandler : function() {
		Event.observe(this.src, "mousedown", function(evt) {
			this.isDrag = true;
			this.startPos = {x: Event.pointerX(evt) - this.targetElem.offsetLeft,
				y : Event.pointerY(evt) - this.targetElem.offsetTop};
		}.bind(this));
	},
	attachMouseUpEventHandler : function() {
		Event.observe(document, "mouseup", function(evt) {
			this.isDrag = false;
		}.bind(this));
	},
	attachMouseMoveEventHandler : function() {
		Event.observe(document, "mousemove", function(evt) {
			Event.stop(evt);
			if(!this.isDrag) return;
			this.targetElem.setStyle({left : Event.pointerX(evt) - this.startPos.x + "px",
				top: Event.pointerY(evt) - this.startPos.y + "px" });
		}.bind(this));
	}
};