function WEB_getXMLHttpRequest()	{

	// ActiveXObject IE en XMLHttpRequest firefox
	if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}

	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}
}

function WEB_setXMLHttpRequestResult(destination,content,mode)	{
	if(mode == "replacechildren"){
		try {
			if (document.getElementById(destination)){
				document.getElementById(destination).innerHTML = content;
			}else{
				alert ("destination: "+destination+" niet gevonden");
			}
		} catch(err){
			alert(err.description);
		}
	}else if(mode == "replace"){
		if (document.getElementById(destination)){
			document.getElementById(destination).outerHTML = content;
		}else{
			alert ("destination: "+destination+" niet gevonden");
		}
	}
}

function WEB_getdata(object)	{
	document.getElementById('cover').style.display = 'block';
	document.getElementById('foto_popup').innerHTML = '';
	document.getElementById('foto_popup').style.display = 'block';
	
	try{
		var XMLdata = WEB_getXMLHttpRequest();
		var url = object.attributes['w:url'].nodeValue;
		var destination = object.attributes['w:destination'].nodeValue;
		var mode = object.attributes['w:mode'].nodeValue;

	}catch(err){
		var txt = "WEB_getdata() niet goed opgemaakt!.\n\n";
		txt += "Error description: " + err.description + "\n\n";
		alert(txt);
		return;
	}

	WEB_createOnReadystateChange(object, XMLdata, url, destination, mode);
}

function WEB_createOnReadystateChange(obj, obj_xml, url, destination, mode){
	try{
		obj_xml.onreadystatechange = function(){
			if (obj_xml.readyState == 4){
				WEB_setXMLHttpRequestResult(destination, obj_xml.responseText, mode);
			} 
		}
		
		WEB_sendData(obj_xml, url, obj);
	}catch(err){
		var txt = "WEB_createOnReadystateChange() niet goed opgemaakt!.\n\n";
		txt += "Error description: " + err.description + "\n\n";
		alert(txt);
		return;
		
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function WEB_sendData(obj_xml, url, obj){
	var queryStr = url.split("?");
	if (queryStr[0] == ''){
		queryStr[0] = url;
	}

	
		obj_xml.open('POST', queryStr[0], true);
	
	obj_xml.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	obj_xml.send(queryStr[1]);
}
