var img = new Image();
img.src = 'img/ajax-loader_clock.gif';

var precio_total;


function crearObjeto()
{
	var ro;
	var browser = navigator.appName;
	if(browser == 'Microsoft Internet Explorer')
{
	ro = new ActiveXObject('Microsoft.XMLHTTP');	
}
else
{
	ro = new XMLHttpRequest();	
}
return ro;
}
var http;
var http_1;
function llamadaAjax(url,arg,func)
{
	http = crearObjeto();
	http.open('get',url+'&'+arg,true);
	eval("http.onreadystatechange = "+func+";");
	try { http.send(null); } catch(e) { alert('Se ha producido un error. Debe actualizar la página'); }
}	

function navegacion(seccion)
{

document.getElementById('mini_habitaciones_sombra').style.display = 'inline';
document.getElementById('mini_hotel_sombra').style.display = 'inline';
document.getElementById('mini_salones_sombra').style.display = 'inline';
document.getElementById('mini_cafeteria_sombra').style.display = 'inline';
document.getElementById('mini_servicios_sombra').style.display = 'inline';

document.getElementById('mini_habitaciones').style.display = 'none';
document.getElementById('mini_hotel').style.display = 'none';
document.getElementById('mini_salones').style.display = 'none';
document.getElementById('mini_cafeteria').style.display = 'none';
document.getElementById('mini_servicios').style.display = 'none';

document.getElementById('mini_'+seccion+'_sombra').style.display = 'none';
document.getElementById('mini_'+seccion).style.display = 'inline';
	
}

function comprueba_galeria(identificador,idioma)
{	
	//$('ubicacion').innerHTML ='<span>Usted está viendo la Categoría: </span><span style="color:#790808"><strong>'+identificador+'</strong></span><span><br /><br /><?= GALERY_TEXTO_CONTENEDOR_DERECHA_7; ?> </span>';
	document.getElementById('ubicacion').style.display = 'none';
	document.getElementById('ubicacion2').style.display = 'inline';
	$('galeria_dinamica').innerHTML = '<br /><div id="special_offer">Cargando imágenes <img src="img/ajax-loader_clock.gif" style="margin-left:30px" /></div>';
	navegacion(identificador);
	llamadaAjax('galeria_respuesta.php?lang='+idioma,'id='+identificador,'pintar_imagenes');
	
}

function pintar_imagenes()
{
	if(http.readyState == 4)
	{	
		$('galeria_dinamica').innerHTML ='';
		 new Insertion.Top('galeria_dinamica',http.responseText);			 
		/*$('galeria_dinamica').innerHTML = http.responseText;*/			
			
			Effect.BlindDown('galeria_dinamica');
			setTimeout("addReflections()",5000);
	}
}

function salamanca_index()
{
Effect.Appear('contenedor_features_sal');
document.getElementById('contenedor_features_pro').style.display = 'none';
document.getElementById('historia_salamanca').style.display = 'none';
document.getElementById('historia_provincia').style.display = 'none';
document.getElementById('fotos_salamanca_general').style.display = 'none';
document.getElementById('fotos_provincia_general').style.display = 'none';
}
function provincia_index()
{
Effect.Appear('contenedor_features_pro');
document.getElementById('contenedor_features_sal').style.display = 'none';
document.getElementById('historia_salamanca').style.display = 'none';
document.getElementById('historia_provincia').style.display = 'none';
document.getElementById('fotos_salamanca_general').style.display = 'none';
document.getElementById('fotos_provincia_general').style.display = 'none';
}

function historia_salamanca()
{
Effect.Appear('historia_salamanca');
document.getElementById('contenedor_features_pro').style.display = 'none';
document.getElementById('historia_provincia').style.display = 'none';
document.getElementById('fotos_salamanca_general').style.display = 'none';
document.getElementById('fotos_provincia_general').style.display = 'none';	
}
function fotos_salamanca()
{
Effect.Appear('fotos_salamanca_general');
document.getElementById('contenedor_features_pro').style.display = 'none';
document.getElementById('historia_provincia').style.display = 'none';
document.getElementById('historia_salamanca').style.display = 'none';
document.getElementById('fotos_provincia_general').style.display = 'none';	
}
function historia_provincia()
{
Effect.Appear('historia_provincia');
document.getElementById('contenedor_features_pro').style.display = 'inline';
document.getElementById('historia_salamanca').style.display = 'none';
document.getElementById('fotos_salamanca_general').style.display = 'none';
document.getElementById('fotos_provincia_general').style.display = 'none';		
}
function fotos_provincia()
{
Effect.Appear('fotos_provincia_general');
document.getElementById('contenedor_features_pro').style.display = 'inline';
document.getElementById('historia_provincia').style.display = 'none';
document.getElementById('historia_salamanca').style.display = 'none';
document.getElementById('fotos_salamanca_general').style.display = 'none';	
}

function lupa_mas ()
{
document.getElementById('lupa_mas').style.display = 'none';
document.getElementById('lupa_menos').style.display = 'inline';	
Effect.SlideDown('lista_esp');	
}
function lupa_menos ()
{
document.getElementById('lupa_mas').style.display = 'inline';
document.getElementById('lupa_menos').style.display = 'none';	
Effect.SlideUp('lista_esp');	
}

function campos(campo) {
        campo.style.backgroundColor = "#DFF7FF";
        if (campo.value == '') {
            alert("Debes rellenar todos los campos con más de 3 caracteres");
            campo.style.backgroundColor = "#FFBFBF"; 
            campo.focus();
            return false;
        }
        return true;
    }
    
		
	function checkemail() {
		mail = document.form_amigo.email_destino;
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail.value)) {
		 	return true;
		 } else {
			alert("Email incorrecto // Invalid email.");
			mail.focus();
			return false;
		 }
	}
		function checkemail2() {
		mail2 = document.form_amigo.email_u;
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail2.value)) {
		 	return true;
		 } else {
			alert("Email incorrecto // Invalid email.");
			mail2.focus();
			return false;
		 }
	}
		function checkemail3() {
		email = document.register_no.email;
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value)) {
		 	return true;
		 } else {
			alert("Email incorrecto // Invalid email.");
			email.focus();
			return false;
		 }
	}
		function checkemail4() {
		email = document.current_reserva.form_email_cliente;
		 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value)) {
		 	return true;
		 } else {
			alert("Email incorrecto // Invalid email.");
            email.style.backgroundColor = "#FFBFBF";  
			email.focus();
			return false;
		 }
	}
		function check_numerohabitaciones() {
		var indice_1 = document.current_reserva.habitaciones_simples.selectedIndex;
  	var indice_2 = document.current_reserva.habitaciones_dobles.selectedIndex;
   	if ((indice_1 ==0)&&(indice_2==0))
   	{
   		alert("Debe seleccionar un tipo de habitacion con un precio");
		//document.current_reserva.habitaciones_simples.style.backgroundColor = "#FFBFBF";
        document.current_reserva.habitaciones_simples.focus(); 
        return false;
		}else{
		//			document.current_reserva.habitaciones_simples.style.backgroundColor = "#FFBFBF"; 
                    return true;
					} 
		}
	

	function comprobar_registro()
	{
		if (campos(document.form_amigo.nombre_destino) && campos(document.form_amigo.nombre_user) 
			&& campos(document.form_amigo.email_destino) && campos(document.form_amigo.email_u) 
			&& checkemail() && checkemail2()) 
		document.form_amigo.submit();
	}

function comprobar_registro_contacta()
	{
		if (campos(document.register_no.nombre) && campos(document.register_no.email) 
			&& campos(document.register_no.phone) && campos(document.register_no.consulta) && campos(document.register_no.recaptcha_response_field)
			&& checkemail3()) 
		document.register_no.submit();
	}
	
	function comprobar_registro_reserva()
	{  
		if (campos(document.current_reserva.form_nombre_cliente) 
		&& campos(document.current_reserva.form_apellidos_cliente) 
		&& campos(document.current_reserva.form_email_cliente) 
		&& campos(document.current_reserva.form_telefono_cliente) 
		&& campos(document.current_reserva.form_direccion_cliente) 
		&& campos(document.current_reserva.form_codigopostal_cliente) 
		&& campos(document.current_reserva.form_provincia_cliente) 
		&& campos(document.current_reserva.form_apellidos_cliente) 
		&& check_numerohabitaciones()	
		&& checkemail4()) 
		document.current_reserva.submit();
	}

function aparece_form(capa_valor)
{
//document.getElementById('contenedoraimagenes_'+capa_valor).style.display = 'none';		
Effect.BlindDown('capa_comment_'+capa_valor);	
}

function oculta_comentario(capa_valor)
{
//document.getElementById('contenedoraimagenes_'+capa_valor).style.display = 'none';		
Effect.Squish('capa_comment_'+capa_valor);	
}

	function envio_video_form()
{
//document.getElementById('contenedoraimagenes_'+capa_valor).style.display = 'none';		
Effect.SlideDown('formulario_video');	
}

function oculta_envio_video_form()
{	
Effect.SwitchOff('formulario_video');	
}

//--------------------------- FUNCIONES PARA LA RESERVA

function comprueba_reserva(checking,checkout)
{	
	//alert(checking);
	$('formulario_reserva').innerHTML ='<br /><div id="special_offer">Buscando Disponibilidad, Espere por Favor...<img src="img/ajax-loader_clock.gif" style="margin-left:30px" /></div>';;
	//document.getElementById('ubicacion').style.display = 'none';
	llamadaAjax('comprueba_reserva.php?checking_fecha='+checking,'checkout_fecha='+checkout,'results_fechas');
	
}

function results_fechas()
{
	if(http.readyState == 4)
	{	
		$('formulario_reserva').innerHTML ='';
		 new Insertion.Top('formulario_reserva',http.responseText);			 
		/*$('galeria_dinamica').innerHTML = http.responseText;*/						
			//Effect.BlindDown('galeria_dinamica');
			//setTimeout("addReflections()",5000);
	}
}

