

function getXMLHTTPRequest() {
	try {
		req = new XMLHttpRequest();
	} catch(err1) {
  		try {
  			req = new ActiveXObject("Msxml2.XMLHTTP");
  		} catch (err2) {
    		try {
    			req = new ActiveXObject("Microsoft.XMLHTTP");
    		} catch (err3) {
      			req = false;
    		} 
  		} 
	}
	return req;
}
var http = getXMLHTTPRequest();
var http2 = getXMLHTTPRequest();

function additem(elementname,elementnum,sec)
{
		theurl = "Zincludes/Hotel_ajax-addfields.php";
		theurl2 = "Zincludes/Hotel_ajax-addfields2.php";
		myRand = parseInt(Math.random()*999999999999999); 
	if ((elementname)=='children') {
		if (sec=="b") {
		var modurl1 = theurl+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=2&name="+elementname;
		http.open("GET", modurl1, true);
		http.onreadystatechange = function() { useHttpResponse(elementname+elementnum+"b") }
		http.send(null);	
		} else {
		var modurl1 = theurl+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=1&name="+elementname;
		http.open("GET", modurl1, true);
		http.onreadystatechange = function() { useHttpResponse(elementname+elementnum+"a") }
		http.send(null);
		var modurl2 = theurl2+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=2&name="+elementname;
		http2.open("GET", modurl2, true);
		http2.onreadystatechange = function() { useHttpResponse2(elementname+elementnum+"b") }
		http2.send(null);
		}
	} else if ((elementname)=='infants') {
		var modurl1 = theurl+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=1&name="+elementname;
		http.open("GET", modurl1, true);
		http.onreadystatechange = function() { useHttpResponse(elementname+elementnum) }
		http.send(null);
	}
	
}

function additem2(elementname,elementnum,sec)
{
		theurl = "Zincludes/Hotel_ajax-addfieldsSel.php";
		theurl2 = "Zincludes/Hotel_ajax-addfields2Sel.php";
		myRand = parseInt(Math.random()*999999999999999); 
	if ((elementname)=='children') {
		if (sec=="b") {
		var modurl1 = theurl+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=2&name="+elementname;
		http.open("GET", modurl1, true);
		http.onreadystatechange = function() { useHttpResponse(elementname+elementnum+"b") }
		http.send(null);	
		} else {
		var modurl1 = theurl+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=1&name="+elementname;
		http.open("GET", modurl1, true);
		http.onreadystatechange = function() { useHttpResponse(elementname+elementnum+"a") }
		http.send(null);
		var modurl2 = theurl2+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=2&name="+elementname;
		http2.open("GET", modurl2, true);
		http2.onreadystatechange = function() { useHttpResponse2(elementname+elementnum+"b") }
		http2.send(null);
		}
	} else if ((elementname)=='infants') {
		var modurl1 = theurl+"?rand="+myRand+"&iXMLRoom="+elementnum+"&x=1&name="+elementname;
		http.open("GET", modurl1, true);
		http.onreadystatechange = function() { useHttpResponse(elementname+elementnum) }
		http.send(null);
	}
	
}

function useHttpResponse(z) {
	//alert(z);
	if (http.readyState == 4) {
	//alert(http.status);
		if (http.status == 200) { 
			var mytext1a = http.responseText;
			//alert(mytext1a);
			document.getElementById(z).innerHTML = mytext1a;
		}
	} else {
	//document.getElementById(z).innerHTML = "wait...";
	}
}
function useHttpResponse2(z) {
	if (http2.readyState == 4) {
		if (http2.status == 200) { 
			var mytext2 = http2.responseText;
			document.getElementById(z).innerHTML = mytext2;
		}
	} else {
	//document.getElementById(z).innerHTML = "wait...";
	}
}
