var encendida = '';
var encendida2 = '';
var encendida3;

function muestraMenu(o){
	
  if (o==1){IDCapa='menuQuienesSomos';}
  if (o==2){IDCapa='menuDondeEstamos';}
  if (o==3){IDCapa='menuProductos';}
  if (o==4){IDCapa='menuAplicaciones';}
  if (o==5){IDCapa='menuDocumentacion';}
  if (o==6){IDCapa='menuActualidad';}
  
  if(document.getElementById(IDCapa).style.display == 'none' || document.getElementById(IDCapa).style.display == ''){
    if(encendida != ''){
      document.getElementById(encendida).style.display = 'none';
      document.getElementById(IDCapa).style.display = 'inline';
      encendida = IDCapa;
    }else{
      encendida = IDCapa;
      document.getElementById(IDCapa).style.display = 'inline';
    }
  }else{
    encendida = '';
    document.getElementById(IDCapa).style.display = 'none';
  }
}

function mayusculea(str){
var aLetras = [];
var spc = 0;
str = str.split('');
for(var i=0;i<str.length;i++){
  if(str[i].indexOf(' ') == -1){
    if(spc == 0){
      aLetras[i] = str[i];
    } else {
	  aLetras[i] = str[i].toUpperCase();
	  spc = 0;
    }
  } else {
    spc = 1;
  }
     switch(aLetras[i]){
		 case 'á':
		   aLetras[i] = 'a';
		   break;
		 case 'Á':
		   aLetras[i] = 'A';
		   break;
		 case 'é':
		   aLetras[i] = 'e';
		   break;
		 case 'É':
		   aLetras[i] = 'E';
		   break;
		 case 'í':
		   aLetras[i] = 'i';
		   break;
		 case 'Í':
		   aLetras[i] = 'I';
		   break;
		 case 'ó':
		   aLetras[i] = 'o';
		   break;
		 case 'Ó':
		   aLetras[i] = 'O';
		   break;
		 case 'ú':
		   aLetras[i] = 'u';
		   break;
		 case 'Ú':
		   aLetras[i] = 'U';
		   break;
	  }
  }
return aLetras.join('');
}

function muestraMenu2(o){
	
  if (o==1){IDCapa='menuComposites';}
  if (o==2){IDCapa='menuLacados';}
  
  if(document.getElementById(IDCapa).style.display == 'none' || document.getElementById(IDCapa).style.display == ''){
    if(encendida2 != ''){
      document.getElementById(encendida2).style.display = 'none';
      document.getElementById(IDCapa).style.display = 'inline';
      o.className = 'selected';
      encendida3.className = '';
      encendida3 = o;
      encendida2 = IDCapa;
    }else{
      encendida2 = IDCapa;
      document.getElementById(IDCapa).style.display = 'inline';
      o.className = 'selected';
      encendida3 = o;
    }
  }else{
    encendida2 = '';
    document.getElementById(IDCapa).style.display = 'none';
    encendida3.className = '';
    encendida3 = '';
  }
}

function ventanea() {
	if(window.showModalDialog){
      window.open('polPriv.html', 'privacidad', 'width=435,height=470,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no');
	}else{
	  window.open('polPriv.html', 'privacidad', 'width=425,height=450,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no');
	}
}


function legal() {
	if(window.showModalDialog){
      window.open('legal.html', 'aviso', 'width=435,height=470,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no');
	}else{
	  window.open('legal.html', 'aviso', 'width=425,height=450,fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no');
	}
}


 //Comprueba tamanos de campos
  function longitud(parametro,nombre,largo)
   {
   cade=parametro
   if (cade.length>largo)
   errStr = errStr + nombre+" es demasiado largo.\r ";
   }
  
  function longitud_minima(parametro,nombre,largo)
   {
   cade=parametro
   if (cade.length<largo)
   errStr = errStr + nombre+" es demasiado corto.\r ";
   }
  
  function vacio(parametro,nombre)
   {
   nom=new String(parametro);
   if (nom=="")
   errStr = errStr + nombre+" esta vacio.\r ";
   }
  
  function vocal(parametro,nombre)
   {
   nom=new String(parametro);
   nom=nom.toLowerCase()
   if (nom.indexOf("a")<0 && nom.indexOf("e")<0 && nom.indexOf("i")<0 && nom.indexOf("o")<0 && nom.indexOf("u")<0)
   errStr = errStr + nombre+" es incorrecto.\r ";
   }
  
  function numerico(parametro,nombre)
   {
   comprobar=parametro;          
   if (isNaN(comprobar)==true)
    {
    errStr = errStr + nombre+" debe ser numerico. Si necesita utilizar decimales puede utilizar el punto como separador \r";
    }
   }
  
  function es_mail(texto,nombre)
	 {
     // Comprueba que el campo email es valido.
	 var cemail = texto;
	 resul1 = cemail.indexOf("@"); resul2 = cemail.lastIndexOf(".");
	 if (resul1 == -1 || resul2 == -1 || resul2 < resul1) 
	   { 
	   errStr = errStr + nombre+" es incorrecto.\r ";
	   }
    
    n=texto.indexOf("'");
    if (n>=0){errStr = errStr + nombre+" es incorrecto.\r ";}
    
	} 
   
   function quitar_comitas(parametro)
   {
   campo=parametro
   n=campo.indexOf("'");
   while (n>=0)
	 {
	 campo=campo.replace("'",'"');
	 n=campo.indexOf("'");
	 }
   return(campo);
   }

