// ************************************************************************************************
// *** Represents a drag item
// ************************************************************************************************

// Constructor
function DragItem(obj, resizeObj, min, max, direction) {
	// ************************************************************************************************
	// *** Interface
	// ************************************************************************************************

	// Fields
	// ******
	this.min = min;
	this.max = max;
	this.obj = obj;
	this.resizeObj = resizeObj;
	this.dragDirection = direction;
	this.isDragging = false;
	
	// Methods
	// *******
	this.dragged = di_Dragged;
	this.dragFinished = di_DragFinished;
	this.getValue = di_getValue;
	this.setValue = di_setValue;
	
	// Events
	// ******
	this.onDrag = new EventManager();
	this.onDragFinish = new EventManager();
	
	// ************************************************************************************************
	// *** Implementation
	// ************************************************************************************************
	
	// Called when the item is being dragged
	function di_Dragged() {
		this.onDrag.exec();
	}
	
	// Called when the drag finishes
	function di_DragFinished() {
		this.onDragFinish.exec();
	}
	
	// Returns a value between 0 and 1 that represents the position of the drag & drop item
	function di_getValue() {
		return parseInt(this.resizeObj.style.width) / this.max;
	}
	
	// Receive a value between 0 and 1 that represents the position of the drag & drop item
	function di_setValue(val) {
		this.resizeObj.style.width = (parseInt(val * this.max)) + 'px';
	}
}

// Drag direction constants
function DragDirection() {
	this.vertical = 1;
	this.horizontal = 2;
}