var ajax = new AjaxRequest("status");
ajax.readyStateMsg0 = "list";
ajax.readyStateMsg1 = "loading.";
ajax.readyStateMsg2 = "loading..";
ajax.readyStateMsg3 = "loading...";

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function handleStateChange() {
	// alert('handleStateChange'+xmlHttp.readyState);
	if(xmlHttp.readyState == 4) {
		 // alert(xmlHttp.status);
        if(xmlHttp.status == 200) {
            // alert(xmlHttp.responseText); 
			// op dit punt is de database aangepast
			if (xmlHttp.responseText>"") {
				//alert(xmlHttp.responseText);
				var str = xmlHttp.responseText;
				var str_check = str.search("DEBUG") ;
				// if (str_check != -1) { alert ("Background Batch Process Finished : "+str.substring(5,1000)); }
			}
        }
		// xmlHttp.status 401 >> access denied
		// xmlHttp.status 404 >> file not founc
		// xmlHttp.status 500 >> cannot be used
    }
}

function StartBatchProcess(id,scr,debug) { 
    createXMLHttpRequest();
    if (debug=="DEBUG") { 
		// dan roepen we de batch rechtstreeks op de MYS op
		var url = "http://www.manageyoursite.be/_MYS/batch/"+id+"/"+scr+"?debug=DEBUG";
		var url = "BATCH/"+scr+"?id="+id;  }
	else { 
		// dan roepen we de batch via de klant op
		var url = "BATCH/"+scr+"?id="+id; 
	}
	// alert(url);
	//alert(window.location);
	xmlHttp.open("GET", url, true);
	// alert('xml opened');
	xmlHttp.onreadystatechange = handleStateChange;
    // alert('xml state changed');
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");   
	xmlHttp.send(null);
	// onderstaande coding is voor Mozzila
	if (!window.ActiveXObject) {
		if (xmlhttp.onreadystatechange == null) handleStateChange();
	}
}

