/**
 * The "search" object is a single object used by CARGO Library.
 * It contains utility function for setting up Search widget in Cargo.
 * @title  CARGO
 * @module search
 * @author Jose Manuel Rodriguez CNIO-INB (jmrodriguez@cnio.es)
 * @version 2.0
 */

/**
 * search is an abstract base class.
 * @constructor
 * @param {Integer} iSearchId Search widget identifier
 * @param {XMLElement} oSearchElement Search widget description
 */
function search(iSearchId, oSearchElement)
{
	this.id = iSearchId;
	this._getProperties(oSearchElement); // Add search widget properties
};

search.prototype = {

/* ATTRIBUTES */

	/**
	* Unique identifier
	* @type Integer
	*/
	id: null,
	/**
	* Name of search widget
	* @type String
	*/
	name: null,
	/**
	* Description of search widget
	* @type String
	*/
	description: null,
	/**
	* URL of icon of search widget
	* @type String
	*/
	icon: null,
	/**
	* URL of search widget
	* @type String
	*/
	url: null,
	
/* 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;
	},
	/**
	* Add the properties of search object.
	* @private
	* @param {XMLElement} oXMLElement Search widget description
	*/
	_getProperties: function (oSearchElement)
	{
		var oConstant = new constant();
		var sPrefix = oConstant.xmlNamespaces['searchList'].p;
		this.name = Sarissa.getText(oSearchElement.selectSingleNode(sPrefix+":name"));
		this.url = Sarissa.getText(oSearchElement.selectSingleNode(sPrefix+":url"));
		this.description = Sarissa.getText(oSearchElement.selectSingleNode(sPrefix+":description"));
	},

/* Public METHODS */

	/**
	* Insert the HTML content of search widget into Search Panel
	* @param {String} sSearchBoardContent Element identifier of Search Panel
	*/
	addIFrameIntoSearchBoard: function (sSearchBoardContent)
	{
		document.getElementById(sSearchBoardContent).innerHTML = "<iframe frameborder='0' id='searchboard_iframe' class='searchboard_iframe' src='"+ this.url + "'></iframe>";
	}

};

