CalendarValues = new Array(0);

function CalendarDateColp(oName, pName)
{
   t = new Array(0);
   var Offset = oName.length + 6;
   try
   {
      t['Y'] = pName.substring(Offset + 0,  Offset + 4);
      t['M'] = pName.substring(Offset + 5,  Offset + 7);
      t['D'] = pName.substring(Offset + 8,  Offset + 10);
      if (pName.substring(Offset + 11, Offset + 15)=='WEEK')
         t['W'] = true;
      else
         t['W'] = false;
      if (t['Y'].match(/^ *$/))
         return false;
      if (t['M'].match(/^ *$/))
         return false;
      if (t['D'].match(/^ *$/))
         return false;
      return t;
   }
   catch(e)
   {
      alert(e);
      return false;
   }
}

function CalendarElementClick(Calendar, Sender)
{
   var d = CalendarDateColp(Calendar, Sender.id);
   if (!d)
      return false;
   if (d['W'])
      s = 'week';
   else
      s = 'day';
   CalendarValues[Calendar] = new Array(d, s);
}

function CalendarChangeMonth(Calendar, Style, Day, Month, Year, Direction)
{
   Month = Math.abs(Month);
   if (Direction==-1)
   {
      if (Month==1)
      {
         Month = 12;
         Year--;
      }
      else
         Month--;
   }
   else
   if (Direction==1)
   {
      if (Month==12)
      {
         Month = 1;
         Year++;
      }
      else
         Month++;
   }
   else
      Style = 'month';
   if (Month < 10)
      Month = '0' + Month;
   dt = new Array(0);
   dt['Y'] = Year;
   dt['M'] = Month;
   dt['D'] = Day;
   CalendarValues[Calendar] = Array(dt, Style);
}