<html>
  <head>
    <link rel="stylesheet" href="../estils/hoja.css" type="text/css">
    <title>Notícies</title>
  </head>

  <body leftmargin="0" topmargin="0" bgcolor="#8F0000">
    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
      <tr>
        <!-- Menú dret -->
        <td align="left" valign="top" width="100" bgcolor="#4F0000">
          <?php include("../menu.inc") ?>
        </td>
        <!-- Capçalera -->

        <td align="left" valign="top" width="100%" class="centered">
          <h2>Departament d'Enginyeria Informàtica i Matemàtiques</h2>
          <img src="images/separador.gif"><br>
          <br><center><?php include("../language.inc"); ?></center><br>
          <br>

          <div align="left">
            <blockquote>
              <!-- Començament del cos -->
              <?php include("../private/connect.inc");
                            $lang = $_COOKIE["lang"];
                            if ($lang=="es") {
                              $taula ="novetats_es";
                            } else if ($lang=="en") {
                              $taula ="novetats_en";
                            } else {
                              $lang="cat";
                              $taula ="novetats";
                            }
                            echo "<h2>".$text[Noticies]."</h2>";
                            $link=Conectar();
                            $result=mysql_query("SELECT nid,titol,date FROM ". $taula ." ORDER BY date DESC",$link);
                            echo("<table border=\"0\" width=\"90%\" align=\"left\">");
                            echo("<tr bgcolor=black><td><b>" . $text[Data] ."</b></td><td><b>".$text[Titol]."</b></td>
                                   </tr>");
                            // Saltem fins a la noticia indicada
                            $bucle=0;
                            while ($bucle<$_GET["pag"]) {
                              $row = mysql_fetch_array($result);
                              $bucle++;
                            }
                            // Mostrem 10 noticies des de la indicada
                            $bucle=0;
                            while (($row = mysql_fetch_array($result))&&($bucle<10)) {
            		              $dd = substr($row["date"], 6, 2);
                              $mm = substr($row["date"], 4, 2);
                              $yy = substr($row["date"], 0, 4);
                              $nid = $row["nid"];
                              echo("<tr><td align=\"left\"> <div align=\"left\">" . $dd . "-" . $mm 
                              . "-" . $yy . "</td>");
                              printf("<td><b>&nbsp; %s</b>&nbsp;&nbsp;&nbsp;</td>",
                              htmlspecialchars($row["titol"]));
                              echo("<td><a href=\"veure.php?nid=$nid\">");
                              echo("<input type=\"image\" border=0 src=\"images/".$lang."/veure.jpg\"></a></td></tr>");
                              $bucle++;
                            }
                            mysql_free_result($result);
                            // Si $row no era null es que encara queden noticies, per tant mostrem link.
                            if ($row != null) {
                              echo "<tr><td colspan=\"2\" align=\"center\"><br><a href=\"historic.php?pag=";
                              echo $_GET["pag"]+10;
                              echo "\">Següents</a></td></tr>";
                            }
                      ?>
              <tr><td><br><input type="image" src="images/<?php echo $lang; ?>/tornar.jpg" onClick="history.go(-1)"></td></tr>
              </table>
            </blockquote>
          </div>
        </td>
      </tr>
    </table>
  </body>
</html>

