/////////////////////////////////////////////////////////////////////////////
// Function : BuscadorBox
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function BuscadorBox(strCgiUrl, strSiteId, strResultsPage, strButtonText, strClassName, strTextColor)
{
	this.m_CgiUrl = "";
	this.m_SiteId = -1;
	this.m_ResultsPage = "";
	this.m_ButtonText="Search";
	this.m_ClassName  = 'BuscadorBox';
	this.m_TextColor  = '';

	this.m_FormName = "BuscadorBox";
	
	if (strCgiUrl != '')
		this.m_CgiUrl = strCgiUrl;

	if (strSiteId != null)
		this.m_SiteId = strSiteId;

	if (strResultsPage != '')
		this.m_ResultsPage = strResultsPage;

	if (strButtonText != '')
		this.m_ButtonText = strButtonText;

	if (strClassName != '')
		this.m_ClassName = strClassName;

	if (strTextColor != '')
		this.m_TextColor = strTextColor;
	
	BuscadorBox.prototype.Display = BuscadorBox_Display;
	BuscadorBox.prototype.isTrue = BuscadorBox_isTrue;
}

function BuscadorBox_Display()	
{
	var ds = new Array();
	var di = 0;

    	ds[di++] = '<div class="fonbus">';
      	ds[di++] = '<div id="busca">';
	ds[di++] = '<form action="' + this.m_CgiUrl;
	ds[di++] = '" + method="get" + name="' + this.m_FormName + '"';
	ds[di++] = '>';

	ds[di++] = '<input type=hidden name="IdcService" value="SS_GET_PAGE">';
	ds[di++] = '<input type=hidden name="siteId" value="' + this.m_SiteId + '">';
	ds[di++] = '<input type=hidden name="nodeId" value="'+nid+'">';
	//ds[di++] = '<input type=hidden name="ssDocName" value="' + this.m_ResultsPage + '">';
	ds[di++] = '<input type=hidden name="tipobusqueda" value="titulares">';
	
	var currentUrl = "" + window.location;
	
	// Continue propagation of the "SSContributor" parameter
	if( SSContributor )
	{
		var paramName = "SSContributor=";
		var pos = currentUrl.indexOf( paramName );
		if( pos != -1 )
		{
			var subStr = currentUrl.substring( pos+paramName.length, pos+paramName.length+1 );
			if( this.isTrue(subStr) )
			{
				ds[di++] = '<input type=hidden name="SSContributor" value="true">';		
			}
		}
	}
	
	// Continue propagation of the "previewId" parameter
	var previewId = "previewId=";
	var posStart = currentUrl.indexOf( previewId );
	if( posStart != -1 )
	{
		var posEnd = currentUrl.indexOf("&", posStart);
		var value = "";
		if (posEnd == -1)
		{
			value = currentUrl.substring(posStart+previewId.length, currentUrl.length);
		}
		else
		{
			value = currentUrl.substring(posStart+previewId.length, posEnd);
		}
		
		ds[di++] = '<input type=hidden name="previewId" value="' + value + '">';		
	}
        ds[di++]='<label class="bustxt">Buscador</label>';
        ds[di++]='<br />';
	
	ds[di++] = '<label><input accesskey="b" value="" size=12';
	
	ds[di++] = ' type=text name="ssUserText" maxlength="100">';
	
	//ds[di++] = ' <input name="Buscar" size="20" ';
		
	//ds[di++] = ' type=submit value="' + this.m_ButtonText + '"> </label>';

        ds[di++] = ' <input type="image" id="botbus" title="Pulse para buscar" value="Buscar" src="laspalmas/img/interfaz/icos/buscar_bot.gif" alt="Pulse para buscar" style="border:0px solid;" />';
	ds[di++] = '</form>';
	ds[di++] = '</div>';
	ds[di++] = '</div>';

	document.write(ds.join(''));
}

/////////////////////////////////////////////////////////////////////////////
// Function : isTrue
// Comments :
/////////////////////////////////////////////////////////////////////////////
function BuscadorBox_isTrue( boolStr )
{
	if( boolStr.length > 0 )
	{
		var boolChar = boolStr.substring(0,1).toUpperCase();
		if( ( boolChar == '1' ) || ( boolChar == 'T' ) )
		{
			return true;
		}
	}

	return false;
}
