//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //Not IE 6
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE 6
	}
}

var receiveReq = getXmlHttpRequestObject();

function openCalendar (DestinationID, CurrentDate, FirstDate, e) {
	var obj = document.getElementById('bookCalendar');

	if (e) {
		obj.style.top = e.pageY + 5 + 'px';
		obj.style.left = e.pageX + 5 + 'px';
	}


	//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		// Setup the connection as a GET call to testcal.php
		// True explicity sets the request to asyncronous (default).
		receiveReq.open("POST", 'bookingcalendar.ajax.php', true);
		// Set the function that will be called when the XmlHttpRequest objects state changes.
		receiveReq.onreadystatechange = dispCalendar; 
		// Make the actual request.
		receiveReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		receiveReq.send('DestinationID='+DestinationID+'&CurrentDate='+CurrentDate+'&FirstDate='+FirstDate);
	}
}

function closeCalendar () {
	var obj = document.getElementById('bookCalendar')
//	obj.style.visibility = 'hidden';
	obj.style.display = 'none';
//	obj.innerHTML = '';
}

function dispCalendar() {
	var obj = document.getElementById('bookCalendar');

	//Check to see if the XmlHttpRequests state is finished.
	if (receiveReq.readyState == 4) {
//		obj.style.visiblity = 'visible';
		obj.style.display = 'block';

		//Set the contents of our element to the result of the asyncronous call.
		document.getElementById('bookCalendar').innerHTML = receiveReq.responseText;
	}
}

window.onload = function() {
	settings = {
		tl: { radius: 20 },
		tr: { radius: 20 },
		bl: { radius: 20 },
		br: { radius: 20 },
		antiAlias: true,autoPad: true
	}
}
