var monthsEN = new Array("", "January", "February", "March", "April", "May", "June",
 "July", "August", "September", "October", "November", "December");

function calNav(mdelta)
{
  var xmlHttp;
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) {
  // Internet Explorer
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      try {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function() {
    if(xmlHttp.readyState==4) {
      document.getElementById('CalendarDiv').innerHTML = xmlHttp.responseText;
    }
  }
  
  var newyear = parseInt(document.getElementById("year").value);
  var newmonth = parseInt(document.getElementById("month").value);
  var cID = document.getElementById("calID").value;
  
  if (mdelta == 0) {
    var date = new Date();
    newmonth = date.getMonth() +1;
    var yy = date.getYear();
    newyear = (yy < 1000) ? yy + 1900 : yy;
  }
  else {
    newmonth += mdelta;
    if (newmonth == 0) {
      newyear = newyear -1;
      newmonth = 12;
    }
    if (newmonth == 13) {
     newyear = newyear+1;
     newmonth = 1;
    }
  }
  
  document.getElementById('MonthTitle').innerHTML =  monthsEN[newmonth] + " " + newyear.toString();
  document.getElementById('month').value = newmonth;
  document.getElementById('year').value = newyear;

  var innerURL = "inc_gcdisplay.php?y=" + newyear + "&m=" + newmonth + "&calID=" + cID;
  
  xmlHttp.open("GET", innerURL ,true);
  xmlHttp.send(null);
  }
