// Esta funcion es valida solo para el grupo de ficheros de contacto


function Validar(){
    var txt = "Error en los siguientes campos: \n\n";
	msg_f = txt.length;

if (document.ValidarAbono.nombre.value == "")
	{
	 document.ValidarAbono.nombre.style.backgroundColor = "#C3C3C3"
	 txt+="\tNombre\n";
	}

if (document.ValidarAbono.apellidos.value == "")
	{
	 document.ValidarAbono.apellidos.style.backgroundColor = "#C3C3C3"
	 txt+="\tApellidos\n";
	}

if (document.ValidarAbono.dni.value == "")
	{
	document.ValidarAbono.dni.style.backgroundColor = "#C3C3C3"
	 txt+="\tD.N.I\n";
	}

if (document.ValidarAbono.direccion.value == "")
	{
	document.ValidarAbono.direccion.style.backgroundColor = "#C3C3C3"
	 txt+="\tDirección\n";
	}
	
	
if (document.ValidarAbono.cp.value == "")
	{
	 document.ValidarAbono.cp.style.backgroundColor = "#C3C3C3"
	 txt+="\tCódigo Postal\n";
	}

if (document.ValidarAbono.localidad.value == "")
	{
	 document.ValidarAbono.localidad.style.backgroundColor = "#C3C3C3"
	 txt+="\tLocalidad\n";
	}


if (document.ValidarAbono.telefono.value == "")
	{
	 document.ValidarAbono.telefono.style.backgroundColor = "#C3C3C3"
	 txt+="\tTelefono\n";
	}
	
if ( TestMail(document.ValidarAbono.correo.value) == false )
	{
	 document.ValidarAbono.correo.style.backgroundColor = "#C3C3C3"
	 txt+="\tE-Mail\n";
	}
	
	
if (document.ValidarAbono.abono.selectedIndex == 0)
	{
	 document.ValidarAbono.abono.style.backgroundColor = "#C3C3C3"
	 txt+="\tTipo de Abono\n";
	}
	
if(document.ValidarAbono.aceptar_condiciones.checked == false )
	{
	document.ValidarAbono.aceptar_condiciones.style.backgroundColor = "#C3C3C3"
	txt+="\tAceptar Condiciones \n";
	}


if (msg_f != txt.length){
	alert(txt);
	return false;
	}else{
		return true;
	}
}




function TestMail(texto)
{
  var correcto=true;
  if ((texto.indexOf("@")<1) || (texto.indexOf("@")>8))
    { correcto=false; }
  if ( (texto.indexOf(".com")<0) &&  (texto.indexOf(".do")<0) && (texto.indexOf(".cu")<0) && (texto.indexOf(".cl")<0) && (texto.indexOf(".br")<0) && (texto.indexOf(".ch")<0) && (texto.indexOf(".pt")<0) && (texto.indexOf(".it")<0) && (texto.indexOf(".uk")<0) && (texto.indexOf(".mx")<0) && (texto.indexOf(".ar")<0) && (texto.indexOf(".de")<0) && (texto.indexOf(".fr")<0) && (texto.indexOf(".biz")<0) && (texto.indexOf(".info")<0) && (texto.indexOf(".net")<0) && (texto.indexOf(".es")<0)  && (texto.indexOf(".org")<0) &&  (texto.indexOf(".edu")<0) )
    { correcto=false; }
  
return correcto;
}

