/*
  xml.js

  SofCon s.r.o
  Petr Cernin, 2002
*/


var xmlRefresh = 1;
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
var xmlTimerId = null;

//------------------------------------------------------------
// xmlGetValue

function xmlGetValue( path )
{
	var node = xmlDoc.getElementsByTagName( path ).item(0);
	if (node != null) return node.text; else return "N/A";
}


//------------------------------------------------------------
// xmlCheckState

function xmlCheckState()
{
	if (xmlDoc.readyState == 4) // Completed
	{
		if (xmlDoc.parseError != 0) 
		{
			if (xmlTimerId != null) window.clearInterval( xmlTimerId );
			alert( "Nelze načíst data ze serveru http://" + 
					queryGetVal( "url" ) + "/\n" +
					xmlDoc.parseError.reason );

		}
		else
		{
			xmlLoadCompleted();
		}
	}
}

//------------------------------------------------------------
// xmlLoad

function xmlLoad( document )
{
	if (xmlDoc.readyState == 4)
	{
		var url = queryGetVal( "url" );

		if (url != null)
		{	
			window.status = "[" + xmlRefresh++ + "]";
			xmlDoc.async = true;
			xmlDoc.onreadystatechange = xmlCheckState;
			xmlDoc.load( "http://" + url + "/" + document );
		}
	}
}


