// Esta funcion valida solo para el grupo de ficheros de Reservas del Hotel San Carlos :)

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

if (document.ValidarReserva.nombre.value == "")
	{
	 document.ValidarReserva.nombre.style.backgroundColor = "#F4F4F4"
	 txt+="\tNombre\n";
	}
	
if (document.ValidarReserva.apellidos.value == "")
	{
	document.ValidarReserva.apellidos.style.backgroundColor = "#F4F4F4"
	 txt+="\tApellidos\n";
	}

if (document.ValidarReserva.dni.value == "")
	{
	 document.ValidarReserva.dni.style.backgroundColor = "#F4F4F4"
	 txt+="\tD.N.I.\n";
	}
	
	
if (document.ValidarReserva.direccion.value == "")
	{
	document.ValidarReserva.direccion.style.backgroundColor = "#F4F4F4"
	 txt+="\tDirección\n";
	}

	
if (document.ValidarReserva.cp.value == "")
	{
	document.ValidarReserva.cp.style.backgroundColor = "#F4F4F4"
	 txt+="\tCódigo Postal\n";
	}

if (document.ValidarReserva.poblacion.value == "")
	{
	 document.ValidarReserva.poblacion.style.backgroundColor = "#F4F4F4"
	 txt+="\tPoblación\n";
	}
	
if (document.ValidarReserva.provincia.value == "")
 	{
    document.ValidarReserva.provincia.style.backgroundColor = "#F4F4F4"
	 txt+="\tProvincia\n";
	}
	
if (document.ValidarReserva.pais.value == "")
	{
	document.ValidarReserva.pais.style.backgroundColor = "#F4F4F4"
	 txt+="\tPais\n";
	}

if (document.ValidarReserva.telefono.value == "")
	{
	 document.ValidarReserva.telefono.style.backgroundColor = "#F4F4F4"
	 txt+="\tTeléfono\n";
	}
	
if ( TestMail(document.ValidarReserva.correo.value) == false )
	{
	 document.ValidarReserva.correo.style.backgroundColor = "#F4F4F4"
	 txt+="\tE-Mail\n";
	}


if (document.ValidarReserva.diallegada.selectedIndex == 0)
	{
 	 document.ValidarReserva.diallegada.style.backgroundColor = "#F4F4F4"
	 txt+="\tDía de Entrada\n";
	}

if (document.ValidarReserva.mesllegada.selectedIndex == 0)
	{
	document.ValidarReserva.mesllegada.style.backgroundColor = "#F4F4F4"
	txt+="\tMes de Entrada\n";
	}

if (document.ValidarReserva.diasalida.selectedIndex == 0)
	{
	document.ValidarReserva.diasalida.style.backgroundColor = "#F4F4F4"
	 txt+="\tDia de la salida\n";
	}

if (document.ValidarReserva.messalida.selectedIndex == 0)
	{
	document.ValidarReserva.messalida.style.backgroundColor = "#F4F4F4"
	 txt+="\tMes de salida\n";
	}

if (document.ValidarReserva.Numerodepersonas.value == "")
	{
	 document.ValidarReserva.Numerodepersonas.style.backgroundColor = "#F4F4F4"
	 txt+="\tNúmero de personas\n";
	}
	
	
if (document.ValidarReserva.HabIndividuales.selectedIndex == 0)
	{
	document.ValidarReserva.HabIndividuales.style.backgroundColor = "#F4F4F4"
	 txt+="\tNúmero de Hab. Individuales\n";
	}

if (document.ValidarReserva.HabDobles.selectedIndex == 0)
	{
	document.ValidarReserva.HabDobles.style.backgroundColor = "#F4F4F4"
	 txt+="\tNúmero de Hab. Dobles\n";
	}
	
if (document.ValidarReserva.JuniorSuite.selectedIndex == 0)
	{
	document.ValidarReserva.JuniorSuite.style.backgroundColor = "#F4F4F4"
	 txt+="\tNúmero de Hab. Junior Suite\n";
	}

		
if (document.ValidarReserva.RegimenEstancia.selectedIndex == 0)
	{
	document.ValidarReserva.RegimenEstancia.style.backgroundColor = "#F4F4F4"
	 txt+="\tRegimen de la Estancia\n";
	}

if(document.ValidarReserva.aceptar_condiciones.checked == false )
	{
	document.ValidarReserva.aceptar_condiciones.style.backgroundColor = "#F4F4F4"
	txt+="\tAceptar Condiciones de Uso\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("@")>20))
    { 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;
}

