function go2advancedSearch() {
 top.location.href = '/offsiteframe.jsp?uu=https://drms.fao.org/drmsIntra/AdvancedSearch.asp?searchmode=advancedsearch';
}

function frmSearch_onSubmit(theForm) {
    //theForm.search_string.value = String(String(theForm.search_string.value).replace(/^ *([^ ]?)/,"$1")).replace(/([^ ]?) *$/,"$1");
    theForm.search_string.value = theForm.search_string.value.toString().replace(/^ *(.*)/,"$1");
    theForm.search_string.value = theForm.search_string.value.toString().replace(/([^ ]) +$/,"$1");
    theForm.search_string.value = theForm.search_string.value.toString().replace(/ /g,'+');
    if ( (theForm.search_type.options[theForm.search_type.selectedIndex].value == 'sm') && (theForm.search_string.value != '') ) {
        top.location.href='/IntranetServlet?searchType=teldir&pg=teldir&search_string='+escape(theForm.search_string.value);
        return false;
    }
    if ( (theForm.search_string.value != '') && (theForm.search_type.options[theForm.search_type.selectedIndex].value != '') )
    {
        return true;
    }
    else
    {
        alert('Please enter some text and try your search again.');
        return false;
    }
}

function frmSearch_setText(theText) { document.frmSearch.search_string.value = theText }

function frmSearch_setType(theValue) {
 var i,theSel;
 theSel = document.frmSearch.search_type;
 for (i=0; i < theSel.options.length; i++) {
  if (theSel.options[i].value == theValue) {
   theSel.selectedIndex = i;
   break;
  }
 }
}

with (self.document) {
 writeln('<table cellspacing="5" cellpadding="0" border="0">');
 writeln('<tr valign="baseline">');
 writeln('<form onSubmit="return frmSearch_onSubmit(this);" name="frmSearch" method="get" action="/searchframe.jsp" target="_top">');
 writeln('<td class="topsearch"><input type="text" size="10" value="" onMouseOver="this.focus();" name="search_string"><'+'/td>');
 writeln('<td class="topsearch"><select name="search_type" size="1">');
 writeln('<optgroup label="FAO Internal">');
 writeln('<option selected="true" value="sm" label="Staff Members">Staff Members<'+'/option>');
 writeln('<option value="intra" label="Intranet">FAO Intranet<'+'/option>');
 writeln('<'+'/optgroup>');
 writeln('<optgroup label="www.fao.org">');
 writeln('<option value="webg" label="with Google">www.fao.org (Google)<'+'/option>');
 writeln('<option value="web" label="with DRMS">www.fao.org (DRMS)<'+'/option>');
 writeln('<'+'/optgroup>');
 writeln('<optgroup label="Internet">');
 writeln('<option value="google" label="with Google">Internet (Google)<'+'/option>');
 writeln('<option value="av" label="with Altavista">Internet (Altavista)<'+'/option>');
 writeln('<'+'/optgroup>');
 writeln('<'+'/select><'+'/td>');
 writeln('<td class="topsearch"><a href="javascript:if(frmSearch_onSubmit(document.frmSearch))document.frmSearch.submit();void(0);">Search</'+'a><'+'/td>');
 writeln('<'+'/form>');
 writeln('<'+'/tr>');
 writeln('<'+'/table>  ');
}
