var ajax4ReQ = getXmlHttpRequestObject();
var ajax2ReQ = getXmlHttpRequestObject();
function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
    	return new XMLHttpRequest();
    } else if(window.ActiveXObject) {
    	return new ActiveXObject("Microsoft.XMLHTTP");
    } 
}
function get_listings(page) {
	if (ajax4ReQ.readyState == 4 || ajax4ReQ.readyState == 0) {
		day = new Date();http://motor.kenkai.co.uk/kc-hire-java.js
		id = day.getTime();
		ajax4ReQ.open("GET", 'kContent/plugins/buy-sell.php?kContent_section=ajax4&location='+document.getElementById("listing_location").value+'&berths='+document.getElementById("listing_berths").value+'&rate='+document.getElementById("listing_rate").value+'&page='+page+'&time='+id, true);
		ajax4ReQ.onreadystatechange = got_listings; 
		ajax4ReQ.send(null);
	}			
}

function got_listings() {
	if (ajax4ReQ.readyState == 4) {
		if (ajax4ReQ.responseText) {
			window.scroll(0,0);
			the_sections = ajax4ReQ.responseText.split("|*|");
			document.getElementById("pages_1").innerHTML = the_sections[0];
			document.getElementById("listings_1").innerHTML = the_sections[1];
			document.getElementById("pages_2").innerHTML = the_sections[0];
		}
	}
}
function get_month(direction) {
	if (ajax2ReQ.readyState == 4 || ajax2ReQ.readyState == 0) {
		day = new Date();
		id = day.getTime();
		ajax2ReQ.open("GET", 'kContent/plugins/buy-sell.php?kContent_section=ajax2&avail_id='+document.getElementById("avail_id").value+'&curmonth='+document.getElementById("curmonth").value+'&curyear='+document.getElementById("curyear").value+'&direction='+direction+'&time='+id, true);
		ajax2ReQ.onreadystatechange = got_month; 
		ajax2ReQ.send(null);
	}			
}

function got_month() {
	if (ajax2ReQ.readyState == 4) {
		if (ajax2ReQ.responseText) {	
			var bits = ajax2ReQ.responseText.split("|*|");
			document.getElementById("avail_cal").innerHTML =bits[0];
			document.getElementById("curmonth").value = bits[1];
			document.getElementById("curyear").value = bits[2];
		}
	}
}


