var curM;var curY;function getDaysInMonth(m,y) {	// months start from 0	switch (m) {		case 0:		case 2:		case 4:		case 6:		case 7:		case 9:		case 11: return 31;		case 3:		case 5:		case 8:		case 10: return 30;		case 1: { if (y%4==0) return 29; return 28; }	}}var eevents = "";var httpRequest;function processRequest(m,y) {  if (httpRequest.readyState == 4)  {    if(httpRequest.status == 200)    {      eevents = httpRequest.responseText;    }    else    {      eevents = "";    }    evs = eevents.split("#%%%#");    	curM = m;	curY = y;	firstday = new Date();	firstday.setMonth(m);	firstday.setFullYear(y);	firstday.setDate(1);	d = firstday.getDay();	if (d==0) d=7;	for (i=1;i<=42;i++) {    document.getElementById("d"+i).innerHTML = "";    document.getElementById("d"+i).className = "";  }	for (i=d;i<getDaysInMonth(m,y)+d;i++) {		document.getElementById("d"+i).innerHTML = i-d+1;		reg = /#%%#/g;		document.getElementById("d"+i).title = evs[i-d+1]?evs[i-d+1].replace(reg,"\n"):"";		if (evs[i-d+1]) document.getElementById("d"+i).className = "activeEvent";		else document.getElementById("d"+i).className = "no";		document.getElementById("d"+i).onclick = function() { dayClicked(this.innerHTML,m,y); return false; }		document.getElementById("d"+i).onmouseover = function() { showInfo(this.title); }		document.getElementById("d"+i).onmouseout = function() { showInfo(-1); }	}	document.getElementById("curM").innerHTML = m+1;	document.getElementById("curY").innerHTML = y;      }}function fillCalendar(m,y) {  document.getElementById("calInfo").innerHTML = "";  if (window.ActiveXObject)  {    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");  }  else  {    httpRequest = new XMLHttpRequest();  }  url = "/kalendar-akci/?display=ajax&y="+y+"&m="+(m+1);  httpRequest.open("GET", url, true);  httpRequest.onreadystatechange = function () { processRequest(m,y); } ;  httpRequest.send(null);}function showInfo(i) {  reg = /\n/g;  if (i==-1)    document.getElementById("calInfo").innerHTML = "";  else if (i)	 document.getElementById("calInfo").innerHTML = i.replace(reg,"<br />");}function initCalendar() {	now = new Date();	fillCalendar(now.getMonth(),now.getFullYear());	document.getElementById("curM").onclick = function() { monthClicked(this); return false; }	document.getElementById("curY").onclick = function() { yearClicked(this); return false; }}function dayClicked(d,m,y) {  if (m || m==0) m = "-"+(m+1);  else m = "";	window.location.href = "/kalendar-akci/?"+"eventDay="+y+m+(d?"-"+d:"");}function monthClicked(e) {  dayClicked(0,curM,curY);}function yearClicked(e) {  dayClicked(0,0,curY);}function moveCalendar(dir) {	curM = curM+dir;	if (curM<0) { curM=11; --curY; }	if (curM>11) { curM=0; ++curY; }	fillCalendar(curM,curY);	return false;}window.onload = initCalendar;