var oXmlUser = {
    oXmlHttp:     Object(),    
    rcTekst: 	  Array(), 
    lastState:    0,
    berichtHdr:   "",
    berichtTxt:   "",
    response:     "",
    Url:	  "",
    doNext:       "",
    rc:           0,
    aReadyState:  Array,

    fInitTekst:	  function() 				 
			{
			    oXmlUser.rcTekst[0] = "00 - Uitvoering goed verlopen."
			    oXmlUser.rcTekst[1] = "01 - Ongeldig wachtwoord."
    		    	    oXmlUser.rcTekst[2] = "02 - Fout bij naam wijzigen."
    		    	    oXmlUser.rcTekst[3] = "03 - Fout bij verwijderen."
    		    	    oXmlUser.rcTekst[4] = "04 - Fout bij lezen bestand."
    		    	    oXmlUser.rcTekst[5] = "05 - Fout bij schrijven bestand."
    		    	    oXmlUser.rcTekst[6] = "06 - Fout bij openen bestand."
    		    	    oXmlUser.rcTekst[7] = "07 - Bestand  aanwezig."
    		    	    oXmlUser.rcTekst[8] = "08 - Bestand niet aanwezig."
    		    	    oXmlUser.rcTekst[9] = "09 - Geen return gevonden."
    		    	    oXmlUser.rcTekst[10] = "10 - Communicatie fout."

    		    	    oXmlUser.aReadyState[0] = "0 The request is not initialized." 
    		    	    oXmlUser.aReadyState[1] = "1 The request has been set up." 
    		    	    oXmlUser.aReadyState[2] = "2 The request has been sent." 
    		    	    oXmlUser.aReadyState[3] = "3 The request is in process." 
    		    	    oXmlUser.aReadyState[4] = "4 The request is completed." 
		  	},

    fInitXmlHttp: function() 
		  	{
			    oXmlUser.fInitTekst();

		    	    var ua = navigator.userAgent.toLowerCase();

		    	    if (!window.ActiveXObject) 
		      	    	oXmlUser.oXmlHttp = new XMLHttpRequest();

		    	    else if (ua.indexOf('msie 5') == -1)
		            	oXmlUser.oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

		    	    else
		            	oXmlUser.oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		  	},


    fSendEnVervolg: function() 
			{

			    oXmlUser.fInitXmlHttp();
			    oXmlUser.oXmlHttp.open("POST", oXmlUser.Url);
			    oXmlUser.oXmlHttp.onreadystatechange = oXmlUser.fResponseHandler;

			    oXmlUser.oXmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			    var sWerk = encodeURI(oXmlUser.berichtHdr);

			    oXmlUser.oXmlHttp.send(sWerk);
			    oXmlUser.lastState = 0;
			},

    fResponseHandler: function() 
			{
			    oXmlUser.rc = 9;
			    oXmlUser.response = oXmlUser.rcTekst[oXmlUser.rc];

			    oXmlUser.lastState = oXmlUser.oXmlHttp.readyState;
			    if (oXmlUser.oXmlHttp.readyState == 4) 
			    {  
			    	if (oXmlUser.oXmlHttp.status == 200 ) 
			    	{
				    oXmlUser.response = trim(oXmlUser.oXmlHttp.responseText); 	// Dit is tekst + #rc=
				    aWerk = oXmlUser.response.split("#");
				    if (aWerk.length == 0)
				        oXmlUser.rc = 9;		 			// Geen #rc= aanwezig

				    else
				        oXmlUser.rc = aWerk.pop().substring(3)    		//ophalen RC

				    if (oXmlUser.rc != 0) oXmlUser.response = oXmlUser.rcTekst[oXmlUser.rc] 	//ophalen fout tekst
				    else oXmlUser.response = aWerk.join("#") 		//ophalen msg tekst
		
				    eval(oXmlUser.doNext)				//vervolg bij caller
			    	}

			    	else
			    	{
			    	    alert("Communicatie niet goed verlopen:\n" + 
		 	                  	"readyState: " + oXmlUser.aReadyState[oXmlUser.lastState] + "\n" + 
						"status: " + oXmlUser.oXmlHttp.status );
			    	    oXmlUser.oXmlHttp.close;

				    oXmlUser.rc = 10;
				    oXmlUser.response = oXmlUser.rcTekst[oXmlUser.rc] 	//ophalen fout tekst
				    eval(oXmlUser.doNext)				//vervolg bij caller
			    	}
			    }
			}
}
