   // --- cmenus.js  versión 1.66 -- castellano --------------------------------------------------------------------------------

   // Cambios de la version 1.66  -----------------------------------------------------------   
   //   Se permiten enlaces de correo con mailto: en la barra de menus y la de botones
   // Cambios de la version 1.65  -----------------------------------------------------------
   //   Si el raiz es "" no se concatena nada al nombre de las imagenes
   // Cambios de la version 1.64  -----------------------------------------------------------
   //   Permite especificar un subdirectorio para la barra de botones superior 
   //   con la llamada a la funcion MostrarBarra(color, subdir)
   // Cambios de la version 1.63  -----------------------------------------------------------
   //   Se puede especificar un color para la barra de arriba para todo el sitio
   // Cambios de la version 1.62  -----------------------------------------------------------
   //   Corrige el problema de las subwebs http://www.ua.es/web/...
   // Cambios de la version 1.61  -----------------------------------------------------------   
   //   Corrige el error de Netscape 7
   // Cambios de la version 1.6  ------------------------------------------------------------   
   //   Permite poner una barra de enlaces con imágenes en cualquier sitio
   // Cambios de la version 1.59 ------------------------------------------------------------
   //   Deja especificar una url para la cabecera distinta de la de por defecto. 
   // Cambios de la version 1.58 ------------------------------------------------------------
   //   Quita el espacio en blanco que aparecía en iExplorer al poner la caja de busqueda
   // Cambios de la version 1.57 ------------------------------------------------------------
   //   Quita el espacio en blanco que aparecía debajo de la cabecera
   // Cambios de la version 1.56 ------------------------------------------------------------
   //   Se puede añadir en la barra de botones la opción de buscar dentro del web
   // Cambios de la version 1.55 ------------------------------------------------------------
   //   Las urls de las imagenes comunes se ponen absolutas a http://www.ua.es si no estamos
   //   en www.ua.es
   // Cambios de la version 1.54 ------------------------------------------------------------
   //   Arregla el error de la fecha de actualización al visualizarlo con NS 4.x
   // Cambios de la version 1.53 ------------------------------------------------------------
   //   A la hora llamar a la funcion MostrarBarra podemos indicarle el color de fondo como
   //   primer argumento, si no ponemos nada será el azul por defecto MostrarBarra("#FFFFFF")
   // Cambios de la version 1.52 ------------------------------------------------------------
   //   Si algun elemento del menuItem no tiene enlace solo se muestra el boton desactivado
   //   Si en algun elemento de barraItem no tiene enlace solo se muestra el boton desactivado
   // Cambios de la version 1.51 ------------------------------------------------------------
   //   Si hay algun enlace de un elemento del menu o de la barra de botones que empieza 
   //   por / no lo concatena con la url raiz
   // Cambios de la version 1.5 -------------------------------------------------------------
   //   Se puede poner un array de imagenes para la cabecera que irán cambiando dinamicamente
   
   var raiz
   var mantenidaPor
   var mailMantenim
   var prePieComun
   var listaItems      // Lista de elementos del menu
   var barraBotones    // Lista de botones de la barra de botones
   var listaImagenes   // Lista de imágenes para el menu de imágenes
   var infoCabecera
   var imgsCabecera
   var cajaBusqueda
   var buscar    // Botón de buscar
   var inicioUrl
   var urlCabecera   // Dirección a la que se va al pinchar en la cabecera, sino base + index.htm
   var kVertical   = 121
   var kHorizontal = 245
   var colorBarra = "#D8E5EA"
   
   if (window.location.href.indexOf("www.ua.es")>=0) inicioUrl = ""
   else inicioUrl = "http://www.ua.es"
   if (window.location.href.indexOf("www.ua.es/web/")>=0) inicioUrl = "http://www.ua.es"
   
   imgsCabecera = new Array("cabecera.gif");   // Por defecto solo una imagen en la cabecera
   cajaBusqueda = false                        // Por defecto no hay caja de busqueda
   urlCabecera  = ""
 
   // Imagen para el boton de buscar
   buscar  = new Image; 
   buscara = new Image; 
   buscar.src  = "" + inicioUrl + "/imagenes/menus/buscar.gif"; 
   buscara.src = "" + inicioUrl + "/imagenes/menus/buscara.gif";

 
   // ------- Clase menuItem --------------------------------------------------------------------------------------------------   
   // Almacena un elemento del menu
   function menuItem (elNombre, elAncho, elAlto, laUrl, laInfo, elSubMenu) {
      this.nombre    = elNombre;      // Nombre de la imagen
	  this.url       = laUrl;         // Url destino de pinchar en el elento
	  this.info      = laInfo;        // Información de destino (alt)
	  this.pinta     = pintaItem;     // Funcion que genera el codigo del item
	  this.separador = pintaRaya;     // Método que genera el código del separador de los elementos del menu	  
	  this.imagenOn  = new Image ();  // Imagen cuando el boton está activado
	  this.imagenOff = new Image ();  // Imagen cuando el boton está desactivado
	  if (raiz == "") {   // Si no hay raiz se supone que en elNombre está toda la ruta
	     this.imagenOn.src  = elNombre + "a.gif";
	     this.imagenOff.src = elNombre + ".gif";	  
	  }
	  else {
	     this.imagenOn.src  = raiz + "imagenes/menu/" + elNombre + "a.gif";
	     this.imagenOff.src = raiz + "imagenes/menu/" + elNombre + ".gif";	  
	  }
	  this.imagenOn.width   = elAncho;   // Tamaños de las imagenes
	  this.imagenOn.height  = elAlto;
	  this.imagenOff.width  = elAncho;
	  this.imagenOff.height = elAlto;
	  this.subMenu = elSubMenu
   }

   // Metodo que genera el codigo html de un elemento del menu
   // Se le pasa el nombre javascript para llegar al objeto 
   function pintaItem (nombreObj) {
	  document.write("<tr BGCOLOR=\"#FFFFFF\">");
      document.write("  <td ALIGN=\"left\" VALIGN=\"top\">");
      if (this.url.length > 0) {
         if ((this.url.substr(0,4)=="http") || (this.url.substr(0,1)=="/") || (this.url.substr(0,6)=="mailto")) 
		    document.write ("<a href=\"" + this.url +"\" ");
         else 
		    document.write ("<a href=\"" +raiz + this.url +"\" ");
         document.write("    onMouseover=\"document['" +this.nombre+ "'].src = " + nombreObj + ".imagenOn.src\"  ");
         document.write("    onMouseout=\"document['" +this.nombre+ "'].src = " + nombreObj + ".imagenOff.src\"  ");
         document.write(" >");
      }
	  if (raiz == "")    // Si no hay raiz se supone que en elNombre está toda la ruta
         document.write("<img src=\""+this.nombre+".gif\"" );
	  else	  
	     document.write("<img src=\""+raiz+"imagenes/menu/" +this.nombre+".gif\"" );
      document.write("     name=\"" + this.nombre+ "\" " );
      document.write("     alt=\"" + this.info + "\" ");
      document.write("     title=\"" + this.info + "\" ");
	  document.write("       nosave=\"\"");
      document.write("     border=\"0\"");
      document.write("     height=\"" +this.imagenOn.height+ "\"");
      document.write("     width=\"" +this.imagenOn.width+ "\">");
      if (this.url.length > 0) document.write("</a>");
      document.write("</td>");
      document.write("</tr>");
   }
   
   // Metodo que genera el codigo html de el separador de los elementos del menu
   function pintaRaya () {
      document.write("<tr BGCOLOR=\"#FFFFFF\">");
      document.write("  <td ALIGN=\"left\" VALIGN=\"top\"><img src=\"" + inicioUrl + "/imagenes/menus/raya.gif\" border=\"0\" width=\"161\" height=\"1\"></td>");
      document.write("</tr>");
   }
   // ----------- Fin clase menuItem -------------------------------------------------------------------------------------------

   
   // ------- Clase barraItem --------------------------------------------------------------------------------------------------   
   // Almacena un elemento de la barra de enlaces
   function barraItem (elNombre, elAncho, elAlto, laUrl, laInfo) {
      this.nombre    = elNombre;        // Nombre de la imagen
	  this.url       = laUrl;           // Url destino de pinchar en el elento
	  this.info      = laInfo;          // Información de destino (alt)
	  this.pinta     = pintaBarraItem;  // Método que genera el codigo del item
	  this.imagenOn  = new Image ();
	  this.imagenOff = new Image ();
	  if (raiz == "") {   // Si no hay raiz se supone que en elNombre está toda la ruta
  	     this.imagenOn.src  = elNombre + "a.gif";
	     this.imagenOff.src = elNombre + ".gif";	  
	  }
	  else {	  
	     this.imagenOn.src  = raiz + "imagenes/menu/" + elNombre + "a.gif";
	     this.imagenOff.src = raiz + "imagenes/menu/" + elNombre + ".gif";	  
	  }
	  this.imagenOn.width   = elAncho;   // Tamaños de las imagenes
	  this.imagenOn.height  = elAlto;
	  this.imagenOff.width  = elAncho;
	  this.imagenOff.height = elAlto;
   }
   
   // Metodo que genera el codigo html de un elemento del menu
   // Se le pasa el nombre javascript para llegar al objeto 
   function pintaBarraItem (nombreObj, subDirectorio) {
      var auxDir
	  if (subDirectorio === undefined) auxDir = "";
	  else auxDir = subDirectorio + "/";

	  if (this.url.length > 0) {
	     if ((this.url.substr(0,4)=="http") || (this.url.substr(0,1)=="/") || (this.url.substr(0,6)=="mailto")) 
		    document.write ("<a href=\"" + this.url +"\" ");
	     else 
		    document.write ("<a href=\"" +raiz + auxDir + this.url +"\" ");
	     document.write("         onMouseover=\"document['" +this.nombre+ "'].src = " + nombreObj + ".imagenOn.src\"  ");
	     document.write("         onMouseout=\"document['" +this.nombre+ "'].src = " + nombreObj + ".imagenOff.src\"  ");
	     document.write("      >");
	  }
	  if (raiz == "")    // Si no hay raiz se supone que en elNombre está toda la ruta
	     document.write("<img src=\""+this.nombre+".gif\"" );
      else
	     document.write("<img src=\""+raiz+"imagenes/menu/" +this.nombre+".gif\"" );
	  document.write("            name=\"" + this.nombre+ "\" " );
	  document.write("            alt=\"" + this.info + "\" ");
	  document.write("            title=\"" + this.info + "\" ");	  
	  document.write("            border=\"0\"");
      document.write("            hspace=\"5\"");	  
	  document.write("            height=\"" +this.imagenOn.height+ "\"");
	  document.write("            width=\"" +this.imagenOn.width+ "\">");
      if (this.url.length > 0) document.write("</a>");
   }

   // ----------- Fin clase barraItem -------------------------------------------------------------------------------------------

   
   // ------- Clase imagenItem --------------------------------------------------------------------------------------------------   
   // Almacena una imagen del menu
   function imagenItem (elNombre, laUrl, laInfo) {
      this.nombre    = elNombre;      // Nombre de la imagen
	  this.url       = laUrl;         // Url destino de pinchar en el elento
	  this.info      = laInfo;        // Información de destino (alt)
	  this.pinta     = pintaImagen    // Funcion que genera el codigo del item
   }
   // Metodo que genera el codigo html de un elemento de imagen
   function pintaImagen () {
      document.write("<tr BGCOLOR=\"#FFFFFF\">");
      document.write("  <td ALIGN=\"left\" VALIGN=\"top\">&nbsp;</td>");
      document.write("</tr>");
      document.write("<tr BGCOLOR=\"#FFFFFF\">");
      document.write("  <td ALIGN=\"center\" VALIGN=\"top\"><a href=\"" + this.url + "\"");
	  if (raiz == "")    // Si no hay raiz se supone que en elNombre está toda la ruta	
	     document.write("><img src=\"" + this.nombre + ".gif\" ");   
	  else
	     document.write("><img src=\""+raiz+"imagenes/menu/" + this.nombre + ".gif\" ");
	  document.write("      alt=\"" + this.info + "\" ");
	  document.write("      title=\"" + this.info + "\" ");
	  document.write("      nosave=\"\" ");
	  document.write("      border=\"0\"></a></td>");
      document.write("</tr>");
   }
   // ----------- Fin clase imagenItem -------------------------------------------------------------------------------------------

   
   
   // Genera la cabecera
   function Cabecera() {
      hoy = new Date();     // Vamos a determinar cual es la imagen que toca dependiendo del segundo en el que nos encontremos
      segundos = parseInt(hoy.getSeconds());      
      proporcion = 60 / imgsCabecera.length;   // Vemos con respecto al número de imágenes cuanto tiempo corresponde a cada imagen
      if (proporcion>segundos) indice = 0            // Para el Netscape 4
      else indice = parseInt(segundos/proporcion);   // Obtenemos el índice de la imagen que corresponda
      if (indice>=imgsCabecera.length) indice = imgsCabecera.length-1;  // Si el número no es exacto le regalamos los últimos segundos a la última imagen 
      document.write("<div align=\"center\">");
      document.write("<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=682 BGCOLOR=#FFFFFF summary=\"Cabecera de la página\">");
      document.write("  <tr>");
      document.write("    <td><center><map name=\"Map\"><area shape=\"rect\" coords=\"0,0,165,36\" href=\"" + inicioUrl + "/es/index.html\" alt=\"Universidad de Alicante\" title=\"Universidad de Alicante\">");
	  document.write("<area shape=\"poly\" coords=\"164,1,164,35,1,35,1,98,680,98,680,1\" ");
	  if (urlCabecera =="") document.write(" href=\""+raiz+"index.html\" ");
	  else document.write(" href=\""+ urlCabecera + "\" ");
      document.write(" alt=\""+ infoCabecera + "\" title=\""+ infoCabecera + "\"></map></center></td>");
	  if (raiz=="") 
         document.write("    <td ALIGN=LEFT VALIGN=BOTTOM><img SRC=\""+ imgsCabecera[indice] + "\" NOSAVE BORDER=0 usemap=\"#Map\" height=100 width=682></td>");
	  else
         document.write("    <td ALIGN=LEFT VALIGN=BOTTOM><img SRC=\""+raiz+"imagenes/menu/" + imgsCabecera[indice] + "\" NOSAVE BORDER=0 usemap=\"#Map\" height=100 width=682></td>");
	  document.write("  </tr>");
      document.write("</table>");
	  document.write("</div>");	  
   }
      

    // --- Funciones para la caja de buscar
    function activa(img1,img2) {
       document[img1].src = eval(img2 + ".src");
    }

    function comprobar2() {
        if (comprobarPalabras())
                document.fbuscar.submit()
        else return
    }

    function comprobarPalabras() {
        arrayofcadenas= document.fbuscar.words.value.split(" ");
        Si=0;
        for (var i=0; i<arrayofcadenas.length; i++)
              if (arrayofcadenas[i].length>2) {
                      Si=1;
                      break;
              }
        if (Si==1) return true;
        else {
                alert("Introduzca palabras más largas");
                return false;
        }
    }
   
   
   // Muestra la barra de botones
   function MostrarBarra(colorFondo, subCarpeta) {
      if (colorFondo === undefined) colorFondo = colorBarra;
	  if (colorFondo == "") colorFondo = colorBarra;
	  document.write("<DIV align=\"center\">");
	  document.write("<TABLE border=0 cellspacing=0 cellpadding=0 width=\"682\" bgcolor=\"#ffffff\" summary=\"\">");
      // Miro si hay barra de botones o no
	  if (barraBotones === undefined) {
         document.write("  <tr>");
		 if (cajaBusqueda!=true)
            document.write("<td ALIGN=\"LEFT\" VALIGN=\"CENTER\">&nbsp;</td>");
      }	  
	  else {
	     document.write("  <TR>");
	     document.write("    <TD bgcolor=\"" + colorFondo + "\" align=\"LEFT\" valign=\"center\" height=\"18\">");
	     for (i=0; i<barraBotones.length; i++) {
	        if (i>0) document.write("<IMG SRC=\"" + inicioUrl + "/imagenes/menus/bs.gif\" ALT=\"\" height=\"18\" width=\"1\">");
		    barraBotones[i].pinta("barraBotones["+i+"]",subCarpeta);  // Pinto el elemento de la barra
	     }
	     document.write("</TD>");
	  }
	  if (cajaBusqueda == true) {
	     document.write("<FORM name=\"fbuscar\" id=\"fbuscar\" method=\"post\" action=\"http://buscador.cpd.ua.es/cgi-bin/htdig/htsearch\" onsubmit=\"return comprobarPalabras()\">");
		 document.write("<INPUT type=\"hidden\" name=\"restrict\" value=\"" + raiz + "\">");
		 document.write("<td bgcolor=\"" + colorFondo + "\" align=\"right\" valign=\"center\">");
         document.write("<input type=\"text\" name=\"words\" value=\"\" size=\"6\">");
		 document.write("<a href=\"javascript:comprobar2();\" onMouseOver=\"activa('buscar','buscara')\" onMouseOut=\"activa('buscar','buscar')\">");
		 document.write("<img SRC=\""+ inicioUrl +"/imagenes/menus/buscar.gif\" NAME=\"buscar\" ALT=\"Buscar\" NOSAVE BORDER=0 height=17 width=48></a>");
         document.write("</td>");
		 document.write("</FORM>");		 
	  } 
      document.write("  </TR>");
	  document.write("</TABLE>");
	  document.write("</DIV>");
	  
   }


   // Maximo 3 subniveles
   // @param indice El indice dentro de listaItems del elemento del menu que va a estar desplegado
   // @param subIndice El indice dentro de listaItems[indice].submenu del elemento del subMenu que va a estar desplegado
   function MostrarMenus(indice, subIndice) {
      document.write("<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=\"100%\" summary=\"Menús\">");
      for (i=0; i<listaItems.length; i++) {
          if (i>0) listaItems[i].separador(); // pinto una separaión
	      listaItems[i].pinta("listaItems["+i+"]"); // Pinto el elemento del menu
		  // Recorro los submenus y los pinto si es el indice que se envia
		  if (i==indice && listaItems[i].subMenu != null) 
		     for(j=0; j<listaItems[i].subMenu.length; j++) {
			    listaItems[i].subMenu[j].pinta("listaItems["+i+"].subMenu["+j+"]");
			    // Recorro los subsubmenus y los pinto si es el subIndice que se recibo
		        if (j==subIndice && listaItems[i].subMenu[j].subMenu != null) 
		           for(k=0; k<listaItems[i].subMenu[j].subMenu.length; k++) 
			          listaItems[i].subMenu[j].subMenu[k].pinta("listaItems["+i+"].subMenu["+j+"].subMenu["+k+"]");
			 }
      }
      if (!(listaImagenes === undefined))    // Si hay imagenes las pinto
         for (i=0; i<listaImagenes.length; i++) 
	         listaImagenes[i].pinta(); // Pinto el elemento del menu
      document.write("</table>");
   }

   
   // Pinta una barra de enlaces con imagenes rollover en la orientacion que se envia
   function MostrarEnlaces (nomListaElementos, orientacion) {
      var i;
	  var listaElementos = eval(nomListaElementos);
	  if (orientacion === undefined) orientacion = kHorizontal;
      if (orientacion == kHorizontal) document.write ("<TR>");	  
      for (i=0; i<listaElementos.length; i++) {
	     if (orientacion == kVertical) document.write ("<TR>");
		 document.write ("<TD>");
	     listaElementos[i].pinta(nomListaElementos + "["+i+"]");    // Pinto el elemento
		 document.write ("</TD>");
	     if (orientacion == kVertical) document.write ("</TR>");		 
	  }
      if (orientacion == kHorizontal) document.write ("</TR>");	  	  
   }
   

   // Devuelve la fecha de modificación
   function fechaModificacion() {
      // Para poner los meses en formato visual
	  var nommeses = new Array("", "ene", "feb", "mar", "abr", "may", "jun", "jul", "ago", "sep", "oct", "nov", "dic")				
	  // Obtenemos la fecha de modificación del documento
	  var mydate = new Date(document.lastModified);						
	  // Separamos el día, mes y año
	  var anyo = mydate.getFullYear();
      if (anyo < 1990) anyo += 100;
	  var dia  = mydate.getDay();
	  var mes  = mydate.getMonth() + 1;
	  var diam = mydate.getDate();
	  return(diam + "-" + nommeses[mes] + "-" + anyo);
   }

   // Muestra el pie de página	
  function Pie() {
	  document.write("<table BORDER=0 CELLSPACING=10 CELLPADDING=0 WIDTH=\"100%\" BGCOLOR=\"#FFFFFF\" summary=\"Pie de página\">");
      document.write("  <tr>");
      document.write("    <td ALIGN=LEFT COLSPAN=\"2\"><font face=\"Tahoma, Helvetica, Arial\" color=\"#003366\" size=-2>");
      document.write (prePieComun);
      document.write("       </font></td>");
      document.write("  </tr>");
      document.write("  <tr>");
      document.write("    <td ALIGN=LEFT VALIGN=CENTER COLSPAN=\"2\" BACKGROUND=\"" + inicioUrl + "/imagenes/menus/fondocolh.gif\" NOSAVE><img SRC=\"" + inicioUrl + "/imagenes/menus/punto.gif\" ALT=\"\" NOSAVE height=1 width=1></td>");
      document.write("  </tr>");
      document.write("  <tr>");
      document.write("    <td ALIGN=LEFT VALIGN=CENTER><font face=\"Tahoma, Helvetica, Arial\" color=\"#003366\" size=-2>Página mantenida por " + mantenidaPor + ". <br>Última actualización: " + fechaModificacion() + "</font></td>");
      document.write("    <td ALIGN=RIGHT VALIGN=CENTER><a href=\"" + inicioUrl + "/es/index.html\"><img SRC=\"" + inicioUrl + "/imagenes/casa.gif\" ALT=\"Universidad de Alicante\" TITLE=\"Universidad de Alicante\" HSPACE=4 VSPACE=2 NOSAVE BORDER=0 height=19 width=23></a><a href=\"mailto:" + mailMantenim + "\"><img SRC=\"" + inicioUrl + "/imagenes/correo.gif\" ALT=\"Enviar correo\" TITLE=\"Enviar correo\" VSPACE=2 NOSAVE BORDER=0 height=15 width=21></a></td>");
      document.write("  </tr>");
      document.write("</table>");
   }


