// NOTE: The IE6 xml ActiveXObject does not support user properties, so I've had to resort to this involuted syntax
var display_debug = true

function xmlcontainer()
{
var thiss = this; // private member function accessible to internal methods later
if (window.XMLHttpRequest) this.xmlob = new XMLHttpRequest()
else if (window.ActiveXObject) this.xmlob = new ActiveXObject("Microsoft.XMLHTTP")// code for IE
else { alert("Your browser does not support XMLHTTP."); return }

this.must_reset = false // need to reset object after first call

this.loadXMLDocplus = function(url, usercall) // public method
    {
    //alert( "called with "+url+" and function: "+usercall )
    if ( thiss.must_reset ) thiss.xmlob.abort()
    thiss.userfun = usercall ? usercall : null
    thiss.query = url
    thiss.cachedresult = 'none'
    thiss.xmlob.onreadystatechange=thiss.state_Change
    thiss.xmlob.open("GET",url,usercall != 1 ) // true unless usercall is == 1
    thiss.xmlob.send(null)
    //alert( "called" )
    thiss.must_reset = true
    }


this.state_Change = function () // public method
    {
    //alert( "ready state = "+ thiss.xmlob.readyState + "status " + thiss.xmlob.status )
    //thiss.cachedresult = thiss.xmlob.responseText
    if (thiss.xmlob.readyState==4)
        {
        /*if ( display_debug )
                {
                display_debug = false                //display_debug = true
                var debtext = "xmlob: ";
                for ( x in thiss.xmlob )
                      {
                      debtext += x + '\n' // + ' = ' + thiss.xmlob[x].toString() +
                      //var typ = typeof thiss.xmlob[x]
                      //if ( ( typ == 'number' ) || ( typ == 'string' ) || ( typ == 'boolean' ) )  debtext += thiss.xmlob[x]
                      //else
                      //debtext += typ
                      //debtext += "\n"
                      }
                dump( debtext )

                }*/
        if ( thiss.userfun == 1 ) return; //dump( thiss.query + ' / ' + thiss.xmlob.readyState + '\n' )
        // if "OK"
        if (thiss.xmlob.status==200)
            {
            //document.getElementById('T1').innerHTML=xmlhttp.responseText
            if ( thiss.userfun == 1 ) return
            if ( thiss.userfun == null ) return
            /*     {
                 var thingy = new Function( thiss.xmlob.responseText );
                 alert( thingy )
                 thingy();
                 }
            else
                {*/
            //alert( "usercall is " + thiss.userfun + "and data is " + thiss.xmlob.responseText );
            thiss.userfun(thiss.xmlob, thiss )
            }
        else
            {
            alert("Problem retrieving data: for [" + thiss.query + "] = ", thiss.xmlob.statusText)
            }
        }
    }

}

// example:
// <script type='text/javascript' src='xmlhttp.js'></script>
// thing = new xmlcontainer()
// thing.loadXMLDocplus(url, usercallback )
