// MSXML Asynchronous Web Service Access
//
// by Kimara Sajn
//
// (c) 2000 General Rubric, Inc
//


// global MSXML object
var mosHttpObj;

// return a usable instance of the MSXML object
function createServerConn() {
	var xmlhttp;

	// open an instance of the XML parser object
	try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	} catch (e) {
		try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		} catch (E) {
			xmlhttp=false
		}
	}
	
	if (!xmlhttp) {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false
		}
	}
	
	return xmlhttp;
}

// open a connection via the global mosHttpObj to URL (returns the responseText)
function serverGet(url) {
	mosHttpObj = createServerConn();
	try {
		mosHttpObj.open("GET", url, false);
		mosHttpObj.onreadystatechange=function() {
			if (mosHttpObj.readyState==4) {
				// alert(mosHttpObj.getAllResponseHeaders());
				// alert(mosHttpObj.responseText);
			}
		}
		mosHttpObj.send(null)
		return mosHttpObj.responseText;
	}
	catch (e) {
		return "";
	}
}

// MSXML DOM HANDLERS

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
function loadXML(xmlFile) {
    xmlDoc.async="false";
    xmlDoc.onreadystatechange=verify;
    xmlDoc.load(xmlFile);
}

function verify() { 
    if(xmlDoc.readyState!=4)
        return false; 
}

function traverse(tree) {
    if(tree.hasChildNodes()) {
        document.write('<ul><li>');
        document.write('<b>'+tree.tagName+' : </b>');
        var nodes=tree.childNodes.length;
        for(var i=0; i<tree.childNodes.length; i++)
            traverse(tree.childNodes(i));
        document.write('</li></ul>');
    }
    else
        document.write(tree.text);
}

function initTraverse(file) {
    loadXML(file);
    var doc=xmlDoc.documentElement;
    traverse(doc);
}


