// JavaScript Document

	
//ESCRIBE EL FLASH PARA QUE SE PUEDA VALIDAR EL HTML
function docwrite() {
document.write('<object type="application/x-shockwave-flash" data="flash/container.swf?path=flash/cabecera.swf" width="760" height="120">');
document.write('<param name="movie" value="flash/container.swf?path=flash/cabecera.swf">');
document.write('<param name="quality" value="high">');
document.write('<param name="wmode" value="transparent">');
document.write('</object>');
}

//FUNCIONES PARA VALIDAR FORMULARIOS DE RESERVA, AMIGO, SUSCRIBIR
function validaSubscripcion() 
{
var ok=1;
if (document.suscribir.nombre.value=='') {ok=0; alert("El nombre es un campo obligatorio");}
if (document.suscribir.apellidos.value=='') {ok=0; alert("El apellido es un campo obligatorio");}
if (mail(document.suscribir.email)==1){} else {ok=0; alert("El e-mail que has introducido no es valido");}
if (ok==0)
	{alert("Debe rellenar correctamente el Formulario");}
else
	{document.suscribir.submit();}
}

function validaRecomienda() 
{
var ok=1;
if (document.recomienda.nombre.value=='') {ok=0; alert("El nombre es un campo obligatorio");}
if (mail(document.recomienda.email)==1){} else {ok=0; alert("El e-mail que has introducido no es valido");}
if (document.recomienda.tuNombre.value=='') {ok=0; alert("Tu nombre es un campo obligatorio");}
if (mail(document.recomienda.tuEmail)==1){} else {ok=0; alert("El e-mail que has introducido no es valido");}
if (ok==0)
	{alert("Debe rellenar correctamente el Formulario");}
else
	{document.recomienda.submit();}
}


function validaReserva() 
{
var ok=1;
var myString=document.reserva.cantidad.value;
if (document.reserva.nombreR.value=='') {ok=0; alert("El nombre es un campo obligatorio");}
if (document.reserva.apellidosR.value=='') {ok=0; alert("El apellido es un campo obligatorio");}
if (isNaN(parseFloat(myString))) {ok=0; alert("Escriba sólo números en el vampo de 'Número de pases'");}
if (document.reserva.cantidad.value=='' || document.reserva.cantidad.value > 8) {ok=0; alert("Se admiten reservas de máximo 8 personas, si quiere apartar una cantidad mayor realice su reserva por telefono");}
if (mail(document.reserva.emailR) ==1){} else {ok=0; alert("El e-mail que has introducido no es valido");}
if (ok==0)
	{alert("Debe rellenar correctamente el Formulario");}
else
	{document.reserva.submit();}
}

function mail(mail)
	{
		var cont,ind1,ind2,ind3,ind4;
		mail = mail.value;
		cont=mail.length;
		ind1=mail.indexOf('@');
		ind2=mail.indexOf('.');
		ind3=mail.lastIndexOf('@');
		ind4=mail.lastIndexOf('.');
       	if ((ind1<=0)||(ind3>ind4)||(ind3!=ind1)||(ind4+2>cont)||(ind4+5<cont)||(ind3==ind4-1))
		{
			return 0;
		}else{
			return 1;
		}
	}


//FUNCION DE LA GALERIA
function muestraFoto(queFoto) {
	var foto = queFoto.getAttribute("href");
	var contenedor = document.getElementById("contenedor");
	contenedor.setAttribute("src", foto);
}



//PRECARGAR IMAGENES DE LOS BONOS PARA ROLLOVER (NO SE SI FUNCIONA)
function preloadImages() {
  img1 = new Image;
  img1.src='images/elBogui_btn_RO.gif';
  img2 = new Image;
  img2.src='images/program_btn_RO';
  img3 = new Image;
  img3.src='images/notic_btn_RO.gif';
  img4 = new Image;
  img4.src='images/gal_btn_RO.gif';
  img5 = new Image;
  img5.src='images/reserv_btn_RO.gif';
  img6 = new Image;
  img6.src='images/contact_btn_RO.gif';
  img7 = new Image;
  img7.src='images/PF_btn_RO.gif';
  img8 = new Image;
  img8.src='images/pdfDownload_btn_RO.gif';
}
