

function NetXML_load( )
{
	if( this.xmlReq )
	{
		
		// Make the request
		this.xmlReq.open ('GET', this.url, true);	

		// Anonymous function to handle changed request states
		var r = this;
		this.xmlReq.onreadystatechange = function(){ r.stateChange( ); };
	
		
		this.xmlReq.send (null);	
		
		trace( 'NetXML.load ' + this.url );
	}
	else
	{
		error('NetXML.load ' + this.url);
	}
	
}


function NetXML_stateChange( )
{
	switch( this.xmlReq.readyState )
	{
		case 0: // Uninitialized
			break;
		case 1: // Loading
			this.onProgress();
			break;
		case 2: // Loaded
			break;
		case 3: // Interactive
			break;
		case 4: // Done!
			this.onLoad();
			break;
		default:
			break;
	}
}

function NetXML_dummy()
{
	/* i am stupid */
}

function NetXML( url )
{	
	this.url = url;	
	
	
	/* member functions */	
	this.load = NetXML_load;
	this.stateChange = NetXML_stateChange;
	this.onProgress = NetXML_dummy;
	this.onLoad = NetXML_dummy;
	
	// Create the XML request
    this.xmlReq = null;
    if( window.XMLHttpRequest )
	{
		this.xmlReq = new XMLHttpRequest();
	}
    else 
	if( window.ActiveXObject )
	{
		this.xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
    if( this.xmlReq==null ) 
	{
		/* shit */
		error( "Failed to create NetXML" );
		return; // 
	}
	
	trace('NetXML( url )');
}
