
	var sDefaultLoadingHTML = "<img src=\"http://www.ideablender.com/wireframe/images/temp/loading.gif\" alt=\"Loading\" />";
	var oModalAjaxRequest, sModalRequestURL, iPostCallbackTimeout, sPostCallback;
	
	/* executes the specified ajax request. */
	function jExecuteAjaxRequest(sRequestURL, oInjectionElement, sLoadingHTML, sRequestVars, sPostCallbackIndex) {
		var oAjaxRequest = jCreateAjaxRequest(); // Create a new request..
		
		if (sPostCallbackIndex != null) {
			sPostCallback = sPostCallbackIndex;
		}
		
		oAjaxRequest.onreadystatechange = function() {
			if (oInjectionElement != null && oAjaxRequest.readyState == 4) {
				oInjectionElement.innerHTML = oAjaxRequest.responseText; // Update the content..
				
				if (sPostCallbackIndex != null) {
					clearTimeout(iPostCallbackTimeout); iPostCallbackTimeout = setTimeout("jAjaxPostCallback();", 1000);
				}
			}
		}
		
		oInjectionElement.innerHTML = (sLoadingHTML != null) ? sLoadingHTML : sDefaultLoadingHTML;
		
		oAjaxRequest.open("POST", sRequestURL, true); // Avoid page cache..
		oAjaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjaxRequest.send("Hash=" + Math.random() + ((sRequestVars != null) ? sRequestVars : "")); // Send the request..
	}
	
	/* executes the specified ajax request in the background. */
	function jExecuteAjaxProcessingRequest(sRequestURL, oInjectionElement, sLoadingHTML, sRequestVars, sPostCallbackIndex) {
		var oAjaxRequest = jCreateAjaxRequest(); // Create a new request..
		
		if (sPostCallbackIndex != null) {
			sPostCallback = sPostCallbackIndex;
		}
		
		oAjaxRequest.onreadystatechange = function() {
			if (sPostCallbackIndex != null) {
				clearTimeout(iPostCallbackTimeout); iPostCallbackTimeout = setTimeout("jAjaxPostCallback();", 10);
			}
		}
		
		oInjectionElement.innerHTML = (sLoadingHTML != null) ? sLoadingHTML : sDefaultLoadingHTML;
		
		oAjaxRequest.open("POST", sRequestURL, true); // Avoid page cache..
		oAjaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oAjaxRequest.send("Hash=" + Math.random() + ((sRequestVars != null) ? sRequestVars : "")); // Send the request..
	}
	
	/* toggles the ajax screen's visibility. */
	function jShowAjaxScreen(bValue) {
		document.getElementById("AjaxBackgroundContainer").style.display = (bValue) ? "" : "none";
	}
	
	/* initializes a new ajax object. */
	function jCreateAjaxRequest() {
		var oAjaxRequest;
		
		try {
			oAjaxRequest = new XMLHttpRequest(); // Opera, Firefox, Safari..
		} catch (e) {
			try {
				oAjaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer..
			} catch (e) {
				try {
					oAjaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer..
				} catch (e) {
					return false;
				}
			}
		}
		
		return oAjaxRequest;
	}
	
	function jAjaxPostCallback() {
		
		switch (sPostCallback) {
		case "FocusLoginPassword":
			
			if (jGetCookie("Username") != null) {
				document.forms["MemberLogin"]["Password"].focus();
			} else {
				document.forms["MemberLogin"]["Username"].focus();
			}
			
			break;
		
		}
	
	}
	
