var users = $H();

var User = Class.create({
	initialize: function(id, inert)
	{
		this.id = id;
		this.element = $("user-" + id);
		this.element.user = this;
		
		this.inert = inert;
		
		this.editor = this.element.parentNode == $("editors");
		this.grand = this.element.parentNode == $("grand")
		
		if (!this.editor && !this.grand)
		{
			new Draggable(this.element);
		}
	}
});

function dropped(draggable, droppable, event)
{
	draggable.user.editor = true;
}

function save()
{
	var parameters = (users.values().select(function (u) { return u.editor }).collect(function (u) { return "page[editors][]=" + u.id }).join("&"));
	
	$("loader").show();
	
	new Ajax.Request("/pages/" + page.id + "/editors", {parameters: parameters});
}