// JavaScript Document

// ---	getHTTPObject detects for Microsoft browsers 
//		and returns the XMLHTTP object
function getHTTPObject () { 
	if ( typeof XMLHttpRequest != 'undefined' ) {
		return new XMLHttpRequest ();
	}
	try {
		return new ActiveXObject ( "Msxml2.XMLHTTP" );
	}
	catch (e) {
		try {
			return new ActiveXObject ( "Microsoft.XMLHTTP" ); 
		}
		catch (e) {}
	}
	return false;
}

// ---	getXML calls for creation of the XMLHTTPResponse object (oHTTP)
var oHTTP 	= new Object ();
var curr_node;
function getXML ( caption_xml, node_name ) {
	//alert ( 'getXML ( caption_xml:' + caption_xml +', node_name:' + node_name + ' );' );
	curr_node 	= node_name;
	oHTTP 		= getHTTPObject ();
	oHTTP.open ( "GET", caption_xml, true );
	oHTTP.onreadystatechange 	= useHTTPResponse;
	oHTTP.send ( null );
}
// ---	useHTTPResponse is triggered after XMLHTTP object (oHTTP) retreives the XML file
function useHTTPResponse () {
	if ( oHTTP.readyState == 4 ) {
		// ---	loop through the nodes to get the root node
		for ( i = 0;  i < oHTTP.responseXML.documentElement.childNodes.length;  i++ ) {
			if ( oHTTP.responseXML.documentElement.childNodes[ i ].nodeType == 1 ) { // avoid selecting white space: "#text"
				var oXML 	= oHTTP.responseXML.documentElement.childNodes[ i ];
				if ( oXML.nodeName == curr_node ) {
					document.getElementById ( 'caption' ).innerHTML = oXML.childNodes[ 0 ].nodeValue;
				}
			}
		}
	}
}


