var right_now = new Date();
var xmlhttp = null;
var cal = "";

function PageStateChanged()
{
var z=1;
  try
  {
    switch(xmlhttp.readyState)
    {
/*
      case 0:
          cal.innerHTML = "Uninitialized!";
          break;
      case 1:
          cal.innerHTML = "Open";
          break;
      case 2:
          cal.innerHTML = "Sent";
          break;
      case 3:
          cal.innerHTML = "Receiving";
          break;
*/
      case 4:
        h = xmlhttp.responseText;
        cal.innerHTML = h;
        break;
    }
  }
  catch(er)
  {
    cal.innerHTML = "<h1 style='color:red'>Error: " + er.description + "</h1>";
  }
}


function OpenEditWindow()
{
  NewWin = window.open('', 'Event', 'width=500,height=300,scrollbars=yes,menubar=no,location=no,hotkeys=no,directories=no,resizable=no,toolbar=no');
  NewWin.focus();
}
function setnote(ec)
{
  var notice;
  if (ec<1)  notice = "No Events";
  if (ec==1) notice = "1 Event";
  if (ec>1)  notice = ec + " Events";
  self.status=notice;
}

function draw_calendar(dt)
{
  try
  {
    t = new Date();
    xmlhttp.open('GET', '/tools/calendar/display.asp?gid=' + gid + '&date=' + dt + '&t=' + t.valueOf(), true);
    xmlhttp.onreadystatechange=PageStateChanged;
    xmlhttp.send(null);
  }
  catch(er)
  {
    cal.innerHTML = "<h1 style='color:red'>Error: " + er.description + "</h1>";
  }
}

function cal_my()
{
  return('&month='+document.getElementById('cal_month').value+'&year='+document.getElementById('cal_year').value);
}

document.write("<div id='calendar'><h1>Initializing Calendar...</h1></div>");

try
{
  cal = document.getElementById('calendar');

  if (window.XMLHttpRequest)
  {
    // code for all new browsers
    xmlhttp=new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    // code for IE5 and IE6
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

  if (xmlhttp!=null)
  {
    setTimeout("draw_calendar(right_now.format('M/d/yyyy'))","500");
  }
  else
  {
    call.innerHTML = "<h1 style='color:red'>Your browser does not support the calendar.</h1>";
  }
}
catch(er)
{
  cal.innerHTML = "<h1 style='color:red'>Error: " + er.description + "</h1>";
}


  