function reservate(day,mon,year) {
	var elm = AJS.$('date');
	if (elm){
		elm.value = day+'.'+mon+'.'+year;
	}
}

function notice (flag,day,mon,year) {
	if (flag == 'past') {
		return;
	}
	if (notices) {
		alert(notices[flag])
	}
}

var ajaxActive = false

function getCalendar(month,year,factor) {
	if (ajaxActive) {
		return;
	}
	ajaxActive = true;
	if(month==null){
		month = new Date().getMonth()+1;	
	}
	if(year==null){
		year = new Date().getFullYear();	
	}
	if (month == 12 && factor == 1) {
		month = 1;
		year = year+1 ;
	}
	else if(month == 1 && factor == -1) {
		month = 12;
		year = year -1;
	}
	else if(factor!=null){
		month = month + (factor);
	}
	var d = AJS.getRequest("/calendar.php?year="+year+'&month='+month)
	d.addCallback(function(res_txt, req) { 
		var elm = AJS.$('calendar_content')
		if (elm) {
			elm.innerHTML = res_txt;
			ajaxActive = false;
		}
	})
	d.addErrback(function(res_txt, req) { alert("Error encountered.") });
	d.sendReq();
}
