month = new Date().getMonth() + 1;
year = new Date().getFullYear();
day = new Date().getDate();

function calendar() {
	if (window.XMLHttpRequest) {
		xmlhttp2 = new XMLHttpRequest();
  	} else {
  		xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp2.onreadystatechange=function() {
  		if (xmlhttp2.readyState == 4 && xmlhttp2.status == 200) {
			document.getElementById("calendar").innerHTML = xmlhttp2.responseText;
    		}
  	}
	xmlhttp2.open("GET","calendar/calendar.php?month=" + month + "&year=" + year + "&day=" + day, true);
	xmlhttp2.send();
}

function nextMonth() {
	
	if (month == 12) {
		month = 1;
		year++;
	} else {	
		month++;
	}
	calendar();
}

function previousMonth() {
	if (year >= 2010) {	
		if (month == 1) {
			month = 12;
			year--;
		} else {	
			month--;
		}
		calendar();
	}
}

function today() {
	month = new Date().getMonth() + 1;
	year = new Date().getFullYear();
	day = new Date().getDate();
	calendar();
}

