/////////////////////////////////////////////////////////////////////////////
// Function : aurorasearch
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function aurorasearch(strCgiUrl, strSiteId, strResultsPage, strSubmitButtonGraphic)
{
	this.m_CgiUrl = "";
	this.m_SiteId = -1;
	this.m_ResultsPage = "";
        this.m_SubmitButtonGraphic = "";

	this.m_FormName = "aurorasearch";
	
	if (strCgiUrl != '')
		this.m_CgiUrl = strCgiUrl;

	if (strSiteId != null)
		this.m_SiteId = strSiteId;

	if (strResultsPage != '')
		this.m_ResultsPage = strResultsPage;

	if (strSubmitButtonGraphic != '')
		this.m_SubmitButtonGraphic = strSubmitButtonGraphic;

	aurorasearch.prototype.Display = aurorasearch_Display;
	aurorasearch.prototype.isTrue = aurorasearch_isTrue;
}

function aurorasearch_Display()	
{
	var di = 0;
	
        document.write('<form action="' + this.m_CgiUrl);
	document.write('" + method="get" + name="' + this.m_FormName + '"');
	document.write('>');

	document.write('<input type=hidden name="IdcService" value="SS_GET_PAGE">');
	document.write('<input type=hidden name="siteId" value="' + this.m_SiteId + '">');
	document.write('<input type=hidden name="ssDocName" value="' + this.m_ResultsPage + '">');
	
	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) )
			{
				document.write('<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);
		}
		
		document.write('<input type=hidden name="previewId" value="' + value + '">');
	}
	
        document.write('<table border=0 cellspacing=0 cellpadding=0><tr><td valign="middle">');

        /********************************************/
        /************ TUTORIAL HYPERLINK ************/
        /********************************************/
	//if ( SSContributor )
	//{
	//	generateTutorialLink('aurorasearch', 'click here to learn more about the search box fragment');
	//}
        /********************************************/
        /************ TUTORIAL HYPERLINK ************/
        /********************************************/

        document.write('<tr><td colspan=2 valign="middle"><img src="groups/public/documents/photograph-image/023703.gif" alt="Search"></td><tr>');
	document.write('<tr><td valign="top"><input class = "aurorasearch" type=text name="ssUserText" height="25" size="15"; maxlength="100"></td>');
        document.write('<td height="25" valign="middle">');

	if (this.m_SubmitButtonGraphic.length >= 0)
	{
		document.write('&nbsp;<a class="btnlink" href="javascript:search..." onclick="' + this.m_FormName + '.submit();return false;"><img src="'+this.m_SubmitButtonGraphic+'" border=0 alt="Submit Search"></a>');
	}
	else
	{
	        document.write('&nbsp;<a class="btnlink" href="javascript:search..." onclick="' + this.m_FormName + '.submit();return false;">Go >></a>');
	}


        document.write('</td></tr></table>');
	document.write('</form>');
}

/////////////////////////////////////////////////////////////////////////////
// Function : isTrue
// Comments :
/////////////////////////////////////////////////////////////////////////////
function aurorasearch_isTrue( boolStr )
{
	if( boolStr.length > 0 )
	{
		var boolChar = boolStr.substring(0,1).toUpperCase();
		if( ( boolChar == '1' ) || ( boolChar == 'T' ) )
		{
			return true;
		}
	}

	return false;
}
