/////////////////////////////////////////////////////////////////////////////
// Function : Discover_search_box
// Comments : 
/////////////////////////////////////////////////////////////////////////////

function Discover_search_box(strCgiUrl, strSiteId, strResultsPage, strButtonText, strClassName, strTextColor, strUserText)
{
	this.m_CgiUrl = "";
	this.m_SiteId = -1;
	this.m_ResultsPage = "";
	this.m_ButtonText="Search";
	this.m_ClassName  = 'Discover_search_box';
	this.m_TextColor  = '';
	this.m_UserText = '';

	this.m_FormName = "Discover_search_box";
	
	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 (strUserText != '')
		this.m_UserText = strUserText;
	
	Discover_search_box.prototype.Display = Discover_search_box_Display;
	Discover_search_box.prototype.isTrue = Discover_search_box_isTrue;
	
}

function Discover_search_box_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++] = '>';
	
	ds[di++] = '<table border="0" cellpadding="0" cellspacing="0" width="770" class="orange">';
    ds[di++] = '<tbody><tr><td>';
    ds[di++] = '<A HREF = "http://www.discoversimcoe.com"><img name="interface_header_r2_c1" src="http://calendar.county.simcoe.on.ca/partners/discoversimcoe/images/HT_interface_header_crop copy.jpg" border="0" alt=""></a></td>';   
       ds[di++] = '<td><img  style="padding: 0px 0px 0px 0px;" name="interface_header_r3_c7" src="http://calendar.county.simcoe.on.ca/partners/discoversimcoe/images/interface_header_r3_c7.jpg" border="0" alt=""></td> ';    


	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="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) )
			{
				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++] = '<td><input';
	ds[di++] = ' class = "' + this.m_ClassName + '"';

	if (this.m_TextColor != '')	
	{
		ds[di++] = ' style="color:' + this.m_TextColor + ';"';
	}	
	
	var trik = this.m_UserText.replace(/"/g, '&quot;');	
	ds[di++] = ' type=text name="ssUserText" id="searchinput" maxlength="100" size="5" value="' + trik + '"></td>';
	

	ds[di++] = ' <td><input';
	ds[di++] = ' class = "' + this.m_ClassName + '"';	

	if (this.m_TextColor != '')	
	{
		ds[di++] = ' style="color:' + this.m_TextColor + ';"';
	}	
	
	ds[di++] = ' type="image" name="interface_header_r3_c9" src="http://calendar.county.simcoe.on.ca/partners/discoversimcoe/images/interface_header_r3_c9.jpg" width="30" height="27" border="0"  alt=""></td>';

	
	
	ds[di++] = '</tr></tbody></table></form>';

	document.write(ds.join(''));
}

/////////////////////////////////////////////////////////////////////////////
// Function : isTrue
// Comments :
/////////////////////////////////////////////////////////////////////////////
function Discover_search_box_isTrue( boolStr )
{
	if( boolStr.length > 0 )
	{
		var boolChar = boolStr.substring(0,1).toUpperCase();
		if( ( boolChar == '1' ) || ( boolChar == 'T' ) )
		{
			return true;
		}
	}

	return false;
}
