	function doXmlRequest(url, bodyContent) {
		var req = null;

		try {
			if( window.XMLHttpRequest ) {
				req = new XMLHttpRequest();
				req.open("POST", url, false);
				req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				req.send(bodyContent);
			// branch for IE/Windows ActiveX version
			} else if( window.ActiveXObject ) {
				req = new ActiveXObject("Microsoft.XMLHTTP");

				if( req ) {
					req.open("POST", url, false);
					req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					req.send(bodyContent);
				}
			}
		} catch( e1 ) {
			return null;
		}

		return req;
	}

	function isErrorDoc(root) {
		return root.nodeName == "Errors";
	}

	function defaultShowErrors(root) {
		if( isErrorDoc(root) ) {
			var node = root.firstChild;
			
			while( node != null ) {
				var fldName = node.getAttribute("fld");
				elem = document.getElementById(fldName + "Error");

				if( elem != null ) {
					elem.innerHTML = node.getAttribute("msg");
					elem.style.display = 'block';
				} else {
					alert("Couldn't find error div for " + fldName);
				}

				node = node.nextSibling;
			}
		}
	}

	function handleResponse(req, fnCommSuccess, fnCommError, fnFormSubmitSuccess) {
		if( req == null )
			return false;

		if( req.status == 200 ) {
			if( fnCommSuccess != null )
				fnCommSuccess(req, fnCommError, fnFormSubmitSuccess);
			else
				defaultCommSuccess(req, fnCommError, fnFormSubmitSuccess);

		} else {
			fnCommError(req);
		}
	}

	function defaultCommSuccess(req, fnCommError, fnFormSubmitSuccess) {
		var xml = req.responseXML;

		if( xml == null ) {
			fnCommError();
		} else {
			var root = xml.documentElement;

			if( isErrorDoc(root) ) {
				defaultShowErrors(root);
			} else {
				fnFormSubmitSuccess();
			}
		}
	}


	function resetErrorMessage(frm) {
		for( var i = 0; i < frm.elements.length; i++ ) {
			var fld = frm.elements[i];
			elem = document.getElementById(fld.name + "Error");
			if( elem != null )
				elem.style.display = 'none';
		}
	}
	
	function getFormBodyContent(frm, fnErrorReadingData) {
		var bodyContent = "";
		var elem = null;

		resetErrorMessage(frm);

		for( var i = 0; i < frm.elements.length; i++ ) {
			var fld = frm.elements[i];

			var v = fld.value;
			
			if( v != null && v.length > 0 ) {
				v = trimAll(v);
				
				if( v.length > 2048 ) {
					fnErrorReadingData();
				}

				bodyContent += encodeURIComponent(fld.name) + "=" + encodeURIComponent(v) + "&";
			}
		}
		//alert(bodyContent);
		return bodyContent;
	}

	function trimAll(sString) {
		while (sString.substring(0,1) == ' ')
			sString = sString.substring(1, sString.length);
		
		while (sString.substring(sString.length-1, sString.length) == ' ')
			sString = sString.substring(0,sString.length-1);
		
		return sString;
	}	