function ChangeUrlGrupo(formulaire)
	{
	if (formulaire.ListeGrupo.selectedIndex != 0)
		{
		location.href = formulaire.ListeGrupo.options[formulaire.ListeGrupo.selectedIndex].value;
	 	}
	
	}

	function ChangeUrlRol(formulaire)
	{
	if (formulaire.ListeRol.selectedIndex != 0)
		{
		location.href = formulaire.ListeRol.options[formulaire.ListeRol.selectedIndex].value;
	 	}
	
	}

	function ChangeUrlModulo(formulaire)
	{
	if (formulaire.ListeModulo.selectedIndex != 0)
		{
		location.href = formulaire.ListeModulo.options[formulaire.ListeModulo.selectedIndex].value;
	 	}
	
	}

     /*   function rolElegido(indice)
        {

	if (document.getElementById('nombre').selectedIndex != 0)
		{

                 variable = document.getElementById('nombre').value;
                 if(indice == 1){
                   window.location="anadirRolGrupo.htm?idGrupo=${model.idGrupo}&nombre="+variable;
                 }
	  }
	
        }*/

        function cambiaUrlPreguntando(url, pregunta)
	{
          
          var confirm = window.confirm(pregunta);
  	  if(confirm){
            window.location=url;
            return;
          } else {
            return;
          }

	}

        function mensaje(){
           alert("No puede eliminar un rol padre");
           window.location="listadoRoles.htm";
        }


        function ChangeUrlUnidadOrg(formulaire, idTipo)
	{

        unidadOrg = "unidadOrg"+idTipo;

	if (document.getElementById(unidadOrg).selectedIndex != 0)
		{
		location.href = document.getElementById(unidadOrg).options[document.getElementById(unidadOrg).selectedIndex].value;
	 	}
         else{
           idTipo = idTipo-1;
          unidadOrg = "unidadOrg"+idTipo;
          location.href = document.getElementById(unidadOrg).options[document.getElementById(unidadOrg).selectedIndex].value;  
         }
	
	}

        function ChangeUrlGuardaMail(pregunta)
        {
	  var confirm = window.confirm(pregunta);
  	  if(confirm){
             host = document.getElementById('host').value;
	     port = document.getElementById('port').value;
             auth = document.getElementById('auth').value;
             if(document.getElementById('auth').checked){
                auth=true;
             }
             else{
               auth=false;
             }
             user = document.getElementById('user').value;
             password = document.getElementById('password').value;
             destinatario =  document.getElementById('destinatario').value;
 
             window.location="guardarParametrosMail.htm?host="+host+"&port="+port+"&auth="+auth+"&user="+user+"&password="+password+"&destinatario="+destinatario;
                 
	  }
	
        }


     function ChangeUrlGuardaDias(pregunta)
        {
	   var confirm = window.confirm(pregunta);
  	  if(confirm){
                 fecha = document.getElementById('festivo').value;
                 motivo = document.getElementById('motivo').value;

                 window.location="guardarDiasVacaciones.htm?fecha="+fecha+"&motivo="+motivo;
                 
	  }
	
        }

     function ChangeUrlGuardarFechasEncuesta(pregunta, edit, idComunidad)
        {
	   var confirm = window.confirm(pregunta);
  	   if(confirm){
                 voteOpenString = document.getElementById('voteOpenString').value;
                 voteCloseString = document.getElementById('voteCloseString').value;
                 titular = document.getElementById('text').value;
//alert("FechaEncuesta " + voteCloseString);
                 window.location="guardarFechasEncuesta.htm?titular="+titular+"&fechaInicio="+voteOpenString+"&fechaFin="+voteCloseString+"&edit="+edit+"&idComunidad="+idComunidad;
                 
	   }
	
        }

     function ChangeUrlGuardarFechasEncuestaAbierta(pregunta, edit, idComunidad)
        {
	   var confirm = window.confirm(pregunta);
  	   if(confirm){
                 voteOpenString = document.getElementById('voteOpenString').value;
                 voteCloseString = document.getElementById('voteCloseString').value;
                 titular = document.getElementById('text').value;
//alert("FechaEncuestaAbierta " + voteCloseString);

                 window.location="guardarFechasEncuesta.htm?titular="+titular+"&fechaInicio="+voteOpenString+"&fechaFin="+voteCloseString+"&edit="+edit+"&idComunidad="+idComunidad+"&abierta=si";
                 
	   }
	
        }
 

     function ChangeUrlEditaVacaciones(pregunta, clave){
        var confirm = window.confirm(pregunta);
  	  if(confirm){
	     fecha = document.getElementById('fecha').value;
             motivo = document.getElementById('motivo').value;
               
             window.location="guardarEditarVacaciones.htm?clave="+clave+"&fecha="+fecha+"&motivo="+motivo;
                 
	  }
     }

    function ChangeUrlGuardaBuzon(pregunta, id){
        var confirm = window.confirm(pregunta);
  	  if(confirm){
             window.location="confirmarAnadirBuzonWorkflow.htm?idModulo=${model.idModulo}&idUsuario="+id;
                 
	  }
    }

    function ChangeUrlBuscaUsuario(id){
        window.location="verUsuarioDirectorio.htm?idUsuario="+id+"&urlCms=directorio";
                 
    }

/*function ChangeUrlBusquedaAvanzada(){
//        var confirm = window.confirm(pregunta);
  	  if(confirm){

	     nombre = encode_utf8(document.getElementById('nombre').value);
             apellidos= encode_utf8(document.getElementById('apellidos').value);
             unidad= encode_utf8(document.getElementById('unidad').value);
             if((nombre == '') && (apellidos == '') && (unidad == '')){
                alert("Debe introducir algun valor en los criterios de b�squeda");
	     } else{ 
             window.location="realizarBusquedaDirectorio.htm?nombre="+nombre+"&apellidos="+apellidos+"&unidad="+unidad;
             }  
                 
	  }
     }*/

/*function encode_utf8( s )
{

var sencode = encodeURIComponent( s );
//var unes = unescape(sencode);
//alert("encode:  " + sencode + "\n unes: " + unes);
var unes = unescape(s);
alert("unes " + unes);
 // return unes;
return sencode;
}*/


/*function ChangeUrlBusquedaAvanzadaUsuario(){
//        var confirm = window.confirm(pregunta);
  	  if(confirm){
	     nombre = document.getElementById('nombre').value;
             apellidos= document.getElementById('apellidos').value;
             unidad= document.getElementById('unidad').value;
             if((nombre == '') && (apellidos == '') && (unidad == '')){
                alert("Debe introducir algun valor en los criterios de b�squeda");
	     } else{ 
             window.location="realizarBusquedaUsuario.htm?nombre="+nombre+"&apellidos="+apellidos+"&unidad="+unidad;
             }  
                 
	  }
     }*/

     function permisoElegido(indice)
        {

	if (document.getElementById('nombre').selectedIndex != 0)
		{

                 variable = document.getElementById('nombre').value;
                 if(indice == 1){
                   window.location="confirmarAnadirPermiso.htm?idRol=${model.idRol}&nombre="+variable;
                 }
	  }
	
        }

        function ChangeUrlComunidadForo()
        {

	if (document.getElementById('comunid').selectedIndex != 0)
		{

                 variable = document.getElementById('comunid').value;

                   window.location="nuevoForo.htm?idComunidad="+variable+"&vuelta=si";
                 
	 }
	
        }




        function ChangeUrlComunidadTablon()
        {

	if (document.getElementById('comunid').selectedIndex != 0)
		{

                 variable = document.getElementById('comunid').value;

                   window.location="nuevoTablon.htm?idComunidad="+variable+"&vuelta=si";
                 
	 }
	
        }


        function ChangeUrlComunidadBlog()
        {

	if (document.getElementById('comunid').selectedIndex != 0)
		{

                 variable = document.getElementById('comunid').value;

                   window.location="nuevoBlog.htm?idComunidad="+variable+"&vuelta=si";
                 
	 }
	
        }


         function ChangeUrlComunidadEncuesta()
        {

	if (document.getElementById('comunid').selectedIndex != 0)
		{

                 variable = document.getElementById('comunid').value;

                   window.location="addUpdatePoll.htm?idComunidad="+variable+"&vuelta=si";
                 
	 }
	
        }
        
        
       
      function getCookie(name) 
      {
	
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
	  begin = dc.indexOf(prefix);
	  if (begin != 0) return null;
	} else {
	  begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
	  end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
	
      }
	
  


     function GuardarCookie (nombre, valor, nombre2, valor2, caducidad) 
     {

	if(!caducidad)
		caducidad = Caduca(0)

	//crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
	//cada valor esta separado por ; y un espacio
	document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad + "; path=/"
	document.cookie = nombre2 + "=" + escape(valor2) + "; expires=" + caducidad + "; path=/"

   }
   
   function Caduca(dias) 
   {
	
	var hoy = new Date()					//coge la fecha actual
	var msEnXDias = eval(dias) * 24 * 60 * 60 * 1000	//pasa los dias a mseg.

	hoy.setTime(hoy.getTime() + msEnXDias)			//fecha de caducidad: actual + caducidad
	return (hoy.toGMTString())
   }

   function BorrarCookie(nombre) 
   {

	//para borrar la cookie, se le pone una fecha del pasado mediante Caduca(-1)
	document.cookie = nombre + "=; expires=" + Caduca(-1) + "; path=/"

 
  }
  
  function ComprobarCookie(nombre, valor, nombre2, valor2, vuelta, urlCms, idComunidad, servlet)
  {
  variable="";
  if(servlet != null){
    variable=servlet;
  }
  	if(getCookie(nombre) == valor && getCookie(nombre2) == valor2){
	   alert("Ya ha votado una vez, no puede votar más");
	   return false;
//	   window.location="viewResult.htm?viewResult="+valor2+"&urlCms="+urlCms+"&idComunidad="+idComunidad+"&return="+vuelta;
	}
	else{
	  GuardarCookie (nombre, valor, nombre2, valor2, Caduca(1));
	  document.formulario.action= variable+"votePoll.htm?view=" + valor2 + "&return="+ vuelta+"&urlCms="+urlCms+"&idComunidad="+idComunidad;
	  document.formulario.submit();
//	  window.location="votePoll.htm?view=" + valor2 + "&return="+ vuelta+"&urlCms="+urlCms+"&idComunidad="+idComunidad;
	}
   }

 function limpiar(){
  document.formulario.nombre.value="";
  document.formulario.apellidos.value="";
  document.formulario.usuario.value="";
  document.formulario.password.value="";
  document.formulario.contraseña.value="";
  document.formulario.email.value="";
         

}

 function compruebaTamanio(campo,tamanio)
	{
		if (tamanio==null)
			tamanio=254;
			
		if(campo.value.length > tamanio)
                {
                   alert('Has superado el tamaño máximo permitido en este campo');
                   campo.value=campo.value.substr(0,tamanio);
                   return false;
                }
	}


   

