var xmlHttp;
var element;

//Deze functie maakt een XmlHttpObject aan
function maakXmlHttpObject(){  
var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

//Deze functie wordt uitgevoerd als er een response wordt teruggegeven
function stateChanged()
{ 
	if (xmlHttp.readyState==4){ 
		document.getElementById(element).innerHTML=xmlHttp.responseText;
	}
}

//functie om get ajax aan te roepen
function getAjax(el,url){
	try{
		xmlHttp = maakXmlHttpObject();
	}catch(e){}

	try{
		if(xmlHttp==null){
			alert ("Je browser ondersteunt geen HTTP Request!");
		}else{
			url+="&sid="+Math.random();
			element = el;
			xmlHttp.onreadystatechange=stateChanged;
			xmlHttp.open("GET",httphost+"ajax.php?"+url,true);
			xmlHttp.send(null);
		}
	}catch(e){}
}

//functie om post ajax aan te roepen
function postAjax(el,url,data){
	try{
		xmlHttp = maakXmlHttpObject();
	}catch(e){}
	
	if (xmlHttp==null){
		alert ("De browser ondersteunt geen HTTP Request!");
	}else{
		element = el;
		type = url;
		xmlHttp.open("POST",httphost+"ajax.php?sid="+Math.random()+"&type="+url,true);
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(data);	
	}
}
