// For clarifications on the below script, please contact shine_cs@ncs.com.sg
// - - - Start - Configuration - Settings the Agency can modify - - - //
// All values passed to GSA must be URL-encoded. eg. spaces must be replaced by char '+'
var Search_Text_Box_Size = 23;
var Server_URL = "http://sgms.internet.gov.sg/search"; 
var Collections = "";
var SiteSearchItems = "";
var MetaDataFilters = "";

//Specify the Website's Feedback URL here e.g. http://www.mywebsite.gov.sg/feedback.html
//must have http:// as the start
var paramFeedbackPageURL ="http://www.agc.gov.sg/feedback/index.html";

//Specify the Website's Contact Info URL here e.g. http://www.mywebsite.gov.sg/ContactInfo.html
var paramContactInfoPageURL ="http://www.agc.gov.sg/contact/index.html";


// Specify additional Collection options using the following //
Collections =
[
	["Within All Government Websites", "default"],
	["Within AGC Website", "within_biz"]
]

// - - - End - Configuration - - - //


function ShowResults()
{
    //document.write("<style type='text/css' media='screen,print'>");
    //document.write("html,input,td{font-family:Arial;font-size:80%;}");
    //document.write("select{font-family:Arial;font-size:90%}");
    //document.write(".fLink{font-family: Arial;font-size: 11px;text-decoration: underline;color:Blue;cursor:hand;}")
    //document.write("</style>");

	document.writeln("<form method='GET' target='_blank' name='SearchPlugInfrm' action='" + Server_URL + "' >");
	/*
	document.writeln("<table border='2' style='background:transparent; border-collapse:collapse;' cellspacing='0' cellpadding='0'>");
	document.writeln("<tr><td>Search&nbsp;&nbsp;</td><td align='right'>");
	document.writeln("<input type='text' name='q' size='"+ Search_Text_Box_Size + "'> ");
	*/
	document.writeln("<input type='hidden' name='q' > ");
	
	if (Collections != "")
	{
		/*
		var param_site_value = ""; //Do not remove

		document.writeln("<SELECT name='site'>");
		for (i = 0; i < Collections.length; i++)
		{
			document.writeln("<OPTION VALUE=" + Collections[i][1] +">" + Collections[i][0]);

			//Do not remove
			param_site_value += Collections[i][0] + "#" + Collections[i][1] + '|';
		}
		document.writeln("</SELECT>");
		*/
		//Do not remove
		document.writeln("<input type='hidden' name='site' > ");
		document.writeln("<input type='hidden' name='filter_s' value='' />");
	}
	else
	{
		//Do not remove
		document.writeln("<input type='hidden' name='site' value='default_collection' />");
	}

	//document.writeln("<input type='submit' name='btnG' style='background-color:#c84141; font-size:85%; color:white; border:outset 1px #fff; width:30px; cursor:hand' value='Go' />"); 
	document.writeln("</td></tr>");
	document.writeln("</table>");

	document.writeln("<input type='hidden' value='" + paramFeedbackPageURL + "' name='feedback_url'  />");
	document.writeln("<input type='hidden' value='" + paramContactInfoPageURL + "' name='contact_url' />");
	document.writeln("<input type='hidden' name='client' value='default' />");
	document.writeln("<input type='hidden' name='proxystylesheet' value='default' />");
	document.writeln("<input type='hidden' name='output' value='xml_no_dtd' />");
	document.writeln("</form>");
}

function ShowForm()
{


	//document.writeln("<form method=post target='new1' onsubmit='SetDDValue(); ' action='"+ Server_URL+ "' name=SearchPlugInfrm style='margin:0' >");	
	//document.writeln("<input type=hidden name=XMLFlag value=false >");
	//document.writeln("<input type=hidden name=SearchSubmit value=Search>");
	document.writeln("<table border=0 cellspacing=1 cellpadding=0> <tr><td style='font-family:arial;font-size:10pt;color:#ffffff;'><b>Search</b></td><td nowrap>");
	document.writeln("<input type=text name=k size="+ Search_Text_Box_Size + " onkeydown='if(event.keyCode==13)return false'></td>");
	document.writeln("<td  valign='bottom'>");
	
	document.writeln("<a href='#' onclick='submitSearch()'><img name=SearchGo id=SearchGo src='http://mysearch.internet.gov.sg/images/header-button-go.gif'  value='Search' border='0' /></a>");
	
	//document.writeln("<input type=image valign='bottom' name=SearchGo id=SearchGo src='" + Server_HomePage + "/images/header-button-go.gif' value='Search' >");
	
	document.writeln("</td><td>");

	document.writeln("</td></tr><tr><td>&nbsp;</td><td colspan=3>");
	if (Collections != "")
	{
		var param_site_value = ""; //Do not remove

		document.writeln("<SELECT name='site'>");
		for (i = 0; i < Collections.length; i++)
		{
			document.writeln("<OPTION VALUE=" + Collections[i][1] +">" + Collections[i][0]);

			//Do not remove
			param_site_value += Collections[i][0] + "#" + Collections[i][1] + '|';
		}
		document.writeln("</SELECT>");
	document.writeln("<input type='hidden' name='filter_s' value='" + param_site_value + "' />");
	}
	document.writeln("</td></tr></table>");
	
	

	
	
	
	
}

function submitSearch()
{
	document.SearchPlugInfrm.q.value = document.forms[0].k.value;
	if (Collections != "")
	{
	document.SearchPlugInfrm.site.value = document.forms[0].site.value;
	document.SearchPlugInfrm.filter_s.value = document.forms[0].filter_s.value;	
	}
	document.SearchPlugInfrm.submit();
}

