// Location of the calendar script file from the root
ajaxPath = '/qcalendar/ajax_qcalendar.php';
//

function createQCObject() {
   var req;
   if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      alert('Problem creating the XMLHttpRequest object');
   }
   return req;
}

// Make the XMLHttpRequest object
var http = createQCObject();

function refresh() {
	if(http.readyState == 4 && http.status == 200) {
  		var response = http.responseText;
  		if(response) {
			document.getElementById("qcalendar").innerHTML = http.responseText;
  		}
   	}
}

function displayQCalendar(lang,home,m,y) {
	var ran_no=(Math.round((Math.random()*9999)));
	http.open('get', ajaxPath + '?home='+home+'&m='+m+'&y='+y+'&lang='+lang+'&ran='+ran_no);
   	http.onreadystatechange = refresh;
   	http.setRequestHeader("Accept-Language","en,ru,it,es,de,fr,ru-ru,pl;q=0.5,*;q=0.4");
   	http.setRequestHeader("Accept-Charset","ISO-8859-1,utf-8,windows-1251;q=0.7,*;q=0.7");
   	http.send(null);
}
function setAvail (lang,tf,home,d,m,y) {
	var http = createQCObject();
	var ran_no=(Math.round((Math.random()*9999)));
	var aurl = ajaxPath + '?avail='+tf+'&home='+home+'&d='+d+'&m='+m+'&y='+y+'&lang='+lang+'&ran='+ran_no;
	http.open('get', aurl,true);
   	http.onreadystatechange = function() { if(http.readyState == 4 && http.status == 200) displayQCalendar(home,m,y)};
   	http.send(null);
}