var reqDisasterCaused = null;

function sendRequestDisasterCaused(url, params, HttpMethod) {
  if (!HttpMethod) {
    HttpMethod = "GET";
  }
  reqDisasterCaused = initXMLHTTPRequest();
  if (reqDisasterCaused) {
    // this is to ensure that no caching is taking place
    url = url + "&seed=" + (new Date()).getTime();

    reqDisasterCaused.onreadystatechange = onReadyStateDisasterCaused;
    reqDisasterCaused.open(HttpMethod, url, true);
    reqDisasterCaused.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    reqDisasterCaused.send(params);
  }
}

function onReadyStateDisasterCaused() {
  var ready = reqDisasterCaused.readyState;
  var data = null;
  if (ready == READY_STATE_COMPLETE) {
    data = reqDisasterCaused.responseText;
    var xmlDoc = reqDisasterCaused.responseXML.documentElement;
    isEmpty = fillSelect(data, xmlDoc);

    var xSel = xmlDoc.getElementsByTagName('selectElement')[0];
    var destination = xSel.childNodes[3].firstChild.nodeValue;
    if (destination == 'forEdit') {
      // populate ff_dis_year with a corresponding value
      updateDisasterYear(); 
    }

    if (isEmpty) {
      document.getElementById("displayResultDisasterNumberValue").style.display = "none";
      //document.getElementById("displayResultDisasterYear").style.display = "none";
      document.getElementById("displayResultDisasterNumberEmpty").style.display = "";
    }
    else {		
      document.getElementById("displayResultDisasterNumberValue").style.display = "";
      //document.getElementById("displayResultDisasterYear").style.display = "";
      document.getElementById("displayResultDisasterNumberEmpty").style.display = "none";
    }
  }
}

