<!--

function iCal (campo, anno, mese, selected) {

  var div = document.getElementById (campo + '_div');
  if (!div) return;

  if (anno == '') anno = null;
  if (mese == '') mese = null;
  if (selected == '') selected = null;

  if ((anno != null) && (mese == null)) {

    selected = anno;
    anno = null;

  }

  if ((selected != null) && (selected.length != 8)) selected = null;
  if ((selected != null) && (anno == null) && (mese == null)) {

    mese = selected.substr (4, 2);
    anno = selected.substr (0, 4);

  }

  var oggi = new Date ();
  var s_oggi = oggi.getFullYear () + (oggi.getMonth () < 9 ? '0' : '') + (oggi.getMonth () + 1) + (oggi.getDate () <= 9 ? '0' : '') + oggi.getDate ();

  mese = mese == null ? oggi.getMonth () + 1 : parseInt (mese, 10);
  anno = anno == null ? oggi.getFullYear () : parseInt (anno, 10);
  if (selected == null) selected = '';

  var mesi = 'Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre'.split ('|');
  var DT = new Date (anno, mese - 1, 1);

  var realMese = DT.getMonth () + 1;
  var realAnno = DT.getFullYear ();

  var firstWeekDay = DT.getDay ();
  if (!firstWeekDay) firstWeekDay = 7;

  var monthDays = new Date (anno, mese, 0).getDate ();

  var i, j, s = '';

  s += '<table style="border: 1px solid #C0C0C0;" width="100%" cellpadding="0" cellspacing="0">' + "\n";
  s +=   '<tr>' + "\n";
  s +=     '<td bgcolor="#E8F0F7"><table border="0" cellpadding="0" cellspacing="2" height="20">' + "\n";
  s +=       '<tr>' + "\n";
  s +=         '<td><a href="#" onclick="iCal (\'' + campo + '\', ' + (realAnno - 1) + ', ' + realMese + ', \'' + selected + '\'); return false;"><img src="/images/anno_indietro.gif" width="14" height="13" border="0"></a></td>' + "\n";
  s +=         '<td><a href="#" onclick="iCal (\'' + campo + '\', ' + realAnno + ', ' + (realMese - 1) + ', \'' + selected + '\'); return false;"><img src="/images/mese_indietro.gif" width="14" height="13" border="0"></a></td>' + "\n";
  s +=         '<td width="100%" align="center" style="font-family: Arial; font-size: 12px; color: #222222;"><b>' + mesi [realMese - 1] + ' ' + realAnno + '</b></td>' + "\n";
  s +=         '<td><a href="#" onclick="iCal (\'' + campo + '\', ' + realAnno + ', ' + (realMese + 1) + ', \'' + selected + '\'); return false;"><img src="/images/mese_avanti.gif" width="14" height="13" border="0"></a></td>' + "\n";
  s +=         '<td><a href="#" onclick="iCal (\'' + campo + '\', ' + (realAnno + 1) + ', ' + realMese + ', \'' + selected + '\'); return false;"><img src="/images/anno_avanti.gif" width="14" height="13" border="0"></a></td>' + "\n";
  s +=       '</tr>' + "\n";
  s +=     '</table></td>' + "\n";
  s +=   '</tr>' + "\n";
  s +=   '<tr>' + "\n";
  s +=     '<td height="100%" bgcolor="#B2CCE4" valign="top"><table border="0" width="100%" cellpadding="2" cellspacing="1">' + "\n";
  s +=       '<tr height="18" align="center">' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Lu</b></td>' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Ma</b></td>' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Me</b></td>' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Gi</b></td>' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Ve</b></td>' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Sa</b></td>' + "\n";
  s +=         '<td style="font-family: Arial; font-size: 11px; color: #222222;"><b>Do</b></td>' + "\n";
  s +=       '</tr>' + "\n";

  var day = 0, giorno = '';

  for (i = 1; i <= 6; ++ i) {

    s +=     '<tr height="16" align="right">' + "\n";

    for (j = 1; j <= 7; ++ j) {

      if ((day > 0) || (j >= firstWeekDay)) ++ day;
      if ((day > 0) && (day <= monthDays)) {

        giorno = '' + realAnno;
        giorno += (realMese < 10 ? '0' : '') + realMese;
        giorno += (day < 10 ? '0' : '') + day;

        if (giorno == s_oggi) {

          color = '#FFFFFF';
          bgcolor_off = (giorno == selected ? '#9EB7A1' : '#7D858C');
          bgcolor_on = (giorno == selected ? '#AABEA5' : '#A7B7AA');

        } else {

          color = '#222222';
          bgcolor_off = (giorno == selected ? '#C5F0CB' : '#B2CCE4');
          bgcolor_on = (giorno == selected ? '#DAFBD2' : '#D4F0DA');

        }

        td_stile = 'font-family: Arial; font-size: 10px; background: ' + bgcolor_off + ';';

        giorno = '<a href="#" onclick="if (window.setData) setData (\'' + (day < 10 ? '0' : '') + day + '\', \'' + (realMese < 10 ? '0' : '') + realMese + '\', \'' + realAnno + '\', \'' + campo + '\'); iCal (\'' + campo + '\', ' + realAnno + ', ' + realMese + ', \'' + giorno + '\'); return false;" style="text-decoration: none; color: ' + color + ';">&nbsp;' + (day < 10 ? ' ' : '') + day + '&nbsp;</a>';
        giorno = '<td style="' + td_stile + '" onMouseOver="this.style.background = \'' + bgcolor_on + '\';" onMouseOut="this.style.background = \'' + bgcolor_off + '\';">' + giorno + '</td>';

      } else giorno = '<td style="font-family: Arial; font-size: 10px;">&nbsp;</td>'

      s += giorno + "\n";

    }

    s +=     '</tr>' + "\n";

  }

  s +=     '</table></td>' + "\n";
  s +=   '</tr>' + "\n";
  s += '</table>' + "\n";

  div.innerHTML = s;

}

// -->