/**
 * Procedimiento que escribe la línea del copyright y la última modificación, en función del idioma de la página.
 * idioma = "English" (inglés), "Español", "Deutsch" (alemán).
 */
function escribeCopyright(idioma) 
{	
  var d = new Date();	 
  document.write("<div class=\"copyright\">\n");
  
  		     		 
  if (idioma=="English") 
  {
    document.write("&copy; 2003-" + d.getFullYear() + " <a href=\"http://www.frav.es\">Face Recognition &amp; Artificial Vision Group</a><br />");  	
    document.write("<a href=\"http://www.datcccia.etsii.urjc.es/\">Department of Computer Architecture and Technology and Computing Sciences and Artificial Intelligence</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /><br />"+
  		   "<a href=\"http://www.etsii.urjc.es\">High Technical School of Computer Engineering</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /> :: <a href=\"http://www.urjc.es\">Rey Juan Carlos University</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /><br />");	
    document.write("<a href=\"http://www.frav.es/sitemap.html\">Sitemap</a> :: Web credits: <a href='http://www.aserrano.es/index_english.htm'>Dr Ángel Serrano Sánchez de León</a> :: Latest update: January 23, 2012\n");
  }
  else if (idioma=="Español")
  { 
    document.write("&copy; 2003-" + d.getFullYear() + " <a href=\"http://www.frav.es\">Grupo de Reconocimiento Facial &amp; Visión Artificial</a> <br />");  	   
    document.write("<a href=\"http://www.datcccia.etsii.urjc.es/\">Departamento de Arquitectura y Tecnología de Computadores y Ciencias de la Computación e Inteligencia Artificial</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Enlace a una página externa\" title=\"Enlace a una página externa\" /><br />"+
  		   "<a href=\"http://www.etsii.urjc.es\">Escuela Técnica Superior de Ingeniería Informática</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Enlace a una página externa\" title=\"Enlace a una página externa\" /> :: <a href=\"http://www.urjc.es\">Universidad Rey Juan Carlos</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Enlace a una página externa\" title=\"Enlace a una página externa\" /><br />");	 	
    document.write("<a href=\"http://www.frav.es/mapadelsitio.html\">Mapa del sitio</a> :: Créditos de la web: <a href='http://www.aserrano.es'>Dr. Ángel Serrano Sánchez de León</a> :: Última modificación: 23 enero 2012\n");  
  }
  else if (idioma=="Deutsch") { 
  	// OBSOLETO!!!!
    document.write("&copy; 2003-2010 <a href=\"http://www.frav.es\">Face Recognition &amp; Artificial Vision Group</a> :: ");  	
    document.write("<a href=\"http://dac.etsii.urjc.es\">División de Arquitectura de Computadores</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /><br />"+
  		   "<a href=\"http://www.datcccia.etsii.urjc.es/\">Departamento de Arquitectura y Tecnología de Computadores y Ciencia de la Computación e Inteligencia Artificial</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /><br />"+
  		   "<a href=\"http://www.etsii.urjc.es\">Escuela Técnica Superior de Ingeniería Informática</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /> :: <a href=\"http://www.urjc.es\">Rey Juan Carlos University</a> <img src=\"http://www.frav.es/images/enlace.png\" alt=\"Link to an external web\" title=\"Link to an external web\" /><br />");	 	
    document.write("<a href=\"http://www.frav.es/seitenkarte.html\">Seitenkarte</a> :: Webdesign: <a href='http://www.aserrano.es/index_deu.html'>Ángel Serrano</a> :: Letzte Aktualisierung: 2.3.2009\n");      
  }
  
  document.write("<br />");
  
  if (idioma=="English") 
  {  
    document.write("<a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.frav.es/images/valid-xhtml10.png\" alt=\"Valid XHTML 1.0 Transitional\" title=\"Valid XHTML 1.0 Transitional\" height=\"31\" width=\"88\" /></a> ");       
    document.write("<a href=\"http://jigsaw.w3.org/css-validator/check/referer\"><img src=\"http://www.frav.es/images/valid-css.png\" alt=\"Valid CSS\" title=\"Valid CSS\" /></a> ");         	
    document.write("<a href=\"http://validator.w3.org/feed/check.cgi?url=http%3A//www.frav.es/frav-english.xml\"><img src=\"http://www.frav.es/images/valid-rss.png\" alt=\"Valid RSS\" title=\"Valid RSS\" /></a> ");       
  }
  else if (idioma=="Español")
  { 
    document.write("<a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.frav.es/images/valid-xhtml10.png\" alt=\"XHTML 1.0 Transicional válido\" title=\"XHTML 1.0 Transicional válido\" height=\"31\" width=\"88\" /></a> ");       
    document.write("<a href=\"http://jigsaw.w3.org/css-validator/check/referer\"><img src=\"http://www.frav.es/images/valid-css.png\" alt=\"CSS válido\" title=\"CSS válido\" /></a> ");        	
    document.write("<a href=\"http://validator.w3.org/feed/check.cgi?url=http%3A//www.frav.es/frav.xml\"><img src=\"http://www.frav.es/images/valid-rss.png\" alt=\"RSS válido\" title=\"RSS válido\" /></a> ");       
  }
  
  //PHPcounter();
  // Lo quito porque usamos Google Analytics.
   
  
  
  document.write("</div>\n");    
}

//function PHPcounter() {
  //document.write("<a href=\"http://phpcounter.sourceforge.net/phpcounter/index.php?l=&name=frav\">");document.write("<img src=\"http://phpcounter.sourceforge.net/phpcounter/hit.php?name=frav&Referer="+escape(document.referrer)+"\" alt=\"Counter\" title=\"Counter\">");document.write("<");document.write("/a>");
  //document.write("<a href=\"http://phpcounter.sourceforge.net/phpcounter/?name=frav\">");document.write("<img src=\"phpcounter/phpcounter.gif\" alt=\"Counter\" title=\"Counter\">");document.write("<");document.write("/a>");
//}


/**
 * Función que devuelve la ruta relativa al directorio images en función del nivel de la jerarquía de directorios.
 */
function getRaiz (nivel) {
  // Cálculo de la ruta relativa al directorio images, en función del nivel de la jerarquía de directorios.	 
  var ruta = "";
  if (nivel=="0") {
    ruta="./";	
  }
  else {
    var i=0;
    for (i=0; i<nivel; i++) 
    {
      ruta += "../";	
    }	
  }  
  return ruta;
}



/**
 * Procedimiento que escribe la tabla que contiene el menú superior de cada página, en función de los siguientes parámetros:
 * idioma = "English" (inglés), "Español", "Deutsch" (alemán).
 * nivel = número natural que indica el nivel dentro de la jerarquía de directorios. Para el raíz: 0, para niveles inferiores: 1,2,3...
 * paginaActual = nombre identificativo de la página actual, para saber qué botón hay que dejar desactivado (el que corresponde a la página actual).
 */
function escribeMenuSuperior(idioma,nivel,alt1,alt2)
{
  var ruta = "";	
  var raiz = "";
  raiz = getRaiz (nivel);
  rutaImages = raiz + "images/";	  
	
  var alt="";
  var pagina="";
  
  document.write("<table background=\"" + rutaImages + "fondo2.gif\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
  document.write("  <tr>\n");
  document.write("    <td align=\"right\" valign=\"bottom\">\n");
  
  
  
  // Botón de cambio de idioma
 
  if (idioma=="English") { 
    document.write("&nbsp;<a href=\"" + raiz + "frav-english.xml\"><img src=\"" + rutaImages + "rss.png\" title=\"RSS\" alt=\"RSS\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"http://www.facebook.com/fravurjc\"><img src=\"" + rutaImages + "facebook.png\" title=\"Become a fan of FRAV in Facebook\" alt=\"Become a fan of FRAV in Facebook\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"http://www.linkedin.com/groups/Face-Recognition-and-Artificial-Vision-4103982\"><img src=\"" + rutaImages + "linkedin.png\" title=\"Join FRAV in Linkedin\" alt=\"Join FRAV on Linkedin\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"http://www.youtube.com/user/fravurjc\"><img src=\"" + rutaImages + "youtube.jpg\" title=\"FRAV videos on YouTube\" alt=\"FRAV videos on YouTube\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"https://picasaweb.google.com/118404027381530551669\"><img src=\"" + rutaImages + "picasa.jpg\" title=\"FRAV pictures on Picasa\" alt=\"FRAV pictures on Picasa\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"" + raiz + alt1 + "\"><img src=\"" + rutaImages + "espanol.png\" title=\"Español\" alt=\"Español\" /></a>&nbsp;");  
//    if (alt2!="")  {
//      document.write("<a href=\"" + raiz + alt2 + "\"><img src=\"" + rutaImages + "deutsch.png\" title=\"Deutsch\" alt=\"Deutsch\" /></a> ");      
//    }
  }
  
  if (idioma=="Español") {
    document.write("&nbsp;<a href=\"" + raiz + "frav.xml\"><img src=\"" + rutaImages + "rss.png\" title=\"RSS\" alt=\"RSS\" /></a>&nbsp;");    	   	
    document.write("&nbsp;<a href=\"http://www.facebook.com/fravurjc\"><img src=\"" + rutaImages + "facebook.png\" title=\"Hazte fan de FRAV en Facebook\" alt=\"Hazte fan de FRAV en Facebook\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"http://www.linkedin.com/groups/Face-Recognition-and-Artificial-Vision-4103982\"><img src=\"" + rutaImages + "linkedin.png\" title=\"Únete a FRAV en Linkedin\" alt=\"Únete a FRAV en Linkedin\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"http://www.youtube.com/user/fravurjc\"><img src=\"" + rutaImages + "youtube.jpg\" title=\"Vídeos de FRAV en YouTube\" alt=\"Vídeos de FRAV en YouTube\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"https://picasaweb.google.com/118404027381530551669\"><img src=\"" + rutaImages + "picasa.jpg\" title=\"Fotos de FRAV en Picasa\" alt=\"Fotos de FRAV en Picasa\" /></a>&nbsp;");    	 
    document.write("&nbsp;<a href=\"" + raiz + alt1 + "\"><img src=\"" + rutaImages + "english.png\" title=\"English\" alt=\"English\" /></a>&nbsp;");  
//    if (alt2!="")  {    
//      document.write("<a href=\"" + raiz + alt2 + "\"><img src=\"" + rutaImages + "deutsch.png\" title=\"Deutsch\" alt=\"Deutsch\" /></a> ");      
//    }
  }
    
  if (idioma=="Deutsch") {
    document.write("<a href=\"" + raiz + alt1 + "\"><img src=\"" + rutaImages + "espanol.png\" title=\"Español\" alt=\"Español\" /></a> ");  
    document.write("<a href=\"" + raiz + alt2 + "\"><img src=\"" + rutaImages + "english.png\" title=\"English\" alt=\"English\" /></a> ");      
  }
    
  document.write("    </td>\n");
  document.write("  </tr>\n");
  document.write("</table>\n");    
}

/**
 * Procedimiento que escribe la cabecera de todas las páginas, en función del nivel en la jerarquía de directorios.
 * nivel = número natural que indica el nivel dentro de la jerarquía de directorios. Para el raíz: 0, para niveles inferiores: 1,2,3... 
 */
function escribeCabecera(idioma,nivel) {
  var ruta = "";	
  ruta = getRaiz (nivel);  
  menu(idioma,ruta);  
  
  ruta2 = ruta + "images/";	
    
  var alt="";
  switch (idioma) {
    case "English" :
      alt="FRAV --- Face Recognition &amp; Artificial Vision Group";
      fravito = "Fravito, our mascot";
      fravitoweb = "videosandpictures";
      uni = "Rey Juan Carlos University";
      enlaceTxt= "Link to an external page";
      break;
    case "Español" :
      alt="FRAV --- Grupo de Reconocimiento Facial &amp; Visión Artificial";
      fravito = "Fravito, nuestra mascota";
      fravitoweb = "videosyfotos";
      uni = "Universidad Rey Juan Carlos";
      enlaceTxt= "Enlace a una página externa";
      break;
    case "Deutsch" :
      alt="FRAV --- Gesichtserkennung- und Künstliches Sehen-Gruppe";
      fravito = "Fravito, unseres Maskottchen";
      fravitoweb = "videosundfotos";
      uni = "Rey Juan Carlos University";
      break;
  }   
  
  document.write("<a name=\"arriba\"></a>");  	
  document.write("<table border=\"0\" width=\"100%\">\n");
  document.write("  <tr>\n");
  document.write("    <td align=\"left\">\n");
  document.write("      <a href=\"http://www.frav.es\"><img src=\""+ruta2+"logo_frav.gif\" title=\"" + alt + "\" alt=\"" + alt + "\" /><img src=\""+ruta2+"puntoes.gif\" title=\"" + alt + "\" border=\"0\" /></a>\n");
  document.write("    </td>\n");
  document.write("    <td>\n");
  document.write("      <a href=\"http://www.frav.es\"><img src=\""+ruta2+"title.gif\" title=\"" + alt + "\" title=\"" + alt + "\" /></a>\n");
  document.write("    </td>\n");
  document.write("    <th align=\"right\">\n");
  document.write("      <img src='"+ruta2+"fravito.jpg' title='" + fravito + "' alt='" + fravito + "' />\n");
  document.write("    </th>\n");  
  document.write("    <th align=\"right\">\n");
  document.write("      <img src=\""+ruta2+"logo_urjc.png\" title='" + uni + "' alt='" + uni + "' />\n");
  document.write("    </th>\n");
  document.write("  </tr>\n");
  document.write("</table><br/>\n");
  
}

function openWindow(URL,Height,width) {
  var v = window.open(URL,"win","height="+Height+",width="+width+",resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no");	
}



function escribeAppletPuzzle() { 
  var num=5;
  num = Math.floor(Math.random()*num);
  if (num<0 || num>5) num=4;
    	
  document.write('<CENTER><APPLET CODEBASE="./" CODE="puzzlemaker.class" WIDTH=250 HEIGHT=250>');
  document.write('<PARAM NAME="AUTHOR" VALUE="Virtual_Max (http://come.to/vmax)">');
  document.write('<PARAM NAME="IMAGE" VALUE="../images/image' + num + '.jpg">');
  document.write('<PARAM NAME="KEY" VALUE="112111122-134127118611281071">');
  document.write('<PARAM NAME="ROWS" VALUE="5">');
  document.write('<PARAM NAME="COLS" VALUE="5">');
  document.write('<PARAM NAME="BGCOLOR" VALUE="000080">');
  document.write('<PARAM NAME="TEXTCOLOR" VALUE="00ff00">');
  document.write('</APPLET>');
  document.write('</CENTER>');	
}


function insertaFoto (raiz,numero,comentario,inicio,fin,tamanno)
{
	
  document.write("<p class='orangecenter'>"+numero+"/"+fin+"</p>");
	
  var numCeros = 0;
  var numCerosAnt = 0;
  var numCerosSig = 0;
  var numeroAnt = numero - 1;
  var numeroSig = numero + 1;
  
  numCeros = Math.ceil(Math.log(fin)/Math.log(10.)) - Math.ceil(Math.log(numero)/Math.log(10.));
  //alert(numCeros);
  if (Math.ceil(Math.log(numero)/Math.log(10.)) == Math.log(numero)/Math.log(10.))
  {
    //alert(Math.ceil(Math.log(numero)/Math.log(10.)));
    //alert(Math.log(numero)/Math.log(10.));
    //alert(Math.ceil(Math.log(numero)/Math.log(10.)) == Math.log(numero)/Math.log(10.));
    numCeros--;
  }
  //alert(numCeros);
     
  var ceros = "";
  var i = 0;
  for (i = 0; i<numCeros; i++) ceros+= "0";  
  var cerosAnt = "";
  var cerosIni = "";
  var cerosFin = "";
  var cerosSig = "";

  	
  document.write('<center>');
  if (numero>inicio)
  {       
    for (i = 0; i<(Math.ceil(Math.log(fin)/Math.log(10.))-1); i++) cerosIni+= "0";    
        
    document.write("<a href='"+raiz+cerosIni+"1.html'><<</a> &nbsp; &nbsp;");  	  	
  	
    numCerosAnt = Math.ceil(Math.log(fin)/Math.log(10.)) - Math.ceil(Math.log(numeroAnt)/Math.log(10.));  	
    if (Math.ceil(Math.log(numeroAnt)/Math.log(10.)) == Math.log(numeroAnt)/Math.log(10.))
    {
      numCerosAnt--;
    }
    
    for (i = 0; i<numCerosAnt; i++) cerosAnt+= "0";    
        
    document.write("<a href='"+raiz+cerosAnt+numeroAnt+".html'><</a> &nbsp; &nbsp;");
  }
  
  document.write("<a href='index.html'>^</a> &nbsp; &nbsp;");
  
  if (numero<fin)
  {
    numCerosSig = Math.ceil(Math.log(fin)/Math.log(10.)) - Math.ceil(Math.log(numeroSig)/Math.log(10.));
    if (Math.ceil(Math.log(numeroSig)/Math.log(10.)) == Math.log(numeroSig)/Math.log(10.))
    {
      numCerosSig--;
    }    
    
    for (i = 0; i<numCerosSig; i++) cerosSig+= "0";    
    document.write("<a href='"+raiz+cerosSig+numeroSig+".html'>></a>");
        
                
    document.write("&nbsp; &nbsp; <a href='"+raiz+fin+".html'>>></a>");  	      
  }  
  
  document.write("<br><br><img src='"+raiz+ceros+numero+".JPG' title='"+comentario+"' border='0' width='"+tamanno+"'><br><br>");
  document.write("<p class='orangecenter'>"+comentario+"</p>");
  
  /*
  
  if (numero>inicio)
  {       
    document.write("<a href='"+raiz+cerosIni+"1.html'><<</a> &nbsp; &nbsp;");  	
      	
    numeroAnt = numero - 1;
    document.write("<a href='"+raiz+cerosAnt+numeroAnt+".html'><</a> &nbsp; &nbsp;");
  }
  
  document.write("<a href='index.html'>^</a> &nbsp; &nbsp; ");
  
  if (numero<fin)
  {
    numeroSig = numero + 1;
    document.write("<a href='"+raiz+cerosSig+numeroSig+".html'>></a>");
    
    document.write("&nbsp; &nbsp; <a href='"+raiz+fin+".html'>>></a>");  	      
  }  
    
      
  document.write("<br><br>");
  */
  document.write('</center>');	
}
