// 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 = 20;
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://app.mof.gov.sg/feedback.aspx";

//Specify the Website's Contact Info URL here e.g. http://www.mywebsite.gov.sg/ContactInfo.html
var paramContactInfoPageURL ="http://app.mof.gov.sg/contact_info.aspx";

// Specify additional Collection options using the following //
Collections =
[
	["Ministry of Finance", "mof"],
	["Within All Singapore Gov Websites", "default"]
]
// - - - End - Configuration - - - //

function Search() {
	window.open(Server_URL + "?q=" + escape(document.forms[0].q.value) + "&site=" + escape(document.forms[0].site.value) + "&filter_s=" + escape(document.forms[0].filter_s.value) + "&feedback_url=" + escape(document.forms[0].feedback_url.value) + "&contact_url=" + escape (document.forms[0].contact_url.value) + "&client=" + escape(document.forms[0].client.value) + "&proxystylesheet=" + escape(document.forms[0].proxystylesheet.value) + "&output=" + escape(document.forms[0].output.value) + "&SearchGo.x=6&SearchGo.y=8");

	//document.forms[0].action = Server_URL;
	//document.forms[0].method = "GET";
	//document.forms[0].target = "_blank";
	//document.submit();
}
function isEnter(e) {
	e= e || window.event || {};
    var charCode = e.charCode || e.keyCode || e.which;
    if (charCode == 13) {
		return true;
	}
	return false;
}
function ShowResults()
{
//	document.writeln("<form method='GET' target='_blank' name='SearchPlugInfrm' action='" + Server_URL + "' style='margin:0'>");
	document.writeln("<table width='451' border='0' align='right' cellpadding='4' cellspacing='0'>");
	document.writeln("<tr>");
	document.writeln("<td width='49' class='header_grey_bold'>Search </td>");
	document.writeln("<td width='167' background='images/search_bg.jpg'>");
	document.writeln("<table width='167' height='20' border='0' cellpadding='0' cellspacing='0'>");
	document.writeln("<tr>");
	document.writeln("<td width='141'><input type='text' name='q' class='transItems' style='width:139px;border:0px;' onkeypress=\"javascript:if(isEnter(event)) {Search();return false;}\"></td>");
	document.writeln("<td width='26'><a href='javascript:Search();' id='btnSgmssearch'><img src='images/btn_search.jpg' width='19' height='20' border='0' alt='Search'></a></td>");
	document.writeln("</tr>");
	document.writeln("</table>");
	document.writeln("</td>");
	document.writeln("<td width='1'>&nbsp;</td>");
	document.writeln("<td width='202' background='images/dropdown_bg.jpg'>");
	document.writeln("<table width='100' border='0' align='center' cellpadding='0' cellspacing='0'>");
	document.writeln("<tr>");
	document.writeln("<td>");
	if (Collections != "")
	{
		var param_site_value = ""; //Do not remove
		//document.writeln("<SELECT name='site'>");
		document.writeln("<select id='drop' name='site' class='transItems'>");
		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='filter_s' value='" + param_site_value + "' />");
	}
	else
	{
		//Do not remove
		document.writeln("<input type='hidden' name='site' value='default_collection' />");
	}
	document.writeln("</td>");
	document.writeln("</tr>");
	document.writeln("</table>");
	document.writeln("</td>");
	document.writeln("</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>");
}