

function get_xml_then(url_obj, cb_obj, custom_error_msg) {
var req;
var xml_error_message = (custom_error_msg!=undefined) ? custom_error_msg:"Error";

if (!url_obj.url) {
	alert(xml_error_message);
	return false;
	}
if (!cb_obj) {
	cb_obj = new Object();
	}

var url       = url_obj.url;
var method    = "GET";
var cb_func   = (cb_obj.func)    ? (cb_obj.func):("");
var cb_arg    = (cb_obj.arg)     ? ((cb_obj.arg.toLowerCase()=="text") ? ("req.responseText"):("req.responseXML")):("req.responseXML");
var cb_custom = (cb_obj.custom)  ? (cb_obj.custom):("");

if (window.XMLHttpRequest) {
    // branch for native XMLHttpRequest object
    req = new XMLHttpRequest();
    req.onreadystatechange = function() {
        // only if req shows "loaded"
        if (req.readyState == 4) {
            // only if "OK"
            if (req.status == 200) {
                // ...processing statements go here...
                if (cb_func) {
	                cb_func+="("+cb_arg+")";
                    eval(cb_func);
                    }
                else if (cb_custom) {
                    eval(cb_custom);
                    }
                //else no actions to take =>send to server only
                }
            else {
                alert("ERROR: "+xml_error_message+"\n\n"+req.statusText);
                return false;
                }
            }
        }
    req.open(method, url, true);
    req.send(null);
    }
else if (window.ActiveXObject) {
    // branch for IE/Windows ActiveX version
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if (req) {
        req.onreadystatechange = function() {
            // only if req shows "loaded"
            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {
                    // ...processing statements go here...
                    if (cb_func) {
	                    cb_func+="("+cb_arg+")";
                        eval(cb_func);
                        }
                    else if (cb_custom){
                        eval(cb_custom);
                        }
                    //else no actions to take =>send to server only
                    }
                else {
                    alert("ERROR: "+xml_error_message+"\n\n"+req.statusText);
                    return false;
                    }
                }
            }
        req.open(method, url, true);
        req.send();
        }
    }
}


function get_node_value(xml_str,node_name) {
cdata_section = "<![CDATA[";
index_begin = xml_str.indexOf("<"+node_name);
index_end   = (xml_str.indexOf("</"+node_name)!=-1) ? xml_str.indexOf("</"+node_name):index_begin;

node_value = (index_begin!=index_end) ? xml_str.substring(xml_str.indexOf(">",index_begin)+1, index_end):"";
if (node_value.indexOf(cdata_section)!=-1) {
    node_value = node_value.substring( node_value.indexOf(cdata_section) + cdata_section.length, node_value.lastIndexOf("]]>"));
    }

return node_value;
}
