function createRequestObject() {
    var ro;
  
	try {
		ro = new XMLHttpRequest();
	} catch (e) {
		try {
			ro = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
			try {
				ro = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e) {
				document.write('XMLHttpRequest not supported'); 
			}
		}
	}

    return ro;
}

function getAvailability(listingID,date,accountCode){

	url = '/booking/getAvailability.php?p[accountCode]='+accountCode+'&p[listingID]='+listingID+'&p[startDate]='+date;

	http.open('GET',url);
    http.onreadystatechange = displayAvail();
    http.send(null);
}

function displayAvail(){

	return function(){
		if(http.readyState == 4 || http.readyState == "complete"){
			var control = document.getElementById('avail');
			control.innerHTML = http.responseText;
		}
	}
}

var http = createRequestObject();
