// - - - Start - Configuration - Settings the Agency can modify - - - //
var Enable_Search_Within_This_Site = true;
var Enable_Search_Within_Agency = false;
var Results_Per_Page = 10;
var Search_Text_Box_Size = 25;
var Server_URL = "http://sgms.internet.gov.sg/search";
var Server_HomePage = "http://sgms.internet.gov.sg/";
var Banner = "";
var AdditionalDropDownItems = "";
var Catalogue = "";
var Collections = "";
var SiteSearchItems = "";
var MetaDataFilters = "";

// Change the following paramter manually if its not desirable to get the website domain automatically.
var URLStr = "http://www.ida.gov.sg";


//Specify the Website's Feedback URL here e.g. www.mywebsite.gov.sg/feedback.html
var paramFeedbackPageURL="http://www.ida.gov.sg/General/Feedback.aspx";

//Specify the Website's Contact Info URL here e.g. www.mMywebsite.gov.sg/ContactInfo.html
var paramContactInfoPageURL="http://www.ida.gov.sg/General/ContactInfo.aspx";


// Specify additional drop down options using the following //
AdditionalDropDownItems =
[
	//["Within Citizens & Residents", 'I80VNN4VY:AUDIENCE_CODES'],
	//["Within Business", "I80Y14E8Z:AUDIENCE_CODES"],
	//["Within Non-Residents", 'I80VOSC4S:AUDIENCE_CODES']
]

Collections =
[	
	["Within This Website" , "ida1"],
 	["Within IDA-Related Websites ", "ida"],
	["Within All Singapore Gov Websites", "default"]
]

// Specify additional Catalgoue options using the following //
Catalogue =
[
 ["Within IDA-Related Websites", "139"]
]
// - - - End - Configuration - - - //


// - - - Start - Configuration - Debug Settings - - - //

var SplitResTry;


// - - - End - Configuration - - -//


function enableSearchWithInSite()
{
	return Enable_Search_Within_This_Site;
}

function enableSearchWithInAgency()
{
	return Enable_Search_Within_Agency;
}

function SetResultsPerPage()
{
	return Results_Per_Page;
}

var mtr = 0
function checkInputIsEmpty(){
	if (document.all.TextBoxSearch.value.replace(/^(\s+)?(.*\S)(\s+)?$/, '$2') == "") {
		mtr = 1
	}
	else mtr = 0
}

function SetDDValue()
{
	var varCombo = "";
	var combo = document.forms[0].drop
	for ( i=0;i<combo.options.length;i++)
	{
		varCombo = varCombo + "^" + combo.options[i].text + "," + combo.options[i].value + ",";
		if (i == combo.options.selectedIndex)
			varCombo = varCombo + "SELECTED"
		var varTemp = ",";
		for(j=0;j<AdditionalDropDownItems.length;j++)
		{
			if (AdditionalDropDownItems[j][0] == combo.options[i].text)
			varTemp = "," + AdditionalDropDownItems[j][1];
		}
		varCombo = varCombo + varTemp;
		for(j=0;j<Catalogue.length;j++)
		{
			if (Catalogue[j][0] == combo.options[i].text)
				varTemp = "CATalogue";
		}
		varCombo = varCombo + varTemp;
	}
	document.forms[0].iNPUTcombo.value = varCombo;
}

function ShowResults()
{
    document.write("<style type='text/css' media='screen,print'>");
    document.write("html,input,td{font-family:Arial;font-size:85%;}");
    document.write("select{font-family:Arial;font-size:85%;width:195px;}");
    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='new1' name='SearchPlugInfrm' action='" + Server_URL + "' >");
	document.writeln("<table border='0' style='background:transparent; border-collapse:collapse;' cellspacing='0' cellpadding='0'>");
	document.writeln("<tr><td><p style='font-family:Arial;font-size:85%;color:white; font-weight:bold;' >Search&nbsp;&nbsp;</p></td><td Height='25px' >");
	document.writeln("<input type='text' name='q' size='" + Search_Text_Box_Size +  "'  />&nbsp; ");
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><tr><td></td><td colspan='2' >");

	if (Collections != "")
	{
		var param_site_value = ""; //Do not remove

		document.writeln("<SELECT name='site' Width='20'>");
		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' />");
	}

	//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>&nbsp;</td><td align='right'><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 clearSelectedRadio(radioId) 
{
    var x=document.getElementsByName(radioId); 
    for(i=0;i<x.length;i++){x[i].checked=false;}
    document.getElementById('btnG').focus();
}




