	function Qform__PostBack(strForm, strControl, strEvent, strParameter) {
		var objForm = eval("document." + strForm);
		objForm.Qform__FormControl.value = strControl;
		objForm.Qform__FormEvent.value = strEvent;
		objForm.Qform__FormParameter.value = strParameter;
		objForm.Qform__FormCallType.value = "Server";
		objForm.submit();
	}

	var objAjaxQueue = new Array();

	function Qform__PostAjax(strForm, strControl, strEvent, strParameter) {
		// Figure out if Queue is Empty
		var blnQueueEmpty = false;
		if (objAjaxQueue.length == 0)
			blnQueueEmpty = true;

		// Enqueue the AJAX Request
		objAjaxQueue.push(new Array(strForm, strControl, strEvent, strParameter));
		//alert('PostAjax: form='+strForm+' control='+strControl+' event='+strEvent+' param='+strParameter);

		// If the Queue was originally empty, call the Dequeue
		if (blnQueueEmpty)
			Qform__AjaxDequeue();
	}

	function Qform__AjaxClearQueue() {
		objAjaxQueue = new Array();
	}

	function Qform__AjaxDequeue() {
		if (objAjaxQueue.length > 0) {
			strForm = objAjaxQueue[0][0];
			strControl = objAjaxQueue[0][1];
			strEvent = objAjaxQueue[0][2];
			strParameter = objAjaxQueue[0][3];
			//alert('AjaxDequeue: form='+strForm+' control='+strControl+' event='+strEvent+' param='+strParameter);

			var objForm = eval("document." + strForm);
			objForm.Qform__FormControl.value = strControl;
			objForm.Qform__FormEvent.value = strEvent;
			objForm.Qform__FormParameter.value = strParameter;
			objForm.Qform__FormCallType.value = "Ajax";
	
			var strPostData = "";
			for (var i = 0; i < objForm.elements.length; i++) {
				strPostData += "&" + objForm.elements[i].id + "="
				strPostData += escape(objForm.elements[i].value);
			}
			
			var strUri = objForm.action;
					
			var objRequest;
			if (window.XMLHttpRequest) {
				objRequest = new XMLHttpRequest();
			} else if (typeof ActiveXObject != "undefined") {
				objRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			
			if (objRequest) {
				objRequest.open("POST", strUri, true);
				objRequest.setRequestHeader("Method", "POST " + strUri + " HTTP/1.1");
				objRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
				objRequest.onreadystatechange = function() {
					//alert('onreadystatechange: readystate='+objRequest.readyState);
					if (objRequest.readyState == 4) {
						try {
							var objXmlDoc = objRequest.responseXML;

							if ((!objXmlDoc) || (!objXmlDoc.documentElement)) {
								alert("An error occurred during AJAX Response parsing.\r\n\r\nThe error response will appear in a new popup.");
								var objErrorWindow = window.open('about:blank', 'qcodo_error','menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=1000,height=700,left=50,top=50');
								objErrorWindow.focus();
								objErrorWindow.document.write(objRequest.responseText);
								return;
							} else {
								var intLength = 0;

								// Go through Controls
								var objXmlControls = objXmlDoc.getElementsByTagName('control');
								intLength = objXmlControls.length;
//								alert('onreadystatechange: xml='+objRequest.responseText);

								for (var intIndex = 0; intIndex < intLength; intIndex++) {
									var strControlId = objXmlControls[intIndex].attributes.getNamedItem('id').nodeValue;
									var strControlHtml = objXmlControls[intIndex].firstChild.nodeValue;
//									alert('onreadystatechange: strControlId='+strControlId+', strControlHtml='+strControlHtml);

									// Perform Callback Responsibility
									if (strControlId == "Qform__FormState") {
										var objFormState = document.getElementById(strControlId);
										objFormState.value = '';
										for (j=0;j<objXmlControls[intIndex].childNodes.length;j++)
										{
											objFormState.value += objXmlControls[intIndex].childNodes[j].nodeValue;
										}
									} else {
										var objSpan = document.getElementById(strControlId + "_ctl");
										if (objSpan)
											objSpan.innerHTML = strControlHtml;
									}
								}


								// Go through Commands
								var objXmlCommands = objXmlDoc.getElementsByTagName('command');
								intLength = objXmlCommands.length;

								for (var intIndex = 0; intIndex < intLength; intIndex++) {
									var strCommand = objXmlCommands[intIndex].firstChild.nodeValue;
									eval(strCommand);
								}
							}
						} catch (objExc) {
							alert("An error occurred during AJAX Response handling.\r\n\r\nThe error response will appear in a new popup.");
							var objErrorWindow = window.open('about:blank', 'qcodo_error','menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=1000,height=700,left=50,top=50');
							objErrorWindow.focus();
							objErrorWindow.document.write(objRequest.responseText);
							return;
						}

						// Perform the Dequeue
						objAjaxQueue.reverse();
						objAjaxQueue.pop();
						objAjaxQueue.reverse();

						// If there are still AjaxEvents in the queue, go ahead and process/dequeue them
						if (objAjaxQueue.length > 0)
							Qform__AjaxDequeue();
					}
				}

				objRequest.send(strPostData);
			}
		}
	}

	function Qform__ResetTimer(strControlId) {
		var objTimer = eval("window." + strControlId);
		if (objTimer) {
			clearTimeout(objTimer);
			objTimer = null;
		}
	}

	function Qform__TriggerDelayedAction(strControlId, strAction, intDelay) {
		Qform__ResetTimer(strControlId);

		eval("window." + strControlId + " = setTimeout(strAction, intDelay)");
	}

	function Qform__GetControl(strControlId) {
		return document.getElementById(strControlId);
	}

	function Qform__GetControlWrapper(strControlId) {
		return document.getElementById(strControlId + "_ctl");
	}

	function Qform__ToggleControlDisplay(strControlId, strShowOrHide, strDefaultDisplayStyle) {
		var objControl = Qform__GetControl(strControlId);
		if (strShowOrHide) {
			if (strShowOrHide == 'show')
				objControl.style.display = strDefaultDisplayStyle;
			else
				objControl.style.display = 'none';
		} else {
			objControl.style.display = (objControl.style.display == 'none') ? strDefaultDisplayStyle : 'none';
		}
	}

	function Qform__ToggleControlWrapperDisplay(strControlId, strShowOrHide) {
		var objControl = Qform__GetControlWrapper(strControlId);
		if (strShowOrHide) {
			if (strShowOrHide == 'show')
				objControl.style.display = 'inline';
			else
				objControl.style.display = 'none';
		} else {
			objControl.style.display = (objControl.style.display == 'none') ? 'inline' : 'none';
		}
	}

	function Qform__ToggleControlDisabled(strControlId, strEnableOrDisable) {
		var objControl = Qform__GetControl(strControlId);

		if (strEnableOrDisable) {
			if (strEnableOrDisable == 'enable')
				objControl.disabled = false;
			else
				objControl.disabled = true;
		} else {
			objControl.disabled = (objControl.disabled) ? false : true;
		}
	}
