/** Used by AbstractAJAXCall. Depends on text of $GSEERROR_PREFIX not changing. **//** * 08-Feb-21: Stop caching httpObjects. It breaks outoload of first tab in TabbedDivElement. * 08-Dec-08: New getHTTPObjectForKey to handle IE7. * 09-Feb-14: Add handlePublishError. * 09-May-22: Add isEnterKeyPressed. * 09-Jul-09: Add null guard in showAJAXIndicator. * 09-Dec-06: Add another null guard in showAJAXIndicator. * */ 	var ajaxIndicatorsArray = new Array(); // see showAJAXIndicator          /// NO WORK AT ALL    function new_getHTTPObjectForKey(key) {    	// These are in order of decreasing likelihood; this will change in time.     	var _PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];        var http = null;        var last_e = null;        try { http = new XMLHttpRequest(); }         catch(e) {        	for(var i=0; i<3; i++){                try {http = new ActiveXObject(_PROGIDS[i]);} catch(e) {last_e = e;}                if(http) {                    break;                }             }        }        if(!http) {return null; } // error!!        return http;     }	function getHTTPObjectForKey(key) {		var xmlhttp; 		/*@cc_on 		@if (@_jscript_version >= 5)			try { 				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 			} catch (e) { 				try { 					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 				} catch (E) { 					xmlhttp = false; 				} 			} 		@else xmlhttp = false; 		@end @*/			if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 			try { 				xmlhttp = new XMLHttpRequest(); 			} catch (e) { 				xmlhttp = false; 			} 		}		return xmlhttp; 	}			function makeAjaxCallForKeyPageParams(key, handlerClass, url, paramsCall, callback, obj, onErrorDo) {		var fnName = paramsCall.toString();		fnName = fnName.substring(8); // get rid of "function"		fnName = fnName.substring(0, fnName.indexOf('('));		fnName = fnName.replace(/^\s*/, "").replace(/\s*$/, "");		showAJAXIndicator(fnName, true);		var http = getHTTPObjectForKey(key);		var params = paramsCall();		params += "&ajax_handler=" + key;		if(handlerClass != null) {			params += "&controller_class=" + handlerClass;		}		http.open("POST", url, true);		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");		// the line below can cause problems with safari		//http.setRequestHeader("Content-length", params.length);		http.setRequestHeader("Connection", "close");		http.onreadystatechange = function() {			if(http.readyState == 4) {				if(http.status == 200) {					if(http.responseText.startsWith("##ERR:")) {						ajaxHandleError(http, obj, onErrorDo, http.responseText);					} else {						callback(http.responseText);					}				} else {				//	ajaxHandleError(http, obj, onErrorDo);				}			}		}		http.send(params);	}	function ajaxHandleError(http, obj, onErrorDo, responseText) {		showAJAXIndicator("ajax", false); // on error, hide all indicators		if(onErrorDo == null) {			reportAJAXError(http.status, obj, responseText);		} else {			onErrorDo(http.status, obj, responseText);		}	}	function reportAJAXError(status, obj, responseText) {		var s;		if(responseText == undefined) {			s = "A communications error occurred: " + status;		} else {			s = responseText.substr(6);		}		window.alert(s);	}		/**	 * Uses CSS to display the existing img with the id of prefix + '_img', or to	 * hide any already displayed img that begins with prefix. Thus if you kick	 * off an AJAX process with the same prefix as an already running process,	 * when either of them finishes, both indicators will be turned off. This is	 * a shortcoming of using this technique that will be addressed in a future	 * release.	 */	function showAJAXIndicator(prefix, show) {		if(show) {			var indID = prefix + '_img';			ajaxIndicatorsArray.push(indID);			var ind = $(indID);			if(ind != null) $(indID).className = 'displayed';		} else {			var indArray = ajaxIndicatorsArray.slice();			var i, j, s;			for(i = 0; i<indArray.length; i++) {				s = indArray[i];				if(s.indexOf(prefix) == 0 && (c = $(s)) != null) {					c.className = 'nodisplay';					for(j=0; j<ajaxIndicatorsArray.length; j++) {	   					if(s == ajaxIndicatorsArray[j]) {	   						ajaxIndicatorsArray.splice(j, 1);	   						break;	   					}	   				}				}			}		}	}		function getAJAXParamsForFields(fields, params) {		var i;		for(i = 0; i < fields.length; i++) {			params += fields[i] + "=" + escape(document.getElementById(fields[i]).value);			if(i < (fields.length - 1)) {				params += "&";			}		}		return params + "";	}			// callbacks		function updateDiv(responseText, divID) {		var div = $(divID);		div.innerHTML = responseText;		copyScriptsToHeadFrom(divID);	}			// utility function	function copyScriptsToHeadFrom(divID) {		var scripts = $(divID).getElementsByTagName("script");		var scriptText = "";		for(var i = 0; i < scripts.length; i++) {			scriptText += scripts[i].text;		}		var e = document.createElement("script");		e.text = scriptText;		e.type="text/javascript";		document.getElementsByTagName("head")[0].appendChild(e);	} 		// custom errors		function handlePublishError(status, obj, responseText) {		reportAJAXError(status, obj, responseText);		$('viewable').checked = false;	}		// use for triggering on enter/return key press	function isEnterKeyPressed(e) {		var keycode;		if (window.event) 			keycode = window.event.keyCode;		else if (e) keycode = e.which; else return false;		return (keycode == 13);	}