// - - - Start - Configuration - Settings the Agency can modify - - - //
var Enable_Search_Within_This_Site = false;
var Enable_Search_Within_Agency = true;
var Results_Per_Page = 10;
var Search_Text_Box_Size = 15;
var Server_URL = "http://mysearch.internet.gov.sg/UIs/Decentralized.aspx";
var Server_HomePage = "http://mysearch.internet.gov.sg/";
var Banner = "";
var AdditionalDropDownItems = "";
var Catalogue = "";

// Change the following paramter manually if its not desirable to get the website domain automatically.
//var URLStr = document.domain;
var URLStr = "app.syariahcourt.gov.sg";

//Specify the Website's Feedback URL here e.g. www.mywebsite.gov.sg/feedback.html
var paramFeedbackPageURL="http://app.customerfeedback.mcys.gov.sg/syariah_faqmain_E.asp?menu_source=FEEDBACK&action=SUBMITMAIL&Source=FEEDBACK";

// Specify the Website's Contact Info URL here e.g. www.mMywebsite.gov.sg/ContactInfo.html
var paramContactInfoPageURL="http://app.syariahcourt.gov.sg/syariah/front-end/AboutUs_Contactinfo_E.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']
]

// Specify additional Catalgoue options using the following //
Catalogue = 
[
	["Within Syariah Court Website","39"]
]
// - - - 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.SearchPlugInfrm.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.SearchPlugInfrm.iNPUTcombo.value = varCombo;
}

function ShowResults()
{
	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 class='readingtextbold'><b>Search</b></td><td nowrap>");
	document.writeln("<input type=text name=TextBoxSearch size="+ Search_Text_Box_Size + "></td>");
	document.writeln("<td  valign='bottom'>");
	document.writeln("<input type=image valign='bottom' name=SearchGo id=SearchGo src='http://app.syariahcourt.gov.sg/syariah/front-end/images/header-button-go.gif' value='Search' >");
	document.writeln("</td><td>");
    document.writeln("<a target=new href=" + Server_HomePage + "><img src=http://app.syariahcourt.gov.sg/syariah/front-end/images/Dconlinesearch.gif  border=0 alt='Singapore Government Online Search Home'>");
	document.writeln("</td></tr><tr><td>&nbsp;</td><td colspan=3>");
	document.writeln("<SELECT id=drop name=drop>");

	if (Catalogue != "")
	{
		for (i = 0; i < Catalogue.length; i++)
			document.writeln("<OPTION VALUE=" + Catalogue[i][1] +" SELECTED>" + Catalogue[i][0]);
	}

	document.writeln("<OPTION VALUE='SearchInAllGovSites'>" + "Within All Singapore Gov Websites");

	if(enableSearchWithInSite())
	{
		document.writeln("<OPTION VALUE=SearchWithinThisSite>" + "Within This Website");
	}
	if(enableSearchWithInAgency())
	{
		document.writeln("<OPTION VALUE=SearchWithInAgency>" + "Within This Agency");
	}
	var t = / /g;
	if(AdditionalDropDownItems.length != 0)
	{
		for (i = 0; i < AdditionalDropDownItems.length; i++)
			document.writeln("<OPTION VALUE=" + AdditionalDropDownItems[i][0].replace(t, "") +">" + AdditionalDropDownItems[i][0]);
	}

	document.writeln("</SELECT>");
	document.writeln("</td></tr></table>");
	if( URLStr.match("https://"))
	{
		URLStr = URLstr.replace("https://","");
	}
	else if (URLStr.match("http://"))
	{
		URLStr = URLStr.replace("http://","");
	}
	SplitResTry = URLStr.split("/");
	SplitResTry = SplitResTry[0].split(":");
	document.writeln("<input id=ResultsPerPage type=hidden value=" + SetResultsPerPage() + " name=ResultsPerPage>");
	document.writeln("<input id=currentURL type=hidden value=" + SplitResTry + " name=currentURL>");
	document.writeln("<input id='iNPUTcombo' type=hidden name='iNPUTcombo' />");
	document.writeln("<input id=inputBanner type=hidden style='display:none' value=" + Banner + " name=inputBanner />");
	document.writeln("<input type=hidden value='DecentralizedInternet' name=EntryPage />");
	
	//New parameters added for Feedback and ContactInfo page - 23 June 2006
	document.writeln("<input type=hidden value='" + paramFeedbackPageURL + "' name='paramFeedbackPageURL'  />");
	document.writeln("<input type=hidden value='" + paramContactInfoPageURL + "' name='paramContactInfoPageURL' />");
	
	
	document.writeln("</form>");
}
