var xmlHttp;

function getDiscount(code) { 
	xmlHttp = GetXmlHttpObject()
	if (xmlHttp == null){
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="/mod/discount_get.php?sDiscount_code="+code+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		xmlDoc = xmlHttp.responseXML;
		document.getElementById("sDiscount_value").value= xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue;
		if(xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue > 0){
			document.getElementById("sDiscount_value_display").innerHTML= 'De hierboven getoonde prijzen zijn inclusief ' + xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue + '% korting';
		}
		
		if(xmlDoc.getElementsByTagName("error")[0].childNodes[0].nodeValue != 0){
			document.getElementById("sDiscount_error").innerHTML = xmlDoc.getElementsByTagName("error")[0].childNodes[0].nodeValue;
		}else{
			document.getElementById("sDiscount_error").innerHTML = '';
		}
		endQuestion2(true);
	}
} 

function GetXmlHttpObject(){ 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
