var editable=false;

if (document.body.innerHTML.indexOf('Log out of'+' your PBwiki')!=-1)
editable=true

var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var buildList="";
var tempmonth=monthlow;
var tempyear=yearlow;
var ytext = tempyear + "";
if (tempyear<10) ytext="0" + tempyear;

document.write('<h1>' + heading + '</h1><div id="listing" style="float:left"></div><center><a href="javascript:Previous()">Previous Month</a> / <a href="javascript:Next()">Next Month</a><br><iframe src="Calendar' + months[tempmonth-1] + ytext + '?raw=bare" scrolling=no style="border:0px; width:300px; height:240px" id="calendarframe" name="calendarframe"  scrolling="no" frameborder="0"></iframe></center>');

while (tempyear<yearhigh || (tempyear==yearhigh && tempmonth<=monthhigh)) {
var yeartext = tempyear + "";
if (tempyear<10) yeartext="0" + tempyear;
if (tempyear==yearlow && tempmonth==monthlow)
     buildList=buildList+ '<h3>20' + yeartext + '</h3>';
buildList=buildList + ' <a href="Calendar' + months[tempmonth-1] + yeartext + '?raw=bare" target="calendarframe">' + months[tempmonth-1] + '</a>';
if (editable)
buildList=buildList + ' <a href="Calendar' + months[tempmonth-1] + yeartext + '?edit=1" target="_blank"><small>(Edit)</small></a><br>';
else
buildList=buildList + "<br>";

   tempmonth+=1;
   if (tempmonth==13) {
     tempmonth=1;
     tempyear+=1;
     buildList=buildList+ '<h3>20' + yeartext + '</h3>';
     }
}

document.getElementById("listing").innerHTML = buildList;


function Previous() {
if (yearnum>yearlow || (yearnum==yearlow && monthnum>monthlow)) {
  monthnum = monthnum-1;
  if (monthnum==0) {
      monthnum=12;
      yearnum=yearnum-1;
     }
  GoMonth();
  }
}

function Next() {
if (yearnum<yearhigh || (yearnum==yearhigh && monthnum<monthhigh)) {
  monthnum= monthnum+1;
  if (monthnum==13) {
      monthnum=1;
      yearnum=yearnum+1;
     }
  GoMonth();
  }
}

function GoMonth() {
var tempyear=yearnum + "";
if (yearnum<10) tempyear="0" + yearnum
var goto = "Calendar" + months[monthnum-1] + tempyear + "?raw=bare"
document.getElementById("calendarframe").src = goto;

}

if (bgcolor!="")
document.getElementById("displaycontent").style.background=bgcolor
