function getCalendarByDate(year,month){$("cal_table").setAttribute("getYear",year);$("cal_table").setAttribute("getMonth",month);getCalendar($("cal_table"));}
function getCalendar(sender){var now=new Date();var month=parseInt(now.getMonth())+1;var year=parseInt(now.getFullYear());if(sender!=null&&sender.getAttribute("getYear")!=null&&sender.getAttribute("getMonth")!=null)
{year=parseInt(sender.getAttribute("getYear"));month=parseInt(sender.getAttribute("getMonth"));}
var xhr=createXMLHttpRequest();xhr.open("GET","/index.pl?service=getarchive&action=getCalendar&year="+
year+"&month="+month);function onCalendarResponse(){if(xhr.readyState!=4){return;}
var response=JSON.parse(xhr.responseText);if(response!=null&&response.calendar!=null){var calObj=response.calendar;removeAllChildNodes($("cal_table"));removeAllChildNodes($("cal_monthname"));$("cal_monthname").appendChild(document.createTextNode(response.monthName+" "+response.curYear));var tbody=document.createElement("tbody")
var dayNames=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];var topRow=document.createElement("tr");for(var i=0;i<7;i++)
{var dayName=document.createElement("td");dayName.appendChild(document.createTextNode(dayNames[i]));topRow.appendChild(dayName);}
tbody.appendChild(topRow);for(var rownum=0;rownum<6;rownum++)
{var curRow=document.createElement("tr");for(var colnum=0;colnum<7;colnum++)
{var curCol=document.createElement("td");var thisday=calObj[rownum][colnum];if(thisday.hasentries==1){var a=document.createElement("a");a.href=thisday.href;a.appendChild(document.createTextNode(thisday.text));curCol.appendChild(a);}
else{curCol.appendChild(document.createTextNode(thisday.text));}
if(thisday.istoday&&thisday.istoday==1){curCol.className="cal-today";}
curRow.appendChild(curCol);}
tbody.appendChild(curRow);}
$("cal_table").appendChild(tbody);$("calPrevButton").setAttribute("getYear",response.prevYear);$("calPrevButton").setAttribute("getMonth",response.prevMonth);$("calNextButton").setAttribute("getYear",response.nextYear);$("calNextButton").setAttribute("getMonth",response.nextMonth);}}
xhr.onreadystatechange=onCalendarResponse;xhr.send(null);}
