var arrUiAjax=new Array(); var indexUiAjax=0; // just in case function insertAfter( referenceNode, newNode ) { referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling ); } // removes control characters from strings function removeNL(s){ return s.replace(/[\n\r\t]/g,""); } var search_ajax=new sack(); var searchTimerID = null; var searchTimerOn = false; var activeSearchObject=null; var timecount = 2000; // Change this to the time delay that you desire function startTime_search() { if (searchTimerOn == false) { searchTimerID=setTimeout( "hideSearchBox('search_box_dropdown')" , timecount); searchTimerOn = true; } } function hideSearchBox(objid) { document.getElementById(objid).style.display="none"; } function showSearchBox(objid) { document.getElementById(objid).style.display="block"; } function stopTime_search() { if (searchTimerOn) { clearTimeout(searchTimerID); searchTimerID = null; searchTimerOn = false; } } //because every change function on this page references the same section of the page, we can use the same function // to change the actual html goodies. function stateChanged_search(index) { if (arrUiAjax[index].response != "notext") { showSearchBox('search_box_dropdown'); } else { hideSearchBox('search_box_dropdown'); } arrUiAjax[index]=null; } function ajaxError() { alert("There was an error retrieving the list of search results. Please try again"); } // works every time the text box is changed function updateSearch_search(obj_id, table, col) { var index=indexUiAjax; indexUiAjax++; arrUiAjax[index]=new sack(); // the php page uses "if(isset())" to check for the various operations activeSearchObject=document.getElementById(obj_id); var searchtext=activeSearchObject.value; var searchDropBox=document.getElementById('search_box_dropdown'); searchDropBox.style.width=activeSearchObject.offsetWidth + "px"; searchDropBox.style.left=getLeftPos(activeSearchObject, searchDropBox.parentNode) + "px"; searchDropBox.style.top=getTopPos(activeSearchObject, searchDropBox.parentNode) + activeSearchObject.offsetHeight + "px"; arrUiAjax[index].setVar("search",searchtext); arrUiAjax[index].setVar('table',table); arrUiAjax[index].setVar('col',col); arrUiAjax[index].setVar('index',index); arrUiAjax[index].requestFile='http://n4a.solacedev.com/tools/ui_dropdown_search/bin/ajaxResponder.php'; arrUiAjax[index].element='search_box_dropdown'; arrUiAjax[index].method="GET"; arrUiAjax[index].onCompletion=function(){stateChanged_search(index);}; arrUiAjax[index].onError=ajaxError; arrUiAjax[index].runAJAX(); } // gets the top position of the search text box up to the parent of the dropdown box function getTopPos(inputObj, stopObj) { var returnValue = inputObj.offsetTop; while((inputObj = inputObj.offsetParent) != null) { returnValue += inputObj.offsetTop; if (inputObj == stopObj) break; } return returnValue; } // gets the left position of the search box up to the parent of the dropdown box function getLeftPos(inputObj, stopObj) { var returnValue = inputObj.offsetLeft; while((inputObj = inputObj.offsetParent) != null) { returnValue += inputObj.offsetLeft; if (inputObj == stopObj) break; } return returnValue; }