add: else if (id == "orgsearchkey") action = "find_name_org"; 
context: function autocomplete(id, popupId, uri, popupData, hideAlt){    var inputField = document.getElementById(id);    var popup      = document.getElementById(popupId);	var dataField  = document.getElementById(popupData); // [ML]	var altField   = document.getElementById(hideAlt); // [ML]    var options = new Array();     var current = 0;    var originalPopupTop = popup.offsetTop;     function constructUri()    {        var separator = "?";		var action = "find_name_client";        if(uri.indexOf("?") >= 0)            separator = "&";		if (id == "clientsearchkey")			action = "find_name_client";		else if (id == "casesearchkey")			action = "find_name_case";			        return uri + separator + action + "=" + (inputField.value); /* [ML] removed escape() for cyrillic ?? */    }       function hidePopup()    {      popup.style.visibility = 'hidden';    }    function handlePopupOver()    {      removeListener(inputField, 'blur', hidePopup);    }        function handlePopupOut()    {      if(popup.style.visibility == 'visible')      {        addListener(inputField, 'blur', hidePopup);      }    }        function handleClick(e)    {	  	var foo = eventElement(e).innerHTML.split(': ');		var action = "id_client";        popup.style.visibility = 'hidden';        inputField.focus();		if (foo[0] > 0) {			inputField.value = foo[1];			altField.style.display = 'none'; // [ML] 			// [ML] experiments			function updateClient()			{				if (xmlHttp1.readyState == 4) {					var response = xmlHttp1.responseText;					dataField.innerHTML = response;					document.getElementById('input_case_title').value = inputField.value;				}			}			if (id == 'clientsearchkey')				action = 'id_client';			else if (id == 'casesearchkey')				action = 'id_case';			xmlHttp1 = new XMLHttpRequest();			xmlHttp1.open('GET', 'ajax.php?' + action + '=' + foo[0], true);			xmlHttp1.onreadystatechange = updateClient;			xmlHttp1.send(null);		}		popup.style.visibility = 'hidden';		inputField.focus();    }        function handleOver(e)    {      options[current].className = '';      current = eventElement(e).index;      options[current].className = 'selected';    }        function post()    {        current = 0;        options = popup.getElementsByTagName("li");        if((options.length > 1)           || (options.length == 1                && options[0].innerHTML != inputField.value))        {          setPopupStyles();          for(var i = 0; i < options.length; i++)          {            options[i].index = i;            addOptionHandlers(options[i]);          }          options[0].className = 'selected';        }        else        {          popup.style.visibility = 'hidden';        }    }      function setPopupStyles()    {      var maxHeight      if(isIE)      {        maxHeight = 200;        popup.style.left = '0px';        popup.style.top = (originalPopupTop + inputField.offsetHeight) + 'px';      }      else      {        maxHeight = window.outerHeight/3;      }      if(popup.offsetHeight < maxHeight)      {        popup.style.overflow = 'hidden';      }      else if(isMoz)      {        popup.style.maxHeight = maxHeight + 'px';        popup.style.overflow = '-moz-scrollbars-vertical';      }      else      {        popup.style.height = maxHeight + 'px';        popup.style.overflowY = 'auto';      }      popup.scrollTop = 0;      popup.style.visibility = 'visible';    }        function addOptionHandlers(option)    {      addListener(option, "click", handleClick);      addListener(option, "mouseover", handleOver);    }        var updater = liveUpdater(constructUri, post);    var timeout = false;   	function start(e) {		if (timeout)			window.clearTimeout(timeout);		//up arrow		if(e.keyCode == 38)		{			if(current > 0)			{				options[current].className = '';				current--;				options[current].className = 'selected';				options[current].scrollIntoView(false);			}		}		//down arrow		else if(e.keyCode == 40)		{			if(current < options.length - 1)			{				options[current].className = '';				current++;				options[current].className = 'selected';				options[current].scrollIntoView(false);			}		}		//enter or tab		else if((e.keyCode == 13 || e.keyCode == 9) && popup.style.visibility == 'visible')		{			var foo = options[current].innerHTML.split(': ');			var action = "id_client";			// [ML] This is redundant with lines ~ 350			popup.style.visibility = 'hidden';			if (foo[0] > 0) {				inputField.value = foo[1];				altField.style.display = 'none'; // [ML]				// [ML] experiments				function updateClient2()				{					if (xmlHttp1.readyState == 4) {						var response = xmlHttp1.responseText;						dataField.innerHTML = response;						document.getElementById('input_case_title').value = inputField.value;					}				}				if (id == 'clientsearchkey')					action = 'id_client';				else if (id == 'casesearchkey')					action = 'id_case';				xmlHttp1 = new XMLHttpRequest();				xmlHttp1.open('GET', 'ajax.php?' + action + '=' + foo[0], true);				xmlHttp1.onreadystatechange = updateClient2;				xmlHttp1.send(null);			}			if(isIE) {				event.returnValue = false;			} else {				e.preventDefault();			}		} else {			timeout = window.setTimeout(updater, 300);		}	}	addKeyListener(inputField, start);	addListener(popup, 'mouseover', handlePopupOver);	addListener(popup, 'mouseout', handlePopupOut);}
meta: 6477	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/6477/adb3287e5b1cf2e3cbdb565c1f87960b325e3be4/liveUpdater.js/clean/inc/liveUpdater.js