PaneManager = function() {
	this.currentElement = null;
}

PaneManager.prototype.clickDetected = function(obj)
{
	this.open(obj, false);
}

PaneManager.prototype.open = function(obj, skipAnim)
{
	if (this.currentElement != null && this.currentElement != obj && this.currentElement.status == 'open') {
		this.currentElement.close();
		this.currentElement = null;
	}

	if(obj.status == "open")
	{
		obj.close(skipAnim);
	}
	else
	{
		this.currentElement = obj;
		obj.open(skipAnim);
	}	
}


PaneOpen = function(idPane, heightOrig, heightFinal, time, status, associatedItem, baseClassName)
{

	this.idPane = idPane;
	this.heightOrig = heightOrig;
	this.heightFinal = heightFinal;
	this.status = status;
	this.associatedItem = associatedItem;
	this.baseClassName = baseClassName;

	YAHOO.util.Dom.addClass(associatedItem, baseClassName + "-" + status);

	this.close(true);
	
	var attributes_open = {   
		height: { to: heightFinal }
	};
	var attributes_close = {   
		height: { to: heightOrig }
	};
	this.anim_open = new YAHOO.util.Anim(idPane, attributes_open, time);
	this.anim_close = new YAHOO.util.Anim(idPane, attributes_close, time);
}

PaneOpen.prototype.clickDetected = function()
{

	/*
	if(this.status == "open")
	{
		this.status = "closed";
		YAHOO.util.Dom.replaceClass(this.associatedItem, this.baseClassName + "-open", this.baseClassName + "-closed");
		this.close();
	}
	else
	{
		this.status = "open";
		YAHOO.util.Dom.replaceClass(this.associatedItem, this.baseClassName + "-closed", this.baseClassName + "-open");
		this.open();
	}
	*/
}

PaneOpen.prototype.open = function(skipAnim)
{
	this.status = "open";
	YAHOO.util.Dom.replaceClass(this.associatedItem, this.baseClassName + "-closed", this.baseClassName + "-open");

	if (skipAnim == true) {
		YAHOO.util.Dom.setStyle(this.idPane, 'height', this.heightFinal + 'px');		
	} else {
		this.anim_close.stop();
		this.anim_open.animate();
	}
}

PaneOpen.prototype.close = function(skipAnim)
{
	this.status = "closed";
	YAHOO.util.Dom.replaceClass(this.associatedItem, this.baseClassName + "-open", this.baseClassName + "-closed");
	
	if (skipAnim == true) {
		YAHOO.util.Dom.setStyle(this.idPane, 'height', this.heightOrig + "px");		
	} else {
		this.anim_open.stop();
		this.anim_close.animate();
	}
}