// JavaScript Document
var gIdioma;
//precarga de imagenes VR
var aImgVR = $w("virtual_over_es.png virtual_en.png virtual_over_en.png");
aImgVR.each(function (v){var auxImg = new Image();auxImg.src="vr/img/" + v;});

function verPrecios(valor)
{
	var v = document.getElementsByClassName("dia");
	(v.length).times(function(n) {
		v[n].style.visibility = "hidden";
});

	
	var v = document.getElementsByClassName(valor);
	(v.length).times(function(n) {
		v[n].style.visibility = "visible";
});

	var v = document.getElementsByClassName("diaMarcado");
	(v.length).times(function(n) {
		v[n].style.visibility = "hidden";});
}

function ocultarPrecios(valor)
{
	var v = document.getElementsByClassName(valor);
	(v.length).times(function(n) {
		v[n].style.visibility = "hidden";
});

	
	var v = document.getElementsByClassName("dia");
	(v.length).times(function(n) {
		v[n].style.visibility = "visible";
});

	var v = document.getElementsByClassName("diaMarcado");
	(v.length).times(function(n) {
		v[n].style.visibility = "visible";});
}
/* ************************************************************************/
function f_ventaOnline()
{
	//if (oReserva == undefined)
	//{
		$("btnReserva").hide();
		$("imgBannerVR").hide();
		$("btnReservaOff").show();
		$("ocultaridiomas").show();
		visualizarCargando();
		oReserva = new cReserva(gMes,gAnho);
		var v = "<div id='caja'> </div>";
		new Insertion.Before("flash",v);
		new Ajax.Updater('caja','php/reservas.php',{evalScripts:true,onComplete:function(objeto) {
			ocultarCargando();
		}
		
		});
	//}
}


function prueba()
{
	alert ("funciï¿½n de prueba");
}

function validarEmail(campo)
{
	var email = $(campo).value;
	var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (email.length == 0 ) return true;
	if (filter.test(email))
		return true;
	else
		return false;
}

//Visualiza la capa cargando
function visualizarCargando()
{
	$("cargando").show();
}

function ocultarCargando()
{
	$("cargando").hide();
}

//abre la ventana de profesionales
function abrirProfesionales()
{
	 window.open("profesional/index.php","ventana1","Titlebar='CostaMar Profesionales',Resizable=yes,top=0,left=0");
	 
}


//Esta función se ejecuta al cambiar de idioma
function btnidioma(idioma, par, ind) //PUEDE SER EN-> INGLES, ES-> ESPAÃ‘OL, AL-> ALEMAN //PAR: 1-> Onmouseover 2-> Onmouseout  //IND: Â¿QuÃ© imagen es?
{
	if (idioma != '')
	{
		gIdioma = idioma;
		idiomaVR(false);
	}	
	if (idioma =='es') {
		document.getElementById('img_reservas').src='img/reservas/spanish_anim.gif';
		document.getElementById('img_reservasOff').src='img/reservas/spanish_anim_act.gif';	
		document.getElementById('img_profesionales').src='img/professionals_button.gif';								
	}
	if (idioma =='en') {
		document.getElementById('img_reservas').src='img/reservas/english_anim.gif';
		document.getElementById('img_reservasOff').src='img/reservas/english_anim_act.gif';	
		document.getElementById('img_profesionales').src='img/professionals_button_en.gif';															
	}
	if (idioma =='al') {
		document.getElementById('img_reservas').src='img/reservas/german_anim.gif';	
		document.getElementById('img_reservasOff').src='img/reservas/german_anim_act.gif';						
		document.getElementById('img_profesionales').src='img/professionals_button_al.gif';									
	}
	
	
	if (idioma == '')
	{
		a=document.getElementById('img_profesionales').src; //Ruta completa de un archivo
		b=a.match(/[\/|\\]([^\\\/]+)$/);
		var img=b[1];
	
		/*IMAGEN PROFESIONALES*/
		if (par ==1 && ind ==1) 
		{
			if (img=='professionals_button.gif')
				document.getElementById('img_profesionales').src="img/professionals_button_over.gif";					
			if (img=='professionals_button_en.gif')
				document.getElementById('img_profesionales').src="img/professionals_button_en_over.gif";
			if (img=='professionals_button_al.gif')
				document.getElementById('img_profesionales').src="img/professionals_button_al_over.gif";
		}
		if (par ==2 && ind ==1) 
		{							
			if (img=='professionals_button_over.gif')
				document.getElementById('img_profesionales').src="img/professionals_button.gif";
			if (img=='professionals_button_en_over.gif')
				document.getElementById('img_profesionales').src="img/professionals_button_en.gif";
			if (img=='professionals_button_al_over.gif')
				document.getElementById('img_profesionales').src="img/professionals_button_al.gif";
		}
		
		a=document.getElementById('img_reservas').src; //Ruta completa de un archivo
		b=a.match(/[\/|\\]([^\\\/]+)$/);
		var img=b[1];					
		
		/*IMAGEN RESERVAS*/
		if (par ==1 && ind ==2) 
		{
			if (img=='spanish_anim.gif')
				document.getElementById('img_reservas').src="img/reservas/spanish_over.gif";					
			if (img=='english_anim.gif')
				document.getElementById('img_reservas').src="img/reservas/english_over.gif";
			if (img=='german_anim.gif')
				document.getElementById('img_reservas').src="img/reservas/german_over.gif";
		}
		if (par ==2 && ind ==2) 
		{							
			if (img=='spanish_over.gif')
				document.getElementById('img_reservas').src="img/reservas/spanish_anim.gif";
			if (img=='english_over.gif')
				document.getElementById('img_reservas').src="img/reservas/english_anim.gif";
			if (img=='german_over.gif')
				document.getElementById('img_reservas').src="img/reservas/german_anim.gif";
		}					
		
	}					
	
}

//Esta funciÃ³n se ejecuta al caducar la session
function sessionCaducada()
{
	//Eliminamos la capa caja
	if ($("caja") != null )
		$("caja").remove();
	//Eliminamos la capa "cajaDatos" sÃ­ existe
	if ($("cajaDatos") != null)
		$("cajaDatos").remove();
	
	//Activamos el botÃ³n reserva
	$('btnReservaOff').hide();
	$("btnReserva").show();
	
	//refrescamos la pÃ¡gina
	location.href="http://www.lanzarote-costamar.com/";
}

//cambiar el botón VR al idiom especificado
//Valor: True hace referencia a la imagen over y false al contrario
function idiomaVR (valor)
{
	var idioma = '';
	(gIdioma == "al")? idioma = "en":idioma=gIdioma;
	if (idioma == '')
		idioma = "es"
				
	if (valor)
		$("imgBannerVR").src="vr/img/virtual_over_" + idioma + ".png";
	else
		$("imgBannerVR").src="vr/img/virtual_" + idioma + ".png";
}

//Cerrar la ventana de reserva
function cerrarReserva()
{
	oReserva.finalizar();
	$('ocultaridiomas').hide(); 
	$('btnReservaOff').hide();	
	$('btnReserva').show();
	$("imgBannerVR").show();	
}