/**
* FUNCIONES JAVASCRIPT SALA DE PRENSA MAPFRE
*	Fecha:17/06/2004
*
*/


//Validar el email
function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    //alert("La dirección de email " + valor + " es correcta.") 
    return (true)
  } else {
    alert("La dirección de email es incorrecta debe tener el formato [nombre@dominio.extension] .");
    return (false);
  }
}


//Validar el Nif
function validaNIF(pNIF){
				   var cLetra
				   var cNumero
				   var cPatron
				   var aPatron
				   try{
				      // Separamos el nÃºmero y lo validamos
				      cNumero = pNIF.substr(0,pNIF.length -1)
				      if (isNaN(cNumero)) return false;
				      cPatron = /["."]/
				      aPatron = cPatron.exec(cNumero)
				      if (aPatron != null) return false;
				
				      // Separamos la letra y la validamos
				      cLetra = pNIF.toUpperCase().substr(pNIF.length -1,1)
				      if (!isNaN(cLetra)) return false;
				
				      // Comprueba que la letra se corresponde con el nÃºmero
				      cPatron = new String("TRWAGMYFPDXBNJZSQVHLCKE")
				      if (cLetra != cPatron.substr( (parseInt(cNumero,10) % 23), 1)) return false;
				
				   }catch(e){
				      return false;
				   }
				   return true;
				}
