/******************************************************
 *
 * This script was written for
 * http://other.lookstrike.com
 *
 * If you plan to use it for your own, you can but you
 * MUST leave this whole comment intact in each file.
 *
 * Copyright		: (C) Jean-Sébastien Goupil - 2006-2008
 * Website		: http://other.lookstrike.com
 *
 ******************************************************/

function DynamicGroup() {
	this.init();
}

DynamicGroup.prototype = {
	init: function() {
		this.groupDragging = "";
		this.dynamicDragActive = null;
		this.dynamicDropActive = null;
		// dynamicDragActive must implement "DragAccepted", "DragRefused", "DragLost" and "GetGroup"
		// dynamicDropActive must implement "DragReleased".
	},

	startDrag: function(obj) {
		this.dynamicDragActive = obj;
		this.groupDragging = this.dynamicDragActive.GetGroup();
	},

	endDrag: function() {
		if(this.dynamicDropActive != null) {
			if(this.dynamicDropActive.DragReleased(this.dynamicDragActive) == true) {
				this.dynamicDragActive.DragAccepted(this.dynamicDropActive);
			} else {
				this.dynamicDragActive.DragRefused(this.dynamicDropActive);
			}
		} else {
			this.dynamicDragActive.DragLost();
		}
		this.dynamicDragActive = null;
		this.groupDragging = "";
	},

	startDrop: function(obj) {
		this.dynamicDropActive = obj;
	},

	endDrop: function() {
		this.dynamicDropActive = null;
	},

	groupDrag: function() {
		return this.groupDragging;
	}
}

var oDynamicGroup = new DynamicGroup();