function getRS(rootnode, iCurRec, sFieldName){
	/*
	   Function allows you to read an XML structure like a
	   ADO recordset.

	   Variables:
	  				rootnode		:reference to root XML object
	  				iCurRec			:current child node record
	  				sFieldName	:field we are looking for in XML record
	   Assumptions:		Function assumes XML string will look like this:
	  		<tablename>
	  			<row>
	  				<field1>data1</field1>
	  				<field2>data2</field2>
	  			</row>
	  		</tablename>

	  	example:
	  		<tbl_Employee>
	  			<EmployeeRow>
	  				<FirstName>John</FirstName>
	  				<LastName>Doe</LastName>
	  			</EmployeeRow>
	  			<EmployeeRow>
	  				<FirstName>Jane</FirstName>
	  				<LastName>Doe</LastName>
	  			</EmployeeRow>
	  		</tbl_Employee>

		Naviating the tree:

		rootnode												Root node (tbl_Employee)
			.childNodes.item(iCurRec)			The nth level 2 node (EmployeeRow)
				.childNodes.item(iField)		The nth level 3 node (FirstName)
					.tagName									Name of the 3ed node (ie FirstName)
					.childNodes.length				Number of 3ed level child nodes.
																			(0 if no data 1 if has data)
					.childNodes.item(0).text	Value of 4th level node

	*/
	var iField;
	var sData;
	sData = "";
	//alert(rootnode)
	for (iField = 0 ; iField < rootnode.childNodes.item(iCurRec).childNodes.length ; iField++){
		if (rootnode.childNodes.item(iCurRec).childNodes.item(iField).tagName  == sFieldName){
			if (rootnode.childNodes.item(iCurRec).childNodes.item(iField).childNodes.length > 0){
				sData = rootnode.childNodes.item(iCurRec).childNodes.item(iField).childNodes.item(0).text;
				}
			else {
				sData = "_";
				}
			}
		}
	if (sData == "#20") {
		sData = "&nbsp;";
	}
	return(sData);
	}


function httpRequestPostX(url, callback, type, values, extraValue) {
	//alert(values)
    var httpObj = false;
    if (typeof XMLHttpRequest != 'undefined') {
        httpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try{
            httpObj = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {
            try{
                httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
            } catch(e) {}
        }
    }
    if (!httpObj) return;

    httpObj.onreadystatechange = function() {
        if (httpObj.readyState == 4) { // when request is complete
        	if (httpObj.status == 200) {
				if (type == "data"){
					callback(httpObj.responseText, extraValue);
				}else{
					callback(httpObj.responseXML, extraValue);
				}
			}
        }
    };
    httpObj.open('POST', url, true);
    httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    httpObj.send(values);
}


function httpRequestPost(url, callback, type, values) {
	//alert(values)
    var httpObj = false;
    if (typeof XMLHttpRequest != 'undefined') {
        httpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try{
            httpObj = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {
            try{
                httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
            } catch(e) {}
        }
    }
    if (!httpObj) return;

    httpObj.onreadystatechange = function() {
        if (httpObj.readyState == 4) { // when request is complete
        	if (httpObj.status == 200) {
				if (type == "data"){
					callback(httpObj.responseText);
				}else{
					callback(httpObj.responseXML);
				}
			}
        }
    };
    httpObj.open('POST', url, true);
    httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    httpObj.send(values);
}


function httpRequest(url, callback, type) {
    var httpObj = false;
    if (typeof XMLHttpRequest != 'undefined') {
        httpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try{
            httpObj = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e) {
            try{
                httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
            } catch(e) {}
        }
    }
    if (!httpObj) return;

    httpObj.onreadystatechange = function() {
        if (httpObj.readyState == 4) { // when request is complete
        	if (httpObj.status == 200) {
				if (type == "data"){
					callback(httpObj.responseText);
				}else{
					if (type == "doc"){
						callback(httpObj);
					}else{
						callback(httpObj.responseXML);
					}
				}
			}
        }
    };
    httpObj.open('GET', url, true);
    httpObj.send(null);
}


function getFormValues(fobj){
	//alert("got here")
   var str = "";
   var valueArr = null;
   var val = "";
   var cmd = "";
   for(var i = 0;i < fobj.elements.length;i++){
       switch(fobj.elements[i].type){
		   case "text" || "textarea":
		   		//alert("got here")
				str += fobj.elements[i].name + "=" + thisEscape(fobj.elements[i].value) + "&";
				break;

		   case "select-one":
				str += fobj.elements[i].name + "=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&";
				break;

		   case "checkbox":
		   		if (fobj.elements[i].checked){
					str += fobj.elements[i].name + "=on&";
				}else{
					str += fobj.elements[i].name + "=off&";
				}
				break;

		   case "button":
		   		break;
		
		   case "radio":
		   		if (fobj.elements[i].checked){
					var strResult = thisEscape(fobj.elements[i].value)
			   		str += fobj.elements[i].name + "=" + strResult + "&";
				}
				break;

		   default:
		        var strResult = thisEscape(fobj.elements[i].value)
		   		str += fobj.elements[i].name + "=" + strResult + "&";
				break;
       }
   }
   str = str.substr(0,(str.length - 1));
   return str;
}

function thisEscape(s){
	return escape(s).replace(new RegExp('\\+','g'), '%2B');

}

