function validarDatos() {
  var resultado=true;
  var errores="";
  
 // alert ('entra');
  
  	var valor = document.getElementById("correo_boletin").value;
  	
    if (!isMail(valor)) {
      errores=errores+"\n - La dirección de e-mail introducida no es válida.";
      resultado=false;    
    }    
 
  
  
  
  if(resultado==false) {
    errores="Se han encontrado errores en el procesamiento del formulario de registro.\nPor favor, revíselos y vuelva a enviarlo para poderlo procesar. \n" + errores;
    alert(errores);
  }
  
   return resultado;
  
}

function isMail(Cadena) {

  valido = true

  if (Cadena != "") {

    Punto = Cadena.substring(Cadena.lastIndexOf('.') + 1, Cadena.length)
    Dominio = Cadena.substring(Cadena.lastIndexOf('@') + 1, Cadena.lastIndexOf('.'))
    Usuario = Cadena.substring(0, Cadena.lastIndexOf('@'))
    Reserv = "@/º\"\'+*{}\\<>?¿[]áéíóú#·¡!^*;,:"

    for (var Cont=0; Cont<Usuario.length; Cont++) {
      X = Usuario.substring(Cont,Cont+1)
      if (Reserv.indexOf(X)!=-1)
          valido = false
    }
    
    for (var Cont=0; Cont<Punto.length; Cont++) {
      X=Punto.substring(Cont,Cont+1)
      if (Reserv.indexOf(X)!=-1)
        valido = false
    }
    
    for (var Cont=0; Cont<Dominio.length; Cont++) {
      X=Dominio.substring(Cont,Cont+1)
      if (Reserv.indexOf(X)!=-1)
        valido = false
    }
    
    if (Punto.length<2 || Dominio <1 || Cadena.lastIndexOf('.')<0 || Cadena.lastIndexOf('@')<0 || Usuario<1) {
      valido = false
    }
  }

  return valido
}

function suscribirse(){
//alert('entra');
//	alert (formboletin.correo_boletin.value);
    var correo = document.getElementById('correo_boletin').value;
  //  alert (correo);
	ponerDiv();
}



function tancaDiv()
{
    var obj = document.getElementById('contenidor_missatge');
    document.body.removeChild(obj);
    var obj = document.getElementById('tapador');
    document.body.removeChild(obj);
    //window.toolbars = 1;
}

function ponerDiv()
{
   // window.toolbars = 0;
    if (!document.getElementById("tapador"))
    {
        var ndiv = document.createElement('div');
        //ndiv.setAttribute('id','tapador');
        //ndiv.setAttribute('class','transparent');
        ndiv.id = 'tapador';
        //ndiv.style.height = '100%';
        ndiv.style.height = '1040';
        ndiv.style.width = '100%';
        
        
        //seria gran algo així
        //ndiv.style.height = document.body.height;
        //ndiv.style.width = document.body.width;
        
        
        ndiv.style.position = 'absolute';
        ndiv.style.top = '0';
        ndiv.style.left = '0';
        ndiv.style.backgroundColor = '#ffffff';
        
            ndiv.style.opacity = '0.6';
            ndiv.style.MozOpacity = '0.6';
            ndiv.style.filter = "alpha(opacity = 60";
            //ndiv.setAttribute('style','filters:alpha(opacity=60)');
        document.body.appendChild(ndiv);   
        //ndiv.className = 'transparent';
        //alert('hi és'); 
    }
   
    if (!document.getElementById("contenidor_missatge"))
    {
        var pdiv = document.createElement('div');
        pdiv.id = 'contenidor_missatge';
        pdiv.style.height = '100%';
        pdiv.style.width = '100%';
        pdiv.style.top = '0';
        pdiv.style.left = '0';
        pdiv.style.position = 'absolute';
        document.body.appendChild(pdiv);
    } 
        
        cridaiposa('plantillas/navidad.html','contenidor_missatge');
    
    
}
