/***************************************/
/*  Util Script for Ajax functionalities
/***************************************/


    function ajaxUpdate() {
    	var dmy=document.getElementById("monthSearch").value;
	var th=document.getElementById("themeSearch").value;
	var de=document.getElementById("destinationSearch").value;
	strCriteriaOffresSelectionnees = "/ajaxResults/c.th="+th+"&c.de="+de+"&dmy="+dmy;
        ajaxCallRemotePage(strCriteriaOffresSelectionnees,dmy);
    }

  /*
  * Ajax call function to call remote page.
  * @param url url to call
  * @param formIdToPost form id to post with the call of the url
  * @param spanIdToModify span id to modify
  */
  function ajaxCallRemotePage(url,dmy) {
    var req = null;
    //Do the Ajax call
    if (window.XMLHttpRequest) { // Non-IE browsers
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.onreadystatechange = function() { processStateChange(req,dmy); };
    req.open("GET", url, true);req.send(null);
  }
function processStateChange(req,dmy) {
	if (req.readyState == 4) { // Complete
      	if (req.status == 200) { // OK response

      		var response = req.responseText;
			$("#searchEngineAjax").html(response);
//      		initDateDepartSearchEngine(dmy);
      	}
      	else {alert("Problem with server response:\n " + req.statusText);}
    }
}
