prefix = "https://ems.netexsoftware.com/ems"; function isXMLHttpEnabled() { var success = false; try { var xml = new XMLHttpRequest(); success = true; } catch (e) { var MSXML_XMLHTTP_PROGIDS = new Array( 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP' ); for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) { try { xml = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]); success = true; } catch (e) {} } } return success; } function createXMLHttp() { var success = false; var xmlhttp = null; try { xmlhttp = new XMLHttpRequest(); success = true; } catch (e) { var MSXML_XMLHTTP_PROGIDS = new Array( 'Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP' ); for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) { try { xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]); success = true; } catch (e) {} } /* if ( !success ) { alert('Cant create XMLHttpRequest - not supported'); } */ } //return success; return xmlhttp; } function callInProgress(xmlhttp) { /**************************************************************** Checks the ready state of the XML call, and returns true if ready state is 1-3 (busy), and false if 0 or 4 (ready) ****************************************************************/ switch ( xmlhttp.readyState ) { case 1, 2, 3: return true; break; // Case 4 and 0 default: return false; break; } } function get_jax_content(jax_file, response_function, post_vars){ /**************************************************************** jax_file: path to the remote file to run response_function: javascript function to send the response to a callback function ie: ajax_callback will actually call ajax_callback(response) post_vars: if set, this will POST the vars to the jax_file -------------------------------------------------------------------- ADDS A TIME STAMP TO THE jax_file SO IT WILL NOT BE CACHED SETS UP A FUNCTION FOR READY STATE 4 CHECKS FOR A CALL IN PROGRESS SENDS THE CALL ****************************************************************/ if ((jax_file.substring(0,5) != "http:") && (jax_file.substring(0,6) != "https:")) jax_file = prefix + jax_file; jax_file = jax_file + "&noCache=" + new Date().getTime() // alert ("Open:" + jax_file + ", Target to: " + target_div);// + "type=" + type); //grab an xmlHttp object var xmlhttp = createXMLHttp(); xmlhttp.open("POST", jax_file, true); //open http connection; xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); //set content-type header xmlhttp.onreadystatechange=function() { try{ wait(1); } catch (e) { } //run a wait(1) function if it exists [usually for displaying some kind of animation to let the user know something is going on. if (xmlhttp.readyState==4) { try{ wait(0); } catch (e) { } var function_to_run = response_function + "(xmlhttp.responseText)"; //setup a string with the callback function to run and response var eval(function_to_run); //execute the callback function } } if ( !callInProgress(xmlhttp) ) { if (post_vars!=""){ xmlhttp.send(post_vars); } else { xmlhttp.send(null); } } else { try{ wait(1); } catch (e) { } } delete xmlhttp; } function get_jax_content2(jax_file, response_function, post_vars, targetId){ /**************************************************************** jax_file: path to the remote file to run response_function: javascript function to send the response to a callback function ie: ajax_callback will actually call ajax_callback(response) post_vars: if set, this will POST the vars to the jax_file -------------------------------------------------------------------- ADDS A TIME STAMP TO THE jax_file SO IT WILL NOT BE CACHED SETS UP A FUNCTION FOR READY STATE 4 CHECKS FOR A CALL IN PROGRESS SENDS THE CALL ****************************************************************/ if ((jax_file.substring(0,5) != "http:") && (jax_file.substring(0,6) != "https:")) jax_file = prefix + jax_file; jax_file = jax_file + "&noCache=" + new Date().getTime(); // alert ("Open:" + jax_file + ", Target to: " + target_div);// + "type=" + type); //grab an xmlHttp object var xmlhttp = createXMLHttp(); xmlhttp.open("POST", jax_file, true); //open http connection; xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); //set content-type header xmlhttp.onreadystatechange=function() { try{ wait(1); } catch (e) { } //run a wait(1) function if it exists [usually for displaying some kind of animation to let the user know something is going on. if (xmlhttp.readyState==4) { try{ wait(0); } catch (e) { } var function_to_run = response_function + "(xmlhttp.responseText" + ", '" + targetId + "')"; //setup a string with the callback function to run and response var eval(function_to_run); //execute the callback function } } if ( !callInProgress(xmlhttp) ) { if (post_vars!=""){ xmlhttp.send(post_vars); } else { xmlhttp.send(null); } } else { try{ wait(1); } catch (e) { } } delete xmlhttp; } function get_jax_content3(jax_file, response_function, post_vars, callbackArgs){ /**************************************************************** jax_file: path to the remote file to run response_function: javascript function to send the response to a callback function ie: ajax_callback will actually call ajax_callback(response) post_vars: if set, this will POST the vars to the jax_file -------------------------------------------------------------------- ADDS A TIME STAMP TO THE jax_file SO IT WILL NOT BE CACHED SETS UP A FUNCTION FOR READY STATE 4 CHECKS FOR A CALL IN PROGRESS SENDS THE CALL ****************************************************************/ if ((jax_file.substring(0,5) != "http:") && (jax_file.substring(0,6) != "https:")) jax_file = prefix + jax_file; jax_file= jax_file + "&noCache=" + new Date().getTime(); // alert ("Open:" + jax_file + ", Target to: " + target_div);// + "type=" + type); //grab an xmlHttp object var xmlhttp = createXMLHttp(); xmlhttp.open("POST", jax_file, true); //open http connection; xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); //set content-type header xmlhttp.onreadystatechange=function() { try{ wait(1); } catch (e) { } //run a wait(1) function if it exists [usually for displaying some kind of animation to let the user know something is going on. if (xmlhttp.readyState==4) { try{ wait(0); } catch (e) { } if (!callbackArgs) { callbackArgs = []; } callbackArgs.unshift(xmlhttp.responseText); response_function.apply(null, callbackArgs); } } if ( !callInProgress(xmlhttp) ) { if (post_vars!=""){ xmlhttp.send(post_vars); } else { xmlhttp.send(null); } } else { try{ wait(1); } catch (e) { } } delete xmlhttp; } function getFormValues(fobj,valFunc,excludeList,noBlank){ /**************************************************************** loops through all the elements of a form and gathers the values to create a postvar string. Existing Element Gathering from text fields, hidden fields, and single value selects ****************************************************************/ if (!fobj) return ""; var str = ""; var valueArr = null; var val = ""; var cmd = ""; for(var i = 0;i < fobj.elements.length;i++) { if (excludeList) { if (excludeList.indexOf(fobj.elements[i].name) >= 0) continue; } switch(fobj.elements[i].type) { case "text": if(valFunc) { //use single quotes for argument so that the value of //fobj.elements[i].value is treated as a string not a literal cmd = valFunc + "(" + 'fobj.elements[i].value' + ")"; val = eval(cmd) } if (fobj.elements[i].name) { if (fobj.elements[i].value == '' && noBlank) break; str += fobj.elements[i].name + "=" + encodeURIComponent(fobj.elements[i].value) + "&"; } break; case "password": str += fobj.elements[i].name + "=" + encodeURIComponent(fobj.elements[i].value) + "&"; break; case "hidden": str += fobj.elements[i].name + "=" + encodeURIComponent(fobj.elements[i].value) + "&"; break; case "select-one": if (fobj.elements[i].selectedIndex>-1 && fobj.elements[i].name) { if (fobj.elements[i].options[fobj.elements[i].selectedIndex].value == '' && noBlank) break; str += fobj.elements[i].name + "=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; } else { if (fobj.elements[i].name) str += fobj.elements[i].name + "=&" } break; case "select-multiple": for (var j = 0; j < fobj.elements[i].options.length; j++) { if (fobj.elements[i].options[j].selected) { str += fobj.elements[i].name + "=" + fobj.elements[i].options[j].value + "&"; } } break; case "checkbox": if (fobj.elements[i].checked) { if (fobj.elements[i].name) { str += fobj.elements[i].name + "=" + encodeURIComponent(fobj.elements[i].value) + "&"; } } else { if (fobj.elements[i].name) str += fobj.elements[i].name +"=0&"; } break; case "textarea": str += fobj.elements[i].name + "=" + encodeURIComponent(fobj.elements[i].value) + "&"; break; case "radio": if (fobj.elements[i].checked){ str += fobj.elements[i].name + "=" + encodeURIComponent(fobj.elements[i].value) + "&"; } break; } } str = str.substr(0,(str.length - 1)); return str; }