var url = "internal_request_city_info.php?country="; // The server-side script
var url1 = "internal_request_hotel_info.php?city="; // The server-side script
function handleHttpResponse() {	
  if (http.readyState == 4) {  	
    if (http.responseText.indexOf('invalid') == -1) {    	
      // Use the XML DOM to unpack the city and state data 
      var xmlDocument = http.responseXML;       
    
      x = document.getElementById('city');
      
      for(i=0; i<x.length;)
      {
      	x.remove(i);
      }
      
      var count = xmlDocument.getElementsByTagName('city_id').length;      
      var city_id;
      var city_name;      
      
      for( i=0; i<count; i++ ) 
      {
      	city_id = xmlDocument.getElementsByTagName('city_id').item(i).firstChild.data;      
     	city_name = xmlDocument.getElementsByTagName('city_name').item(i).firstChild.data;      
	    x[i]=new Option(city_name,city_id);
      }
      
      isWorking = false;
    }
  }
}

function handleHttpResponse1() {	
  if (http.readyState == 4) {  	
    if (http.responseText.indexOf('invalid') == -1) {    	
      // Use the XML DOM to unpack the city and state data 
      var xmlDocument = http.responseXML;       
    
      x = document.getElementById('hotel');
      
      for(i=0; i<x.length;)
      {
      	x.remove(i);
      }
      
      var count = xmlDocument.getElementsByTagName('hotel_id').length;      
      var hotel_id;
      var hotel_name;      
      
      for( i=0; i<count; i++ ) 
      {
      	hotel_id = xmlDocument.getElementsByTagName('hotel_id').item(i).firstChild.data;      
     	hotel_name = xmlDocument.getElementsByTagName('hotel_name').item(i).firstChild.data;    
		hotel_name = unescape(hotel_name .replace(/\+/g,  " "));
  
	    x[i]=new Option(hotel_name,hotel_id);
      }
      
      isWorking = false;
    }
  }
}

function handleHttpResponse2() {	

  if (http.readyState == 4) {  	
    if (http.responseText.indexOf('invalid') == -1) {    	
      // Use the XML DOM to unpack the city and state data 
      var xmlDocument = http.responseXML;       

      x = document.getElementById('divCheckBokHolderList');

      x.innerText = "";

      /*
      for(i=0; i<x.length;)
      {
      	x.remove(i);
      }
      */
      
      var txt = "";
      
      var count = xmlDocument.getElementsByTagName('hotel_id').length;      
      var hotel_id;
      var hotel_name;      

      if(i > 0)
      for( i=1; i<count; i++ ) 
      {
      	hotel_id = xmlDocument.getElementsByTagName('hotel_id').item(i).firstChild.data;      
     	hotel_name = xmlDocument.getElementsByTagName('hotel_name').item(i).firstChild.data;      
     	hotel_name = unescape(hotel_name .replace(/\+/g,  " "));
     	txt += "<input type='checkbox' id='h" + i + "' name='h" + i + "' value='"+ hotel_id +"' />&nbsp;" + hotel_name + "<br />"    	
      }
      
      x.innerHTML = txt;
      
      isWorking = false;
    }
  }
}

var isWorking = false;
function setNodeInfo() {
	  
  if (!isWorking && http) {
    var node_slno_update = document.getElementById("country").value;    
    http.open("GET", url + escape(node_slno_update), true);
    http.onreadystatechange = handleHttpResponse;
    isWorking = true;
    http.send(null);
  }  
}

function setNodeInfo1() {
	  
  if (!isWorking && http) {
	  
    var node_slno_update = document.getElementById("city").value;    
    http.open("GET", url1 + escape(node_slno_update), true);
    http.onreadystatechange = handleHttpResponse1;
    isWorking = true;
    http.send(null);
  }  
}

function setNodeInfoHotelsWithCheckBoxes() {	  
  if (!isWorking && http) {
	  
    var node_slno_update = document.getElementById("city").value;    
    http.open("GET", url1 + escape(node_slno_update), true);
    http.onreadystatechange = handleHttpResponse2;
    isWorking = true;
    http.send(null);
  }  
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml"); 
    } catch (e) {
      xmlhttp = false;
    }
  }  
  return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Objecta
