function vacio(q) {
    for (i=0; i<q.length; i++){
        if (q.charAt(i) != " " ) {
           return false
        }
    }
    return true
}
 function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
     return true;
  else
   return false;

 }
 function checkPhone(str)
{
  var phone2 = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
  if (str.match(phone2)) {
     return true;
  } else {
     return false;
  }
}

function validanombre() {
        var F = document.forms['formreserva'];
        if( vacio(F.nombre.value) == true) {
                alert("Es obligatorio indicar un nombre para hacer una reserva");
                return false;
        }
        else return true;
}


function valida() {
        var F = document.forms['formreserva'];

        if( vacio(F.nombre.value) == true ||
            vacio(F.pax.value) == true ||
            vacio(F.telefono.value) == true ||
            vacio(F.email.value) == true ||
            vacio(F.fecha.value) == true) {
                alert("Rellene los campos obligatorios");
                return false;
        }
        if (vacio(F.pax.value) == false && isNaN(F.pax.value)){
                alert("El campo con el número de personas asistentes no contiene un número");
                return false;
        }
        if (vacio(F.email.value) == false && validarEmail(F.email.value) == false){
                alert("La dirección de email es incorrecta.");
                return false;
        }

/*        if (vacio(F.telefono.value) == false && checkPhone(F.telefono.value)== false){
		alert("Por favor indique un número de teléfono válido")
		return false;
        }
*/        return true
}

function mostrar(numCapa){
       for (i=1;i<7;i++){
           if (i==numCapa){
              document.getElementById('capa'+i).style.visibility="visible";
              document.getElementById('dia'+i).style.backgroundColor="Silver";
              document.getElementById('dia'+i).style.color="White";
           } else {
              document.getElementById('capa'+i).style.visibility="hidden";
              document.getElementById('dia'+i).style.backgroundColor="White";
              document.getElementById('dia'+i).style.color="DarkSlateGray";
           }
       }
}
function ocultar(nombreCapa){
document.getElementById(nombreCapa).style.visibility="hidden";
}

function abrir(pagina){
  ventana = window.open(pagina,'LayDown','toolbar=no,directories=no,menubar=no,status=no,scrollbars=yes,height=500,width=700');
  ventana.moveTo((screen.width-700)/2,(screen.height-500)/2);
}
