/* Modifications */
/* 09/23/09 New JavaScript to calculate next meeting date (LK) */

function calcdate(passedType)
{
  var nextdate = new Array(12);
  var nd = new Date();
  var currentYear = nd.getFullYear() + "";
  var currentMonth = (nd.getMonth()+1) + "";
  var currentDay = nd.getDate() + "";

  if (currentMonth.length == 1)
     {
       currentMonth = "0" + (nd.getMonth()+1)
     }
  if (currentDay.length == 1)
     {
       currentDay = "0" + nd.getDate()
     }
  var currdate = currentYear + currentMonth + currentDay;
  var x = nd.getMonth();

  switch(passedType)
  {
/* First Sunday dates for 2012 - Houston */
    case 'ph1':
      nextdate[0] = "20120108";
      nextdate[1] = "20120205";
      nextdate[2] = "20120304";
      nextdate[3] = "20120401";
      nextdate[4] = "20120506";
      nextdate[5] = "20120603";
      nextdate[6] = "20120701";
      nextdate[7] = "20120805";
      nextdate[8] = "20120909";
      nextdate[9] = "20121007";
      nextdate[10] = "20121104";
      nextdate[11] = "20121202";
      break;
/* Third Thursday dates for 2012 - Houston */
    case 'ph2':
      nextdate[0] = "20120119";
      nextdate[1] = "20120216";
      nextdate[2] = "20120315";
      nextdate[3] = "20120419";
      nextdate[4] = "20120517";
      nextdate[5] = "20120621";
      nextdate[6] = "20120719";
      nextdate[7] = "20120816";
      nextdate[8] = "20120920";
      nextdate[9] = "20121018";
      nextdate[10] = "20121115";
      nextdate[11] = "20121220";
      break;
/* Forth Sunday dates for 2012 - Clear Lake */
    case 'cl1':
      nextdate[0] = "20120122";
      nextdate[1] = "20120226";
      nextdate[2] = "20120325";
      nextdate[3] = "20120422";
      nextdate[4] = "20120527";
      nextdate[5] = "20120624";
      nextdate[6] = "20120722";
      nextdate[7] = "20120826";
      nextdate[8] = "20120923";
      nextdate[9] = "20121028";
      nextdate[10] = "20121125";
      nextdate[11] = "20121223";
      break;
    default:
      var meetingdate = "";
      return meetingdate;
  }
  if (currdate > nextdate[x].substring(0,8))
     {
       x++;
       if (x == 12)
          {
           x = 0;
          }
     }
  var meetingyear = nextdate[x].substring(0,4);
  var meetingmonth = nextdate[x].substring(4,6);
  if (nextdate[x].length > 8)
     {
       var meetingday = nextdate[x].substring(6,8);
       var msg = nextdate[x].substring(8);
       var meetingdate = meetingmonth + "/" + meetingday + "/" + meetingyear + " " + msg;
     }
  else
     {
       var meetingday = nextdate[x].substring(6);
       var meetingdate = meetingmonth + "/" + meetingday + "/" + meetingyear;
     }
  return meetingdate;
}  


