/////////////////////////////////////////////////////////////////////////////
// Function : BuscadorGeneral
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function BuscadorGeneral(strCgiUrl, strSiteId, strResultsPage, strButtonText, strTexto, strtipobusqueda)
{
	this.m_SiteId = -1;
	this.m_ResultsPage = "";
	this.m_ButtonText="Search";
	this.m_Textobuscado=strTexto;
	this.m_tipobusqueda=strtipobusqueda;


	this.m_FormName = "BuscadorGeneral";
	
	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;

	BuscadorGeneral.prototype.Display = BuscadorGeneral_Display;
	BuscadorGeneral.prototype.isTrue = BuscadorGeneral_isTrue;
}

function BuscadorGeneral_Display()	
{
	var ds = new Array();
	var di = 0;


	ds[di++] = '<form name="buscar" id="buscar" action="' + this.m_CgiUrl;
	ds[di++] = '" + method="get" + name="' + this.m_FormName + '">';
        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 + '">';
	var currentUrl = "" + window.location;
	
	// 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++] = '<div id="busca">';
        ds[di++] = '<div class="fonbus">';
        ds[di++] = '<span class="txt">Buscar </span>'
        ds[di++] = '<label>';
        ds[di++] = '<input name="ssUserText" type="text" accesskey="b" value="' + this.m_Textobuscado + '" id="busqueda" />';
        ds[di++] = '<span class="txt"> en </span>';
        ds[di++] = '<input name="tipobusqueda" type="radio" value="titulares"';
        if (this.m_tipobusqueda=="titulares"){
        	ds[di++] = 'checked="checked"';
        }
        ds[di++] = ' />';	
        ds[di++] = '<span class="txt"> titulares </span>';
        ds[di++] = '<input name="tipobusqueda" type="radio" value="contenidos"';           
        if (this.m_tipobusqueda=="contenidos"){
        	ds[di++] = 'checked="checked"';
        }
        ds[di++] = ' />';
        ds[di++] = '<span class="txt"> contenidos</span>';
	ds[di++] = '</div>';
	ds[di++] = '<div class="fonbus">';
        ds[di++] = '<input name="Buscar" type="submit" value="' + this.m_ButtonText + '" />';
        ds[di++] = '</label>';
        ds[di++] = '</div>';
        ds[di++] = '</form>';
        ds[di++] = '</div>';
        
        document.write(ds.join(''));
}

/////////////////////////////////////////////////////////////////////////////
// Function : isTrue
// Comments :
/////////////////////////////////////////////////////////////////////////////
function BuscadorGeneral_isTrue( boolStr )
{
	if( boolStr.length > 0 )
	{
		var boolChar = boolStr.substring(0,1).toUpperCase();
		if( ( boolChar == '1' ) || ( boolChar == 'T' ) )
		{
			return true;
		}
	}

	return false;
}
