document.write('<form name="searchform" action="/fcgi/icssearch" id="searchform">');
document.write('<input type="hidden" name="sitesearch" value="www.ics.uci.edu"/>');
document.write('<input id="query" onFocus="clear_textbox()" name="q" size="8" maxlength="300" value="Search ICS" autocomplete="off"  type="text"></input>');
document.write('<div class="auto_complete" id="results" align="center" size="100" maxlength="500" height="500" style="position:absolute;zIndex:100" ></div>');
document.write('<input type="hidden" id="results_selected" name="sel" />');
document.write('<input type="hidden" name="start_pb" value="1">');
document.write('</form>');


var searcher = new Ajax.Autocompleter( 
	    'query', 
	    'results', 
	    '/fcgi/icssearch', 
            {minChars: 2,
	     afterUpdateElement: searchSubmit})
             function searchSubmit(text, li) { 
             document.getElementById("results_selected").value = li.getAttribute("value"); 
             if(document.getElementById("results_selected").value>0)
               document.getElementById("query").value="";
             //alert(document.getElementById("results_selected").value);
             if (document.getElementById("results_selected").value<=0)
             { 
                  var action2google= li.getAttribute("sendquery");
                  //alert(action2google);
                  //action2google = action2google.split('"')[1];
                  //document.getElementById("searchform").action =
                  document.getElementById("query").value=action2google;
                  var newurl = "http://www.googlesyndicatedsearch.com/u/isearch";//?sitesearch=www.ics.uci.edu&q=" + action2google;
                  // alert(newurl); 
		  //window.location = newurl;
                  document.getElementById("searchform").action=newurl;
	          document.getElementById("searchform").submit(); 
             }
	     else
             { 
                document.getElementById("searchform").action="/fcgi/icssearch";				
	        document.getElementById("searchform").submit();
             }
	}

