/**
 * The "inputboard" object is a single object used by CARGO Library.  It
 * contains utility function for setting up the visualization of selected genes.
 * @title  CARGO
 * @module inputboard
 * @author Jose Manuel Rodriguez CNIO-INB (jmrodriguez@cnio.es)
 * @version 2.0
 */

/**
 * inputboard is an abstract base class.
 * @constructor
 * @param {String} sContainerName "div" identifier of HTML Element that will be contain dashboard panel
 */
function inputboard(sContainerName)
{
	this._createElementContainer(sContainerName, this.name, this.name); // Create "div" of inputboard Element
	this._createElementContainer(this.name, this.content, this.content); // Create "div" of inputboard content

	// Create "div" of inputboard tab
	var oDivMainTab = this._createElementContainer(this.name, this.tab, this.tab);
	oDivMainTab.onclick = function() { cargo.inputboard._expandSearchBoard("inputboard_tab"); } // Add onClick event to tab
	this._createElementContainer(this.tab, "inputboard_tab_left_border", "inputboard_tab_left_border");
	this._addInputboardTabs();
	this._createElementContainer(this.tab, "inputboard_tab_right_border", "inputboard_tab_right_border");
};

inputboard.prototype = {

/* ATTRIBUTES */

	/**
	* Unique identifier
	* @type Integer
	*/
	id: null, // ???????
	/**
	* The name of inputboard
	* @type String
	*/
	name: "inputboard",
	/**
	* The "div" name of inputboard content
	* @type String
	*/
	content: "inputboard_content",
	/**
	* The "div" name of inputboard tab
	* @type String
	*/
	tab: "inputboard_tab",
	/**
	* The minimum size of inputboard
	* @type Integer
	*/
	minSize: 6,
	/**
	* The maximum size of inputboard
	* @type Integer
	*/
	maxSize: 200,
	/**
	* Current size of inputboard
	* @type Integer
	*/
	size: this.maxSize,
	/**
	* Flag that controls if inputboard is expanded. True by default.
	* @type Boolean
	*/
	expanded: true,


/* Private METHODS */

	/**
	* Create "div" element
	* @private
	* @param {String} sContainerName Name of "div" container
	*/
	_createElementContainer: function (sDivContainerName, sDivId, sDivClass)
	{
		var oDivSearchBoard = document.createElement("div");
		oDivSearchBoard.setAttribute("id", sDivId);
		oDivSearchBoard.setAttribute("class", sDivClass);
		document.getElementById(sDivContainerName).appendChild(oDivSearchBoard);
		return oDivSearchBoard;
	},
	/**
	* Create Inputboard tab
	* @private
	*/
	_addInputboardTabs: function ()
	{
		var oDivInputBoardTabText = document.createElement("img");
		oDivInputBoardTabText.setAttribute("id", "inputboard_tab_text");
		oDivInputBoardTabText.setAttribute("class", "inputboard_tab_text");
		oDivInputBoardTabText.setAttribute("src", "scripts/rotateText.cgi?text=Selected Gene&degrees=0");
		document.getElementById(this.tab).appendChild(oDivInputBoardTabText);
		return oDivInputBoardTabText;
	},
	/**
	* Event that contract to expand and vice versa.
	* @private
	*/
	_expandSearchBoard: function (sId)
	{
		if (this.expanded)
		{
			this.expanded = false;
			document.getElementById(this.name).style.height = 29 + "px";
			document.getElementById(this.tab).style.top = 10 + "px";
			document.getElementById(this.content).style.display = "none";
			document.getElementById(this.content).style.opacity = 0;
		}
		else
		{
			this.expanded = true;
			document.getElementById(this.name).style.height = 99 + "px";
			document.getElementById(this.tab).style.top = 80 + "px";
			document.getElementById(this.content).style.display = "block";
			document.getElementById(this.content).style.opacity = 1;
		}
	},
	
/* Public METHODS */
	
	/**
	* Print the input description into respective panel.
	* @param {String} sInputDesc Input Description
	*/
	printInputDescription: function(sInputDesc)
	{
		document.getElementById(this.content).style.display = 'block';
		document.getElementById(this.content).innerHTML = sInputDesc;
	}
};

