// SMGS begin here
// 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 = 30;
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 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", "app2.appealsboard.gov.sg"]
]

// - - - End - Configuration - - - //


function ShowResults()
{
   var sdatahtml  =  '';
   sdatahtml += "<BR style='clear:both'><span style='font-size:12px;'>Search&nbsp;&nbsp;</span><input type='text' name='q' id='input_site_mlaw'  size='"+ Search_Text_Box_Size + "' style='font-size:12px;'>";
 
   if (Collections != "")
	{
		var param_site_value = ""; //Do not remove

		sdatahtml += "<span style='font-size:12px;'>&nbsp;</span><SELECT name='site' style='font-size:12px;'>";
		for (i = 0; i < Collections.length; i++)
		{
			sdatahtml +="<OPTION VALUE=" + Collections[i][1] +">" + Collections[i][0];

			//Do not remove
			param_site_value += Collections[i][0] + "#" + Collections[i][1] + '|';
		}
		sdatahtml +="</SELECT>";

		//Do not remove
		sdatahtml +="<input type='hidden' name='filter_s' value='" + param_site_value + "' />";
	}
	else
	{
		//Do not remove
		sdatahtml +="<input type='hidden'  name='site' value='default' />";
	}

	sdatahtml +="<span style='font-size:12px;'>&nbsp;</span>";
	sdatahtml +="<input type='button' id='btnG_mlaw' name='btnG' style='background-color:#c84141; font-size:85%; color:white; border:outset 1px #fff; width:30px; cursor:hand' value='Go' />"; 
	
	if(SiteSearchItems != "")
	{
		var param_ssearch_value = ""; //Do not remove

		for (i = 0; i < SiteSearchItems.length; i++)
		{
			sdatahtml += "<BR><input type='radio' name='sitesearch' VALUE=" + SiteSearchItems[i][1] +"><span style='font-size:11px'>" + SiteSearchItems[i][0];
			sdatahtml += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";

			//Do not remove
			param_ssearch_value += SiteSearchItems[i][0] + "#" + SiteSearchItems[i][1] + "|";
		}
		//Do not remove
		sdatahtml +="<input type='hidden' name='filter_ss' value='" + param_ssearch_value + "' />";
	}
	
	sdatahtml +="<input type='hidden' value='" + paramFeedbackPageURL + "' name='feedback_url'  />";
	sdatahtml +="<input type='hidden' value='" + paramContactInfoPageURL + "' name='contact_url' />";
	sdatahtml +="<input type='hidden' name='client' value='default' />";
	sdatahtml +="<input type='hidden' name='proxystylesheet' value='default' />";
	sdatahtml +="<input type='hidden' name='output' value='xml_no_dtd' />";
	
    $('<div id="top-search-container-sgms"></div>').insertAfter('ul.top-search-container');
	$('div#top-search-container-sgms').html(sdatahtml);
	$('ul.top-search-container').remove();
	
	 $('#btnG_mlaw').click(function(){
	    $('form').attr('action',Server_URL);
	    $('form').attr('method','GET');
		$('#__EVENTTARGET').remove();
		$('#__EVENTARGUMENT').remove();
		$('#__VIEWSTATE').remove();
		$('#__LASTFOCUS').remove();
		$('form').submit();
	 });
	 
	 $('#input_site_mlaw').keypress(function(e) {
		 if (e.which == 13) {
				$('form').attr('action',Server_URL);
				$('form').attr('method','GET');
				$('#__EVENTTARGET').remove();
				$('#__EVENTARGUMENT').remove();
				$('#__VIEWSTATE').remove();
		        $('#__LASTFOCUS').remove();
				$('form').submit();
		 }
     });
    
}


 


function clearSelectedRadio(radioId) 
{
    var x=document.getElementsByName(radioId); 
    for(i=0;i<x.length;i++){x[i].checked=false;}
    document.getElementById('btnG').focus();
}


// SGMS end here

// JavaScript Document
var dnnhostpath = ""
$(document).ready(function(){
	ShowResults();
	$('ul.main-menu-links li').hover(function(){ $(this).addClass('menu-hover');  },function(){ $(this).removeClass('menu-hover');  });
    $('div.box1').hover(function(){ $(this).addClass('box1-hover');  },function(){ $(this).removeClass('box1-hover');  });
	
	
	
			$('.headlink_panel').hide();
			$('li.headlink').toggle(
			function() { 
			     //$('.headlink_panel').hide();
 				 $('ul', this).css('display', '');
 				 $(this).addClass('current');
				  $('img.headerlink_arrow').attr('src',dnnhostpath + 'images/global/down-arrow.gif')
				 $('img.headerlink_arrow',this).attr('src',dnnhostpath + 'images/global/up-arrow.gif')
		    },
			function() { 
			     $('ul', this).css('display', 'none'); 
			     $('img.headerlink_arrow',this).attr('src',dnnhostpath + 'images/global/down-arrow.gif')
			});
 			
		$('.left-menu-panel li').hover(
			function() { $(this).addClass('mover');   },
			function() { $(this).removeClass('mover'); });
 
      // var thref = $('a',this).attr('href'); if
		$('.left-menu-panel li a').click(function(){
		     if($(this).attr('href')!=undefined  && $(this).attr('href')!='#' &&  $(this).attr('href')!=''){
				   self.location = $(this).attr('href'); 
			 }										
		});

			$('.faq_section  .content').hide();
			$('.faq_section li').toggle(
			function() { 
			     $('a',this).click(function(){
				   self.location = $(this).attr('href');						
				 });
		         $('.content',this).show();
			},
			function() { 
			     $('a',this).click(function(){
				   self.location = $(this).attr('href');						
				 });
		         $('.content',this).hide();
			});			
			
		    $('.current .headlink_panel').css('display', '');
		    $('.current  img.headerlink_arrow').attr('src',dnnhostpath + 'images/global/up-arrow.gif');
			
			
	   //   $('ul.head-menu-link-panel').css('display', 'none');
 		  $('li.head-menu-link').hover(
			function() { 
					$('ul', this).css('display', '');
			},
			function() {
					$('ul', this).css('display', 'none');
			});
		  
 		  $('li.head-menu-link').show();
	      $('ul.head-menu-link-panel').css('display', 'none');
		  

		 $('div.title_vis').hide();
		 $('div.c_footer').hide();

	      $('input#mlainput').keypress(function(e){
				if(e.keyCode==13){ 
				    //__GSMS_UI();
				    return false;
				} 	return true;						   

		});
		 
		 $('img#mlabutton').click(function(){ __GSMS_UI(); });


});

function __GSMS_UI(){
    if($('input#mlainput').val()!=''){
		// var feedback_url = "http://mlawstg.comwerks.net/Default.aspx";
		// var contact_url = "http://mlawstg.comwerks.net/Default.aspx";
 	     self.location = 'http://sgms.internet.gov.sg/search?q='+ escape($('input#mlainput').val()) + '&site=' + $("input[@name='mlasite']:checked").val()+ '&feedback_url=' + escape(feedback_url) + '&contact_url=' + escape(contact_url) + '&client=default&proxystylesheet=default&output=xml_no_dtd';
    }else{
		alert("please enter atleast 1 or more keywords");
    }return false;
}


function __ForwardFriend(){
	self.location = '/ForwardtoaFriend/tabid/452/Default.aspx?forward_url=' + escape(document.location.href);
}
