
  /////////////////////////////////////////////////////
  //                                                 //
  //          C-NOOFS Forecast Viewer v0.6           //
  //               Web User Interface                //
  //                                                 //
  /////////////////////////////////////////////////////
  
/**
 * Creates a new visual box object
 * @param box_id DOM ID for the new box
 */
CollapseBox = function(box_id, box_title)
{
	this.container = document.createElement("div");
	this.container.className = "visualBox"
	this.container.id = box_id;

		var header = document.createElement("div");
		header.className = "hd";
		
			var MinMaxBtn = document.createElement("div");
			MinMaxBtn.className = "minimize";
			MinMaxBtn.id = box_id + "MinMaxBtn";
	
		header.appendChild(MinMaxBtn);
	
			var HeaderText = document.createElement("span");
			HeaderText.id = box_id + "HeaderText";
			HeaderText.innerHTML = box_title;

		header.appendChild(HeaderText);

	this.elHeader = new YAHOO.util.Element(header);	
	this.container.appendChild(header);
	
		var body = document.createElement("div");
		body.className = "bd";

	this.elBody = new YAHOO.util.Element(body);
	this.container.appendChild(body);
	
		var footer = document.createElement("div");
		footer.className = "ft";

	this.container.appendChild(footer);
	
	
	var MMB = new YAHOO.util.Element(MinMaxBtn);
	MMB.on("click", function()
	{
		if ( this.hasClass("minimize") )
		{
			this.replaceClass("minimize","maximize");
			body.style.display="none";
		}
		else
		{
			this.replaceClass("maximize","minimize");
			body.style.display="block";
		}				
	});
}

/**
 * HTMLElement which forms the foundation of this box
 * @type HTMLDivElement
 */
CollapseBox.prototype.container = {}

/**
 * YUI Element object representing the box's header
 * @type YAHOO.util.Element
 */
CollapseBox.prototype.elHeader = {}

/**
 * YUI Element object representing the box's body
 * @type YAHOO.util.Element
 */
CollapseBox.prototype.elBody = {}

/**
 * Array of rows in the table
 * @type array
 */
CollapseBox.prototype.rowset = [];
CollapseBox.prototype.numRows = 0;


/**
 * Create a new row, and append it to the body of the box
 * @param row_id Identifier to assign the new row (must be unique within current box)
 * @param element Element to store in the row
 */
CollapseBox.prototype.addRow = function(row_id,element)
{
 	this.rowset[row_id] = document.createElement("div");
 	this.rowset[row_id].id = this.container.id + "-" + row_id;

	var elNewRow = new YAHOO.util.Element(this.rowset[row_id]);
	elNewRow.addClass("cBoxRow");
	if ( this.numRows == 1) elNewRow.addClass("cBoxRowFirst");
	if ( this.numRows % 2 == 1 ) elNewRow.addClass("lightGray");
	
	this.rowset[row_id].appendChild(element);
	this.elBody.appendChild(this.rowset[row_id]);
	this.numRows++;
}

/**
 * Returns the container HTMLDivElement for the constructed box
 * @return HTMLDivElement
 */
CollapseBox.prototype.getContainer = function()
{
	return this.container;
}
