function frmSearch_onSubmit(theForm) {
    //theForm.querystring.value = String(String(theForm.querystring.value).replace(/^ *([^ ]?)/,"$1")).replace(/([^ ]?) *$/,"$1");
    theForm.querystring.value = theForm.querystring.value.toString().replace(/^ *(.*)/,"$1");
    theForm.querystring.value = theForm.querystring.value.toString().replace(/([^ ]) +$/,"$1");
    theForm.querystring.value = theForm.querystring.value.toString().replace(/ /g,'+');
   
    if ( (theForm.querystring.value != '') && (theForm.list.options[theForm.list.selectedIndex].value != '') )
    {
       select_search();
    }
    else
        {
            alert('Please enter some text and try your search again.');
            location.reload(); 
            
    }
}





function select_search()
{

	//document.quicksearchform.submit();
	if( quicksearchform.list.value == "FAO") //Search Into Giews
	{

		quicksearchform.action = "http://www.fao.org/waicent/search/default.asp";
		document.quicksearchform.submit();
	}


	else if(quicksearchform.list.value == "GiewsSite") //Search into FAO
	{
		//alert("newsft");
		//search_form1.searchcontent.name="word";
		quicksearchform.action = "http://www.fao.org/eims/es/eims_search/free_s.asp?Action=Execute&itype=2&SearchString="+quicksearchform.querystring.value;
		//quicksearchform.SearchString.value=
		document.quicksearchform.submit();
	}
	
	else if(quicksearchform.list.value == "GiewsPub") //Search into FAO
		{
			
			quicksearchform.action="http://www.fao.org/eims/es/eims_search/free_s.asp?Action=Execute&itype=1&SearchString="+quicksearchform.querystring.value;
			//&quicksearchform.querystring.value;
			
			//quicksearchform.action = "http://www.fao.org/eims/es/eims_search/advanced_s_result.asp";
			//quicksearchform.querystring.value=quicksearchform.querystring.value;
			document.quicksearchform.submit();
	}
	
	
	else if(quicksearchform.list.value == "Google") //Search into FAO
	{
		//alert("newsft");
		//search_form1.searchcontent.name="word";
		document.quicksearchform.method="get";
        quicksearchform.q.value=quicksearchform.querystring.value;
		if (quicksearchform.language.value=="ZH") {
        quicksearchform.hl.value="zh-CN";
        }
        quicksearchform.action = "http://www.google.com/search";
		document.quicksearchform.submit();
	}
}

//add tree menu function on 1 Nov. 2007

function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='/giews/imgs/plus.gif' hspace='0' vspace='0' border='0'>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='/giews/imgs/minus.gif' hspace='0' vspace='0' border='0'>";
   }
}

function Expand() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="block";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='../imgs/minus.gif' hspace='0' vspace='0' border='0'>";
   }
}

function Collapse() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="none";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='../imgs/plus.gif' hspace='0' vspace='0' border='0'>";
   }
}

