/////////////////////////////////////////////////////////////////////////////
// Function : ComSearchBoxInclude
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function ComSearchBoxInclude(strCgiUrl, strSiteId, strResultsPage, strButtonText, strClassName, strTextColor,strPrefix)
{ 
	this.m_CgiUrl = "";
	this.m_SiteId = -1;
	this.m_ResultsPage = "";
	this.m_ButtonText=(isSpanish ? "Buscar" : "Search");
	this.m_ClassName  = 'ComSearchBoxInclude';
	this.m_TextColor  = '';
	this.strPrefix  = '';

	this.m_FormName = "ComSearchBoxInclude";
	
	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;

	if (strPrefix != '')
		this.strPrefix = strPrefix;
	
	ComSearchBoxInclude.prototype.Display = ComSearchBoxInclude_Display;
	ComSearchBoxInclude.prototype.isTrue = ComSearchBoxInclude_isTrue;
}

function ComSearchBoxInclude_Display()	
{
	var ds = new Array();
	var di = 0;
	
	ds[di++] = '<form action="' + this.m_CgiUrl;
	ds[di++] = '" + method="get" + name="' + this.m_FormName + '"';
	ds[di++] = '>';

	
	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++] = '<input  type="text"';

	//ds[di++] = ' class = "' + this.m_ClassName + '"';
	//ds[di++] = ' class = "' + this.m_ClassName + '"';
	//ds[di++] = ' class = "searchBox" name="searchInput"';	
	if (this.m_TextColor != '')	
	{
		ds[di++] = ' style="color:' + this.m_TextColor + ';"';
	}	
	
	if(this.strPrefix !='crs'){
		ds[di++] = ' name="searchString" id="searchString" maxlength="100"><br>';
	}else{
		ds[di++] = ' name="searchString" id="searchString" maxlength="100" style="width: 145px;"><br>';
	}


	if (isSpanish) {
		if(this.strPrefix !='crs'){
			ds[di++] = '<input type="image" src="' + g_HttpRelativeWebRoot + 'groups/jsp/documents/webcontent/sp_btn_search.gif" width="67" height="20" alt="' + this.m_ButtonText + '" border="0" class="searchBtn"';
			}else{
			ds[di++] = '<input type="image" src="' + g_HttpRelativeWebRoot + 'groups/jsp/documents/webcontent/sp_btn_search_crs.gif" width="66" height="19" alt="' + this.m_ButtonText + '" border="0" style="margin-top: 10px;"';
		}
	} else {

		if(this.strPrefix !='crs'){
			ds[di++] = '<input type="image" src="' + g_HttpRelativeWebRoot + 'groups/jsp/documents/webcontent/btn_search.gif.gif" width="67" height="20" alt="' + this.m_ButtonText + '" border="0" class="searchBtn"';
		}else{

			ds[di++] = '<input type="image" src="' + g_HttpRelativeWebRoot + 'groups/jsp/documents/webcontent/btn_search_crs.gif" width="66" height="19" alt="' + this.m_ButtonText + '" border="0" style="margin-top: 10px;"';
	}
	}

	//ds[di++] = ' class = "' + this.m_ClassName + '"';	

	if (this.m_TextColor != '')	
	{
		ds[di++] = ' style="color:' + this.m_TextColor + ';"';
	}	
	
	ds[di++] = ' type=submit value="' + this.m_ButtonText + '">';
	
	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="' + this.m_ResultsPage + '">';


	ds[di++] = '</form>';

	//(ds.join(''));
	document.write(ds.join(''));
}
/////////////////////////////////////////////////////////////////////////////
// Function : isTrue
// Comments :
/////////////////////////////////////////////////////////////////////////////
function ComSearchBoxInclude_isTrue( boolStr )
{
	if( boolStr.length > 0 )
	{
		var boolChar = boolStr.substring(0,1).toUpperCase();
		if( ( boolChar == '1' ) || ( boolChar == 'T' ) )
		{
			return true;
		}
	}

	return false;
}

