var livecal_dir = '/wp-content/plugins/livecalendar/'
var week_begins = 1;
var thismonth = 02;
var thisyear = 2012;
var min_month = 1;
var min_year = 2008;
var has_fp = false;
var siteurl = 'http://www.tue-blog.de';
var firstpost = '';
var permastruct = '/%year%/%monthnum%/%day%';
var m_permastruct= '/%year%/%monthnum%/';
var spinner_img = '/wp-content/plugins/livecalendar/wait1.gif';
var dateDayDisp = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S');
var dateMon = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var dateMonShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var archives = 'Archives:';
var viewpostsfor_= 'View posts for %1$s %2$s';
// extra fiddly bits of needed code before getting to the meat
function viewpostsfor(year,month) {
return viewpostsfor_.replace("%1\$s",dateMon[month]).replace("%2\$s",year);
}
var unixmonth = new Date(thisyear,thismonth-1,1);
unixmonth.setYear(thisyear); // to be sure it's a 4 digit value.
var entries_cache=new Array();
var tocall;
function addEvent(el,ev,fn) {
if (el.attachEvent)el.attachEvent('on'+ev,fn);
else if (el.addEventListener)el.addEventListener(ev,fn,false);
}
if (typeof window.XMLHttpRequest!="undefined") {
if (navigator.userAgent.indexOf('KHTML')>0) {
setTimeout('kcalendar_refresh()',2000);
}
else {
addEvent(window,'load',kcalendar_refresh);
}
}
// let's create the calendar table array
function kcalendar_build(year,month,day) {
var today=new Date;
shownDate=new Date(year,month,day);
cal=document.createElement('table');
cal.id="wp-calendar";
// draw month name
caption=document.createElement('caption');
caption.appendChild(document.createTextNode(dateMon[shownDate.getMonth()]+' '+shownDate.getFullYear()));
cal.appendChild(caption);
caption.id="wp-calendar_caption";
// draw day headers
cal_head = document.createElement('THEAD');
cal.appendChild(cal_head);
cal_row=cal_head.insertRow(0);
cal_row.id="calendar_daysRow";
for (i=0;i<7;i++) {
cal_cell = document.createElement('TH');
cal_row.appendChild(cal_cell);
var wd = dateDayDisp[(i+week_begins)%7];
cal_cell.appendChild(document.createTextNode(wd));
cal_cell.abbr =wd;
cal_cell.title=wd;
cal_cell.scope="col";
}
// draw navigation row month
cal_foot = document.createElement('TFOOT');
cal.appendChild(cal_foot);
cal_row=cal_foot.insertRow(0);
// create previous month nav if we have a post from then
cal_cell=cal_row.insertCell(0);
cal_cell.colSpan=3;
cal_cell.id = 'prev';
cal_cell.className = 'pad';
// create spinner element
cal_cell=cal_row.insertCell(1);
cal_cell.className = 'pad';
spinner = document.createElement("IMG");
spinner.id="calendar_spin";
spinner.src = siteurl + spinner_img;
cal_cell.appendChild(spinner);
// create next month nav if we have a post from then
cal_cell=cal_row.insertCell(2);
cal_cell.colSpan=3;
cal_cell.id="next";
cal_cell.className='pad';
// draw navigation row year
cal_row=cal_foot.insertRow(1);
// create previous year nav if we have a post from then
cal_cell=cal_row.insertCell(0);
cal_cell.colSpan=3;
cal_cell.id='prev_year';
cal_cell.className='pad';
// create filler space
cal_cell=cal_row.insertCell(1);
cal_cell.className='pad';
// create next year nav if we have a post from then
cal_cell=cal_row.insertCell(2);
cal_cell.colSpan=3;
cal_cell.id='next_year';
cal_cell.className = 'pad';
// create calendar body
cal_body = document.createElement('TBODY');
cal.appendChild(cal_body);
// get date of first cell
firstcelldate=new Date(shownDate.getFullYear(),shownDate.getMonth(),1);
cellDate=1-firstcelldate.getDay()+week_begins;
if (cellDate>1)cellDate-=7;
// draw rest of month
days_in_last_month=kcalendar_daysInMonth(shownDate.getFullYear(),shownDate.getMonth()-1);
for (i=0;i<6;i++) {
cal_row=cal_body.insertRow(i);
for(j=0;j<7;j++) {
cal_cell=cal_row.insertCell(j);
class_to_show='';
if (cellDate<1) {
class_to_show='pad';
num_to_show='';//days_in_last_month+cellDate
}
else if (cellDate>kcalendar_daysInMonth(shownDate.getFullYear(),shownDate.getMonth())) {
class_to_show='pad';
num_to_show='';//cellDate-kcalendar_daysInMonth(shownDate.getFullYear(),shownDate.getMonth());
}
else {
num_to_show=cellDate;
class_to_show='';
if (shownDate.getFullYear()==today.getFullYear() && shownDate.getMonth()==today.getMonth() && cellDate==today.getDate()) {
cal_cell.id='today';
class_to_show+=" today"
}
}
cal_cell.appendChild(document.createTextNode(num_to_show));
cal_cell.className=class_to_show;
if( cal_cell.id != 'today' )
cal_cell.id="kcalendar_"+shownDate.getFullYear()+"_"+(shownDate.getMonth()+1)+"_"+cellDate;
cellDate++;
}
}
tocall='kcalendar_'+(shownDate.getFullYear())+"_"+(shownDate.getMonth());
return cal;
}
// identify posts for dates listed
function kcalendar_create_links(arr, shown_year,shown_month) {
// add prev month/year links if necessary
split = arr[0].split(/: /);
if (split[1] != 'none') {
prev_date = split[1].split(/,/);
cell = document.getElementById('prev');
// kill the kid.
if (cell.childNodes.length>0)
cell.removeChild(cell.childNodes[0]);
// create a new one.
link = document.createElement('a');
link.appendChild(
document.createTextNode(String.fromCharCode(171)+" " +
dateMonShort[prev_date[1]-1])
);
link.href="javascript:kcalendar_refresh("+prev_date[0]+","+prev_date[1]+");";
link.title = viewpostsfor(prev_date[0],prev_date[1]-1)
cell.appendChild(link);
cell.abbr=dateMonShort[prev_date[1]-1];
cell.className = '';
if ((prev_date[0] == shown_year && min_year < shown_year) || prev_date[0] < shown_year ) {
cell = document.getElementById('prev_year');
// speed em up to 88 mph
year = (prev_date[0] < shown_year-1) ? prev_date[0] : shown_year-1;
// but block the flux capacitor
month = (year == min_year && shown_month < min_month) ? min_month : shown_month+1;
// kill the kid.
if (cell.childNodes.length>0)
cell.removeChild(cell.childNodes[0]);
// create a new one.
link = document.createElement('a');
link.appendChild(
document.createTextNode(String.fromCharCode(171)+" " + year)
);
link.href="javascript:kcalendar_refresh("+year+","+month+");";
link.title = viewpostsfor(year,month-1)
cell.appendChild(link);
cell.className = '';
}
}
// add next month/year links if necessary
split = arr[1].split(/: /);
if (split[1] != 'none') {
cell = document.getElementById('next');
next_date = split[1].split(/,/);
// kill the kid.
if (cell.childNodes.length>0)
cell.removeChild(cell.childNodes[0]);
// create a new one.
link = document.createElement('a');
link.appendChild(
document.createTextNode(dateMonShort[next_date[1]-1]+ " " +
String.fromCharCode(187))
);
link.href="javascript:kcalendar_refresh("+next_date[0]+","+next_date[1]+");";
link.title = viewpostsfor(next_date[0],next_date[1]-1)
cell.appendChild(link);
cell.abbr=dateMonShort[next_date[1]-1];
cell.className = '';
if ( (next_date[0] == shown_year && thisyear > shown_year) || next_date[0] > shown_year) {
cell = document.getElementById('next_year');
// speed em up to 88 mph
year = (next_date[0] > shown_year+1) ? next_date[0] : shown_year+1;
// but block the flux capacitor
month = (year == thisyear && shown_month > thismonth) ? thismonth : shown_month+1;
// kill the kid.
if (cell.childNodes.length>0)
cell.removeChild(cell.childNodes[0]);
// create a new one.
link = document.createElement('a');
link.appendChild(
document.createTextNode(year + " " + String.fromCharCode(187))
);
link.href="javascript:kcalendar_refresh("+year+","+month+");";
link.title = viewpostsfor(year,month-1)
cell.appendChild(link);
cell.className = '';
}
}
// don't do anything if we don't have any links
// this should only happen when someone jumps years
if (arr[2] == '') return;
// now create links for each post
for (i=2;i