//Doc! /* alertContents : Response from AJAX Changed : Updates the text box with the new value of the select box Clicked : Resets the value of a text box FindInList : Searches the contents of a select control, not recomended for 250+ items findPos : Find the x and y of an id HideDiv : Hides div and executes function if available [onDivClose] lSKeyPress : Activated when a key is pressed makeRequest : Makes an AJAX call MoveInList : Moves the selected index of a select box onDivClose : Executes predefined finctions PosDiv : Sets the x and y of a div SearchBox : Searches the contents of a select control, not recomended for 250+ items after 3 charactors Selected : Updated text box when select box is clicked ShowSelectDiv : Displays the select div ShowDiv : Shows div UpdateList : Updates a select control with new xml UpdateTextBox : Updates the textbox */ var http_request = false; var http_request = false; var uTargetID = ''; function debugWindow(toDisplay){ if (document.getElementById("jsdebug")) { document.getElementById("jsdebug").innerText = toDisplay; } } function makeRequest(url, parameters, targetID) { debugWindow(url + ' ' + parameters + ' ' + targetID); http_request = false; uTargetID = targetID; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url + parameters, true); http_request.send(null); document.getElementById('img' + uTargetID).src = '/images/searching_progress_blue15.gif'; } function alertContents() { if (http_request.readyState == 4) { //document.getElementById('imgLSDestinationAirports').src='/images/drop_icon.gif'; if (http_request.status == 200) { if (window.ActiveXObject) { // IE var doc = http_request.responseText; var xDoc = new ActiveXObject("Microsoft.XMLDOM"); xDoc.loadXML(doc); } else { var xDoc = http_request.responseXML; } UpdateList('', 'Select' + uTargetID, '', xDoc); document.getElementById('img' + uTargetID).src = "/images/drop_icon.gif"; } else { alert('There was a problem with the request.'); } } } function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft curtop = obj.offsetTop while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } } return [curleft,curtop]; } function UpdateList(divID, selectID, textID, lXML){ while (document.getElementById(selectID).options.length) { document.getElementById(selectID).remove(0); } var xValue = lXML.getElementsByTagName("Value"); var xText = lXML.getElementsByTagName("Text"); for (j=0;j= 3) && (continueSearch)){ ShowDiv(divID); FindInList(divID, thisID, textID, exeFunction, selectID); } } function LiveSearchBox(divID, thisID, textID, exeFunction, selectID, imgID, targetID, ajaxCall, event){ var searchCriteria = document.getElementById(textID).value; var continueSearch = true; var keynum; if(window.event) // IE { keynum = event.keyCode; } else if(event.which) // Netscape/Firefox/Opera { keynum = event.which; } if (keynum == 40){ continueSearch = false; //ShowDiv(divID); } if (keynum == 38){ continueSearch = false; //ShowDiv(divID); } if (keynum == 13){ continueSearch = false; } if ((searchCriteria.length >= 3) && (continueSearch)){ ShowDiv(divID); //FindInList(divID, thisID, textID, exeFunction, selectID); makeRequest('ajax/ajax-funcrtions.asp', '?ft=' + ajaxCall + '&fp=' + searchCriteria + '&fl=true', targetID); } } function FindInList(divID, thisID, textID, exeFunction, selectID) { var searchCriteria = document.getElementById(textID).value; for(var f=0; f= maxIndex){ curIndex = maxIndex; } else { curIndex++; } } document.getElementById(selectID).selectedIndex = curIndex; Changed(divID, document.getElementById(selectID), textID, ''); } function lSKeyPress(divID, selectID, textID, exeFunction, event) { var keynum; var keychar; if(window.event) // IE { keynum = event.keyCode; } else if(event.which) // Netscape/Firefox/Opera { keynum = event.which; } if (keynum == 40){ MoveInList(divID, selectID, textID,'down'); } if (keynum == 38){ MoveInList(divID, selectID, textID,'up'); } if (keynum == 13){ if (document.getElementById(divID).style.display == 'block'){ HideDiv(divID, textID, selectID, exeFunction); Changed(divID, document.getElementById(selectID), textID, ''); } } keychar = String.fromCharCode(keynum); return; } function SelText(Obj) { if(Obj.value != "") { Obj.select() } } function disableEnterKey(e) { var key; if(window.event) key = window.event.keyCode; //IE else key = e.which; //firefox if(key == 13) return false; else return true; }