// JavaScript Document
function getHTTPRequestObject() {
  var xmlHttpRequest;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (exception1) {
      try {
        xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (exception2) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttpRequest = false;
  @end @*/
 
  if (!xmlHttpRequest && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlHttpRequest = new XMLHttpRequest();
    } catch (exception) {
      xmlHttpRequest = false;
    }
  }
  return xmlHttpRequest;
}

var httpRequester = getHTTPRequestObject(); // Create the xml http object on the page load

function process_send_form() {
	if ( httpRequester.readyState == 4) {
		if ( httpRequester.status == 200) {
		//	window.alert (httpRequester.responseText);
			document.getElementById("formulier").innerHTML = '';
			document.getElementById("contactResult").innerHTML = '<strong>' + httpRequester.responseText + '</strong>';
		} else {
			//window.alert ("Er is een fout opgetreden, probeer het nogmaals");
			document.getElementById("contactResult").innerHTML = "Er is een fout opgetreden, probeer het nogmaals";

		}
	}	
}

function send_contact_form() {
	httpRequester.open("POST", "../send_contact_form.php", true);
	httpRequester.onreadystatechange = process_send_form;
	httpRequester.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	param = 'naam=' + encodeURIComponent(document.getElementById('naam').value);
	param += '&mail=' + encodeURIComponent(document.getElementById('mail').value);
	param += '&vraag=' + encodeURIComponent(document.getElementById('vraag').value);
	param += '&type=hotel';
//	alert(param);
	httpRequester.send(param);	
}