// For clarifications on the below script, please contact shine_cs@ncs.com.sg
// Release V1.1 - 22 Jan 2008 
// - - - 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 = 28;
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://sgms-web.internet.gov.sg/UIs/Feedback.aspx";

//Specify the Website's Contact Info URL here e.g. http://www.mywebsite.gov.sg/ContactInfo.html
var paramContactInfoPageURL ="http://sgms-web.internet.gov.sg/UIs/ContactInfo.aspx";


// Specify additional Collection options using the following //
Collections =
[
	["Within All Government Websites", "default"],
["Within This Website", "iac"],
["Within This Agency", "mom1"],
	["Within Business", "within_biz"],
	["Within Citizens And Residents", "within_cit_res"],
	["Within Non-Residents", "within_non_res"]

]

// Specify within this site (ie. sitesearch) options using the following //
// Only specify the website hosting this script
SiteSearchItems =
[	
	//["Results Within This Website", "www.iac.gov.sg"]
]

// - - - 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='0' style='background:transparent; border-collapse:collapse;' cellspacing='0' cellpadding='0'>");
	document.writeln("<tr><td><b><span style='font-size=12px'>Search </span></b></td><td align='left'>");
	document.writeln("<input type='text' name='q' size='"+ Search_Text_Box_Size + "'> ");
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' /></td></tr>"); 
	if (Collections != "")
	{
		var param_site_value = ""; //Do not remove

		document.writeln("<tr><td>&nbsp;</td><td><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='filter_s' value='" + param_site_value + "' /></td></tr>");
	}
	else
	{
		//Do not remove
		document.writeln("<input type='hidden' name='site' value='default' />");
	}

	//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>");
	
	if(SiteSearchItems != "")
	{
		var param_ssearch_value = ""; //Do not remove

		document.writeln("<tr><td align='right'colspan=2><a href='#' onclick=clearSelectedRadio('sitesearch'); class='fLink'>Clear Site Option</a>");
		for (i = 0; i < SiteSearchItems.length; i++)
		{
			document.writeln("<input type='radio' name='sitesearch' VALUE=" + SiteSearchItems[i][1] +"><span style='font-size:11px'>" + SiteSearchItems[i][0] + "</span>");

			//Do not remove
			param_ssearch_value += SiteSearchItems[i][0] + "#" + SiteSearchItems[i][1] + "|";
		}
		//Do not remove
		document.writeln("<input type='hidden' name='filter_ss' value='" + param_ssearch_value + "' />");
		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 ShowResults_MasterPage() {
    //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='0' style='background:transparent; border-collapse:collapse;' cellspacing='0' cellpadding='0'>");
    document.writeln("<tr><td><b><span style='font-size=12px'>Search </span></b></td><td align='left'>");
    document.writeln("<input type='text' id='q' name='q' size='" + Search_Text_Box_Size + "'> ");
    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' onClick='javascript: searchClick(this)' /></td></tr>");
    if (Collections != "") {
        var param_site_value = ""; //Do not remove

        document.writeln("<tr><td>&nbsp;</td><td><SELECT id='site' 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='filter_s' value='" + param_site_value + "' /></td></tr>");
    }
    else {
        //Do not remove
        document.writeln("<input type='hidden' id='site' name='site' value='default' />");
    }

    //document.writeln("<input type='submit' id='btnG' 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>");

    if (SiteSearchItems != "") {
        var param_ssearch_value = ""; //Do not remove

        document.writeln("<tr><td align='right'colspan=2><a href='#' onclick=clearSelectedRadio('sitesearch'); class='fLink'>Clear Site Option</a>");
        for (i = 0; i < SiteSearchItems.length; i++) {
            document.writeln("<input type='radio' name='sitesearch' VALUE=" + SiteSearchItems[i][1] + "><span style='font-size:11px'>" + SiteSearchItems[i][0] + "</span>");

            //Do not remove
            param_ssearch_value += SiteSearchItems[i][0] + "#" + SiteSearchItems[i][1] + "|";
        }
        //Do not remove
        document.writeln("<input type='hidden' name='filter_ss' value='" + param_ssearch_value + "' />");
        document.writeln("</td></tr>");
    }
    document.writeln("</table>");

    document.writeln("<input type='hidden' value='" + paramFeedbackPageURL + "' name='feedback_url' id='feedback_url' />");
    document.writeln("<input type='hidden' value='" + paramContactInfoPageURL + "' name='contact_url' id='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 searchClick(curform) 
{

    var varsite = document.getElementById("site").value; 
    var varcontacturl = document.getElementById("contact_url").value;
    var varfeedbackurl = document.getElementById("feedback_url").value;
    var varq = document.getElementById("q").value;

    window.open(Server_URL + ".aspx?q=" + varq + "&btnGo=Go&site=" + varsite + "&filter_s=Within+All+Government+Websites%23default%7CWithin+This+Website%23iac%7CWithin+This+Agency%23mom1%7CWithin+Business%23within_biz%7CWithin+Citizens+And+Residents%23within_cit_res%7CWithin+Non-Residents%23within_non_res%7C&feedback_url=" + varfeedbackurl + "&contact_url=" + varcontacturl + "&client=default&proxystylesheet=default&output=xml_no_dtd");

}
function clearSelectedRadio(radioId) 
{
    var x=document.getElementsByName(radioId); 
    for(i=0;i<x.length;i++){x[i].checked=false;}
    document.getElementById('btnG').focus();
}
