	var nav=(navigator.appName == "Microsoft Internet Explorer") ? "ie" : "ns";

	NS4=(document.layers) ? 1 : 0;
	IE4=(document.all) ? 1 : 0;

	function ref(nombre_capa)
	{
		if (nav == "ie") return "document.all['" + nombre_capa + "'].style.";
		if (nav == "ns") return "document." + nombre_capa + ".";
	} 

	function mostrar_capa(nombre_capa)
	{
		eval(ref(nombre_capa) + "visibility='visible'");
	}

	function ocultar_capa(nombre_capa)
	{
		eval(ref(nombre_capa) + "visibility='hidden'");
	}
	
	function abrir_ventana(pagina, width_, height_)
	{
		var pageWidth = screen.availWidth;
		var pageHeight = screen.availHeight;
		var top_;
		var left_;

		top_ = ( pageHeight - height_ ) / 2;
		left_ = ( pageWidth - width_ ) / 2;

		ventana  = window.open(pagina,'viatgestravelling','fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,top=' + top_ + ',left=' + left_ + ',width=' + width_ + ',height=' + height_ + ',titlebar=0,alwaysRaised=0,dependent=0,hotkeys=0',true);
		ventana.focus();
	}

	/*************************************************************************************************************************/

	function cambiar_imagen()
	{
		// CONFIGURACIÓN DE LAS FOTOS PEQUEÑAS
		max_width_image = 200; // px
		max_height_image = 200; // px
		max_size = 30; // Kb
		// -----------------------------------

		problema = false;

		width_imagen = document.all.imagen_nueva.width;
		height_imagen = document.all.imagen_nueva.height;
		size = parseInt(document.all.imagen_nueva.fileSize/1024);

		var the_string = document.all.imagen_nueva.src;
		var extension = the_string.substring(the_string.length-4,the_string.length);

		if ( ( extension != ".gif" ) && ( extension != ".jpg" ) && ( extension != "jpeg" ) && ( extension != ".png" ) && ( !problema ) )
		{
			alert("Formato incorrecto de imagen.\n\nLa imagen seleccionada debería estar en formato: GIF, JPG, JPEG o PNG");

			problema = true;	
		}

		if ( ( ( width_imagen > max_width_image ) || ( height_imagen > max_height_image ) || ( size > max_size ) ) && ( !problema ) )
		{
			alert("La imagen seleccionada es DEMASIADO GRANDE.\n\nOcupa " + size + "Kb y mide " + height_imagen + "x" + width_imagen + ". Como máximo debería ocupar " + max_size + "Kb y medir " + max_width_image + "x" + max_height_image + ".");

			problema = true;	
		}

		if ( !problema )
		{
			document.all.imagen_mostrar_nueva.src = document.all.imagen_nueva.src;
			return true;
		}

		document.all.imagen_nueva.src = "";
		return false;
	}

	function actualizar_imagen()
	{	
		document.all.imagen_nueva.src = document.all.imagen.value;
		timer_actualizar_imagen = setTimeout("cambiar_imagen()",300);
	}

	function cambiar_imagen_p()
	{
		// CONFIGURACIÓN DE LAS FOTOS PEQUEÑAS
		max_width_image = 200; // px
		max_height_image = 200; // px
		max_size = 30; // Kb
		// -----------------------------------

		problema = false;

		width_imagen_p = document.all.imagen_p_nueva.width;
		height_imagen_p = document.all.imagen_p_nueva.height;
		size = parseInt(document.all.imagen_p_nueva.fileSize/1024);

		var the_string = document.all.imagen_p_nueva.src;
		var extension = the_string.substring(the_string.length-4,the_string.length);

		if ( ( extension != ".gif" ) && ( extension != ".jpg" ) && ( extension != "jpeg" ) && ( extension != ".png" ) && ( !problema ) )
		{
			alert("Formato incorrecto de imagen_p.\n\nLa imagen_p seleccionada debería estar en formato: GIF, JPG, JPEG o PNG");

			problema = true;	
		}

		if ( ( ( width_imagen_p > max_width_image ) || ( height_imagen_p > max_height_image ) || ( size > max_size ) ) && ( !problema ) )
		{
			alert("La imagen_p seleccionada es DEMASIADO GRANDE.\n\nOcupa " + size + "Kb y mide " + height_imagen_p + "x" + width_imagen_p + ". Como máximo debería ocupar " + max_size + "Kb y medir " + max_width_image + "x" + max_height_image + ".");

			problema = true;	
		}

		if ( !problema )
		{
			document.all.imagen_p_mostrar_nueva.src = document.all.imagen_p_nueva.src;
			return true;
		}

		document.all.imagen_p_nueva.src = "";
		return false;
	}

	function actualizar_imagen_p()
	{	
		document.all.imagen_p_nueva.src = document.all.imagen_p.value;
		timer_actualizar_imagen_p = setTimeout("cambiar_imagen_p()",300);
	}

	function cambiar_imagen_itinerario_p()
	{
		// CONFIGURACIÓN DE LAS FOTOS PEQUEÑAS
		max_width_image = 200; // px
		max_height_image = 200; // px
		max_size = 30; // Kb
		// -----------------------------------

		problema = false;

		width_imagen_p = document.all.imagen_p_nueva.width;
		height_imagen_p = document.all.imagen_p_nueva.height;
		size = parseInt(document.all.imagen_p_nueva.fileSize/1024);

		var the_string = document.all.imagen_p_nueva.src;
		var extension = the_string.substring(the_string.length-4,the_string.length);

		if ( ( extension != ".jpg" ) && ( !problema ) )
		{
			alert("Formato incorrecto de imagen_p.\n\nLa imagen_p seleccionada debería estar en formato: JPG");

			problema = true;	
		}

		if ( ( ( width_imagen_p > max_width_image ) || ( height_imagen_p > max_height_image ) || ( size > max_size ) ) && ( !problema ) )
		{
			alert("La imagen_p seleccionada es DEMASIADO GRANDE.\n\nOcupa " + size + "Kb y mide " + height_imagen_p + "x" + width_imagen_p + ". Como máximo debería ocupar " + max_size + "Kb y medir " + max_width_image + "x" + max_height_image + ".");

			problema = true;	
		}

		if ( !problema )
		{
			document.all.imagen_p_mostrar_nueva.src = document.all.imagen_p_nueva.src;
			return true;
		}

		document.all.imagen_p_nueva.src = "";
		return false;
	}

	function actualizar_imagen_itinerario_p()
	{	
		document.all.imagen_p_nueva.src = document.all.imagen_p.value;
		timer_actualizar_imagen_p = setTimeout("cambiar_imagen_itinerario_p()",300);
	}

	function cambiar_imagen_cubierta()
	{
		// CONFIGURACIÓN DE LAS FOTOS
		max_width_image = 800; // px
		max_height_image = 200; // px
		max_size = 50; // Kb
		// -----------------------------------

		problema = false;

		width_imagen = document.all.imagen_nueva.width;
		height_imagen = document.all.imagen_nueva.height;
		size = parseInt(document.all.imagen_nueva.fileSize/1024);

		var the_string = document.all.imagen_nueva.src;
		var extension = the_string.substring(the_string.length-4,the_string.length);

		if ( ( extension != ".gif" ) && ( extension != ".jpg" ) && ( extension != "jpeg" ) && ( extension != ".png" ) && ( !problema ) )
		{
			alert("Formato incorrecto de imagen.\n\nLa imagen seleccionada debería estar en formato: GIF, JPG, JPEG o PNG");

			problema = true;	
		}

		if ( ( ( width_imagen > max_width_image ) || ( height_imagen > max_height_image ) || ( size > max_size ) ) && ( !problema ) )
		{
			alert("La imagen seleccionada es DEMASIADO GRANDE.\n\nOcupa " + size + "Kb y mide " + height_imagen + "x" + width_imagen + ". Como máximo debería ocupar " + max_size + "Kb y medir " + max_width_image + "x" + max_height_image + ".");

			problema = true;	
		}

		if ( !problema )
		{
			document.all.imagen_mostrar_nueva.src = document.all.imagen_nueva.src;
			return true;
		}

		document.all.imagen_nueva.src = "";
		return false;
	}

	function actualizar_imagen_cubierta()
	{	
		document.all.imagen_nueva.src = document.all.imagen.value;
		timer_actualizar_imagen_cubierta = setTimeout("cambiar_imagen_cubierta()",300);
	}

	function validar_formulario_newsletter(formulario)
	{
		problema = false;

		if ( formulario.email_newsletter.value == "" )
		{
			alert("El campo E-MAIL es obligatorio");
			formulario.email_newsletter.focus();
			problema = true;
		}
		else
		{
			campo = "document.formulario_newsletter.email_newsletter";
			nombre_campo = "E-MAIL";

			str = new String(eval(campo+".value"));
			// are regular expressions supported?
			var supported = 0;
			if (window.RegExp) {
				var tempStr = "a";
				var tempReg = new RegExp(tempStr);
				if (tempReg.test(tempStr)) supported = 1;
			}
			if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
			var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			if (!r1.test(str) && r2.test(str))
			{
				return true;
			} else {
				alert("El formato de mail del campo " + nombre_campo + " no es válido");
				eval(campo + ".select()");
				return false;
			}		
		}

		return !problema;
	}

	function cambiar_imagen_popup()
	{
		// CONFIGURACIÓN DE LAS FOTOS PEQUEÑAS
		max_width_image = 400; // px
		max_height_image = 274; // px
		max_size = 60; // Kb
		// -----------------------------------

		problema = false;

		width_imagen = document.all.imagen_nueva.width;
		height_imagen = document.all.imagen_nueva.height;
		size = parseInt(document.all.imagen_nueva.fileSize/1024);

		var the_string = document.all.imagen_nueva.src;
		var extension = the_string.substring(the_string.length-4,the_string.length);

		if ( ( extension != ".gif" ) && ( extension != ".jpg" ) && ( extension != "jpeg" ) && ( extension != ".png" ) && ( !problema ) )
		{
			alert("Formato incorrecto de imagen.\n\nLa imagen seleccionada debería estar en formato: GIF, JPG, JPEG o PNG");

			problema = true;	
		}

		if ( ( ( width_imagen > max_width_image ) || ( height_imagen > max_height_image ) || ( size > max_size ) ) && ( !problema ) )
		{
			alert("La imagen seleccionada es DEMASIADO GRANDE.\n\nOcupa " + size + "Kb y mide " + height_imagen + "x" + width_imagen + ". Como máximo debería ocupar " + max_size + "Kb y medir " + max_width_image + "x" + max_height_image + ".");

			problema = true;	
		}

		if ( !problema )
		{
			document.all.imagen_mostrar_nueva.src = document.all.imagen_nueva.src;
			return true;
		}

		document.all.imagen_nueva.src = "";
		return false;
	}

	function actualizar_imagen_popup()
	{	
		document.all.imagen_nueva.src = document.all.imagen.value;
		timer_actualizar_imagen_popup = setTimeout("cambiar_imagen_popup()",300);
	}