  <LINK REL="stylesheet" TYPE="text/css" HREF="calendario.css">
  <DIV ID=overDiv STYLE="position:absolute; visibility:hide; z-index:1;"></DIV> <SCRIPT LANGUAGE=JavaScript SRC=overlib.js></SCRIPT>
  <?php
  $letter_of_day = array('Dl','Dm','Dx','Dj','Dv','Ds','Di');
  $string_of_day = array('Dilluns','Dimarts','Dimecres','Dijous','Divendres','Dissabte','Diumenge');
  $months = array('Gener', 'Febrer', 'Mar&ccedil;', 'Abril', 'Maig', 'Juny', 'Juliol', 'Agost', 'Setembre', 'Octubre', 'Novembre', 'Desembre');

  if(!isset($_GET['_day'])) $_day = date("j");
  else $_day = $_GET['_day'];

  if(!isset($_GET['_year'])) $_year= date("Y");
  else $_year = $_GET['_year'];

  if(!isset($_GET['_month'])) $_month = date("n");
  else{
    $_month = $_GET['_month'];
    if($_month == date('n') && $_year == date('Y')) $_day = date('j');
  }

  include("make_popup_info.php");

  if($_day) {	
  	$timestamp = mktime(0,0,0,$_month, $_day, $_year);
  } else {
  	$timestamp = mktime(0,0,0,$_month, 1, $_year);
  }

  $date_info = getdate($timestamp);
  $number_of_days = date("t", $timestamp);
  $first_day = abs((date("w", mktime(0,0,0,$_month,1,$_year))+6)%7);

  $month_before = $_month - 1;
  if($month_before == 0) {
  	$month_before = 12;
  	$year_before = $_year - 1;
  } else {
  	$year_before = $_year;
  }

  $next_month = $_month + 1;
  if($next_month== 13) {
  	$next_month= 1;
  	$next_year= $_year + 1;
  } else {
  	$next_year = $_year;
  }
  ?>

  <TABLE WIDTH = 100%  CLASS = tabla CELLSPACING=0 CELLPADDING = 0 ALIGN=Center>

  <TR CELLPADDING = 0>
  <TD ALIGN = left CLASS = botones><A HREF=index.php?_day=0&_month=<?php echo "$month_before"; ?>&_year=<?php echo "$year_before"; ?>&page=<?php echo $page; ?>&id=<?php echo $id; ?>&orden=<?php echo $orden; ?> alt='Anar al mès anterior' title='Anar al mès anterior'> <IMG SRC= "images/flecha_esq.gif" BORDER = 0></IMG> </A></TD> 

  <TD CLASS = titulo COLSPAN = 5>
    <FONT CLASS = titulo_font>
      <A HREF=index.php?page=event1&_day=0&_month=<?php echo "$_month"; ?>&_year=<?php echo "$_year"; ?>&month=<?php echo $_month; ?>&year=<?php echo "$_year"; ?> onMouseOut="" onMouseOver="" alt='Veure totes les activitats del mès' title='Veure totes les activitats del mès'><?php echo $months[$_month-1]; ?></A>
      <A HREF=index.php?page=event1&_day=0&_month=<?php echo $_month; ?>&_year=<?php echo "$_year"; ?>&year=<?php echo "$_year"; ?> onMouseOut="" onMouseOver="" alt="Veure totes les activitats de l'any" title="Veure totes les activitats de l'any"><?php echo "$_year"; ?></A>
    </FONT>
  </TD>

  <TD ALIGN = right CLASS = botones ><A HREF=index.php?_day=0&_month=<?php echo "$next_month"; ?>&_year=<?php echo "$next_year"; ?>&page=<?php echo $page; ?>&id=<?php echo $id; ?>&orden=<?php echo $orden; ?> alt='Anar al mès següent' title='Anar al mès següent'><IMG SRC = "images/flecha_dre.gif" BORDER = 0></IMG></A></TD> 
  </TR>

  <TR>
  <?php
  /* Letras iniciales de los dias de la semana */

  for($i=0; $i<7; $i++) {
  	printf("<TD CLASS = iniciales_dias><A HREF='javascript:void(0);' alt='%s' title='%s'>%s</A></TD>",$string_of_day[$i],$string_of_day[$i],$letter_of_day[$i]);
  }
  ?>
  </TR>
  <TR>
 
  <?php 
  /* Pintar celdas del mes anterior */
  $celdas = 0;
  $celdas_total=0;
  $filas = 1;
  for($i=0; $i<$first_day; $i++) {
  	printf("<TD CLASS = day_other_month>&nbsp;</TD>");
  	$celdas++;
  	$celdas_total++;
  }


  for($i=0; $i<$number_of_days; $i++) {
    $temp = $i+1;
    if($popup_info[$i]=="") {
      /* No hay eventos */
      $class = 'day_without_events';
      $font = 'day_without_events_font';
      $openpop="<a href='javascript:void(0);' alt='No hi ha cap activitat' title='No hi ha cap activitat'";
      $closepop="</a>";
      if($temp == $_day){
        /* Dia de hoy */
        $class = 'dia_actual_without_events';
        $font = 'dia_actual_without_events_font';
        $openpop="<a href='javascript:void(0);' alt='Dia actual' title='Dia actual'";
        $closepop="</a>";
      }
    } else{ 
      /* Si hay eventos */
      $class = 'day_with_events';
      $font = 'day_with_events_font';
      if($temp == $_day){
        /* Dia de hoy */
        $class = 'dia_actual_with_events';
        $font = 'dia_actual_with_events_font';
      }

      $openpop="<A HREF=\"javascript:void(0);\" onMouseOver=\"return overlib('$popup_info[$i]',STICKY,MOUSEOFF,CAPTION,'&nbsp;Activitats&nbsp;')\" onMouseOut=\"nd();\" onClick=\"javascript:document.location='$popup_link[$i]' \">";
      $closepop="</A>";
    }

    echo "<TD><DIV CLASS = $class>$openpop<FONT CLASS = $font>$temp</FONT>$closepop</DIV></TD>";

    $celdas++;
    $celdas_total++;
    if($celdas == 7 && $i+1<$number_of_days) {
      printf("</TR><TR>");
      $celdas = 0;
      $filas++;
     }
  }

  if($celdas_total<$filas*7)
  	for($i=0; $i<$filas*7-$celdas_total; $i++) 
          printf("<TD CLASS = day_other_month> &nbsp;</TD>");
  ?>
  </TR>
  </TABLE>
