	//============================================================================================
	//   LIBRERIA DE FUNCIONES
	//============================================================================================
	
	function cambiar_orden(campo){

	if (campo == "nom"){
		// si ordeno por lo que ya esta ordenado cambio desc
		if (document.getElementById('campo_actual').value == "nom"){
			if (document.getElementById('desc').value == 0){
				document.getElementById('desc').value=1;	
			}
			else {document.getElementById('desc').value=0;	}
		
		}
		else { document.getElementById('campo_actual').value=campo;
			   document.getElementById('desc').value=0;		   
		
		}
	
	}
	if (campo == "cat"){
		// si ordeno por lo que ya esta ordenado cambio desc
		if (document.getElementById('campo_actual').value == "cat"){
			if (document.getElementById('desc').value == 0){
				document.getElementById('desc').value=1;	
			}
			else {document.getElementById('desc').value=0;	}
		
		}
		else { document.getElementById('campo_actual').value=campo;
			   document.getElementById('desc').value=0;		   
		
		}
	
	}
	
	if (campo == "tarifa"){
		// si ordeno por lo que ya esta ordenado cambio desc
		if (document.getElementById('campo_actual').value == "tarifa"){
			if (document.getElementById('desc').value == 0){
				document.getElementById('desc').value=1;	
			}
			else {document.getElementById('desc').value=0;	}
		
		}
		else { document.getElementById('campo_actual').value=campo;
			   document.getElementById('desc').value=0;		   
		
		}
	
	}
	

	//document.getElementById('form_orden').action="index.php?id=1&ct="+document.getElementById('ct_actual').value+"&pg=1";
	tam=document.getElementById('tam_page').value;
	document.getElementById('form_orden').action = "index.php?id=1&ct=" + document.getElementById('ct_actual').value + "&pg=1&tam_page=" + tam + "&campo_actual=" + campo;
	document.getElementById('form_orden').submit();
	}

	//============================================================================================
	//============================================================================================

	function cambiar_orden_all(campo){

	// esta funcion es para la impresion de todos los paquetes
	if (campo == "nom"){
		// si ordeno por lo que ya esta ordenado cambio desc
		if (document.getElementById('campo_actual').value == "nom"){
			if (document.getElementById('desc').value == 0){
				document.getElementById('desc').value=1;	
			}
			else {document.getElementById('desc').value=0;	}
		
		}
		else { document.getElementById('campo_actual').value=campo;
			   document.getElementById('desc').value=0;		   
		
		}
	
	}
	if (campo == "cat"){
		// si ordeno por lo que ya esta ordenado cambio desc
		if (document.getElementById('campo_actual').value == "cat"){
			if (document.getElementById('desc').value == 0){
				document.getElementById('desc').value=1;	
			}
			else {document.getElementById('desc').value=0;	}
		
		}
		else { document.getElementById('campo_actual').value=campo;
			   document.getElementById('desc').value=0;		   
		
		}
	
	}
	
	if (campo == "tarifa"){
		// si ordeno por lo que ya esta ordenado cambio desc
		if (document.getElementById('campo_actual').value == "tarifa"){
			if (document.getElementById('desc').value == 0){
				document.getElementById('desc').value=1;	
			}
			else {document.getElementById('desc').value=0;	}
		
		}
		else { document.getElementById('campo_actual').value=campo;
			   document.getElementById('desc').value=0;		   
		
		}
	
	}
	

	//document.getElementById('form_orden').action="index.php?id=1&ct="+document.getElementById('ct_actual').value+"&pg=1";
	tam=document.getElementById('tam_page').value;
	document.getElementById('form_orden').action="index.php?id=24&pg=1&tam_page="+tam;
	document.getElementById('form_orden').submit();
	}

	//============================================================================================
	//============================================================================================


	function validar_mail(t){
		//txt=document.getElementById('email_derecha').value;
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(t)){
			return (true);
		}
		else {
			alert("La dirección de email es incorrecta.");
			return (false);
		}

	}


	//============================================================================================
	//============================================================================================

	function preview_imp(){
		ct=document.getElementById('ct_actual').value;
		desc=document.getElementById('desc').value;
		campo=document.getElementById('campo_actual').value;
		url="index.php?id=3&ct="+ct+"&desc="+desc+"&campo_actual="+campo;
		win=window.open(url,"","width=480,height=450,scrollbars=yes");
		//"toolbar=no,menubar=no,width=400"
	}

	//============================================================================================
	//============================================================================================

	function preview_imp_paquete(){
		ct=document.getElementById('ct_actual').value;
		id_p=document.getElementById('p_actual').value;
		url="index.php?id=11&ct="+ct+"&id_p="+id_p;
		win=window.open(url,"","width=480,height=450,scrollbars=yes");
	}

	//============================================================================================
	//============================================================================================

	function preview_imp_hotel(){
		ct=document.getElementById('ct_actual').value;
		id_h=document.getElementById('h_actual').value;
		lang=document.getElementById('idioma_actual').value;
		url="index.php?id=12&ct="+ct+"&id_h="+id_h+"&lang="+lang;
		win=window.open(url,"","width=480,height=450,scrollbars=yes");
	}

	//============================================================================================
	//============================================================================================

	function preview_novia(id){
		url="index.php?id=28&id_n="+id;
		win=window.open(url,"","width=480,height=450,scrollbars=yes");
	}

	//============================================================================================
	//============================================================================================

	function recomendar_novia(id){
		url="index.php?id=29&id_n="+id;
		win=window.open(url,"","width=460,height=450,scrollbars=no,toolbar=no,menubar=no");
	}

	//============================================================================================
	//============================================================================================


	function recomendar(){
		ct=document.getElementById('ct_actual').value;
		desc=document.getElementById('desc').value;
		campo=document.getElementById('campo_actual').value;
		url="index.php?id=4&ct="+ct+"&desc="+desc+"&campo_actual="+campo;
		win=window.open(url,"","width=460,height=450,scrollbars=no,toolbar=no,menubar=no");
	}

	//============================================================================================
	//============================================================================================

	function cambiar_accion(lang){
		fmr=document.getElementById('form_idioma');
		accion=fmr.action;
		fmr.action=accion+"&lang="+lang;
		fmr.submit();
	
	}

	//============================================================================================
	//============================================================================================

	function recomendar_descrip(cod){
		ct=document.getElementById('ct_actual').value;
		switch(cod){
			case "paquete":
				id_p=document.getElementById('p_actual').value;
				url="index.php?id=13&ct="+ct+"&id_p="+id_p;
				break;
			case "hotel":
				id_h=document.getElementById('h_actual').value;
				url="index.php?id=13&ct="+ct+"&id_h="+id_h;
				break;
		}
		win=window.open(url,"","width=460,height=450,scrollbars=no,toolbar=no,menubar=no");

	}

	//============================================================================================
	//============================================================================================

	function abrir_galeria(url){
		window.open(url,"","toolbar=no,menubar=no,height=555,width=700");
	
	}

	//============================================================================================
	//============================================================================================

	function ir_a_descripcion(){
		url=document.getElementById('hoteles').value;
		document.location.href=url;
		
	}

	//============================================================================================
	//============================================================================================
	
	function validar_suscripcion(){
		// cajas de texto
		user=document.getElementById('username').value;
		pass=document.getElementById('password').value;
		email=document.getElementById('email').value;
		respuesta=document.getElementById('respuesta').value;
		nombre=document.getElementById('nombre').value;
		apellido=document.getElementById('apellido').value;
		num_doc=document.getElementById('num_doc').value;
		// combos
		pregunta=document.getElementById('pregunta').value;	
		tipo_doc=document.getElementById('tipo_doc').value;	
		dia_nac=document.getElementById('dia_nac').value;		
		mes_nac=document.getElementById('mes_nac').value;		
		anio_nac=document.getElementById('anio_nac').value;		
		// campos a re-confirmar
		pass_repeat=document.getElementById('password_repeat').value;
		email_repeat=document.getElementById('email_repeat').value;


		// verifico que los campos obligatorios no esten vacios y que se hayan seleccionado 
		// los combos obligatorios
		if (user == ""){
			alert("Debe especificar un nombre de usuario.");
			return false;
		}
		if (pass == ""){
			alert("Debe especificar una contraseña.");
			return false;
		}
		// verifico que la contaseña y su confirmacion coincidan
		if(pass_repeat != pass){
			alert("La contraseña y su confirmacion no coinciden.");
			return false;
		
		}
		if (email == ""){
			alert("Debe especificar un email.");
			return false;
		}
		// verifico la validez del email
		if (validar_mail(email) == false){
			return false;
		}
		// verifico que email y su confirmacion coincidan
		if(email_repeat != email){
			alert("El email y su confirmacion no coinciden.");
			return false;

		}

		if (pregunta == ""){
			alert("Debe seleccionar una pregunta de seguridad.");
			return false;
		}

		if (respuesta == ""){
			alert("Debe especificar una respuesta a la pregunta de seguridad.");
			return false;
		}
		if (nombre == ""){
			alert("Debe especificar un nombre.");
			return false;
		}
		if (apellido == ""){
			alert("Debe especificar un apellido.");
			return false;
		}
		if (tipo_doc == ""){
			alert("Debe seleccionar un tipo de documento.");
			return false;
		}
		if (num_doc == ""){
			alert("Debe especificar un numero de documento.");
			return false;
		}
		if ((dia_nac == "") || (mes_nac == "") || (anio_nac == "") ){
			alert("Debe especificar su fecha de nacimiento.");
			return false;
		}


		return true;

	}


	//============================================================================================
	//============================================================================================

	function limpiar_suscripcion(){
		document.getElementById('username').value="";
		document.getElementById('password').value="";
		document.getElementById('password_repeat').value="";
		document.getElementById('email').value="";
		document.getElementById('email_repeat').value="";
		document.getElementById('respuesta').value="";
		document.getElementById('nombre').value="";
		document.getElementById('apellido').value="";
		document.getElementById('prefijo').value="(05411)";
		document.getElementById('tel').value="";
		document.getElementById('num_doc').value="";
		document.getElementById('num_pass').value="";
		// combos
		document.getElementById('pregunta').selectedIndex=0;	
		document.getElementById('tipo_doc').selectedIndex=0;	
		document.getElementById('dia_nac').selectedIndex=0;		
		document.getElementById('mes_nac').selectedIndex=0;		
		document.getElementById('anio_nac').selectedIndex=0;		
		document.getElementById('civil').selectedIndex=0;		
		document.getElementById('cant_hijos').selectedIndex=0;		
		document.getElementById('pais_pass').selectedIndex=0;	
		// radios
		document.form_suscripcion.sexo[0].checked=true;
		document.form_suscripcion.news[0].checked=true;
		document.form_suscripcion.news_anun[0].checked=true;
	
	}

	//============================================================================================
	//============================================================================================

	function validar_contacto(){
		// si no se ingreso username tengo que verificar 
		// que todos los campos obligatorios esten llenos
		if((document.getElementById('username').value == "") && (document.getElementById('password').value == "")){			
			nombre=document.getElementById('nombre').value;
			apellido=document.getElementById('apellido').value;
			email=document.getElementById('email').value;
			pais=document.getElementById('pais').selectedIndex;		

			if ((nombre == "") || (apellido == "") || (email == "") || (pais == 0)){
				alert("Si no es usuario debe completar los campos obligatorios.");
				return false;
			}
			// verifico la validez del email
			if (validar_mail(email) == false){
				return false;
			}
			// si se completaron todos los campos cambio la accion del formulario para que mande el mail directamente
			document.getElementById('form_suscripcion').action="index.php?id=20&cod_op=2";
			return true;

		}
		// si se ingreso username o password tambien se tiene que ingresar el otro campo
		if ((document.getElementById('username').value == "") || (document.getElementById('password').value == "")){
			alert("Si es usuario debe ingresar username y password");
			return false;
		}
		return true;
		
	}

	//============================================================================================
	//============================================================================================

	function validar_reserva(){
		// si no se ingreso username tengo que verificar 
		// que todos los campos obligatorios esten llenos
		if((document.getElementById('username').value == "") && (document.getElementById('password').value == "")){			
			nombre=document.getElementById('nombre').value;
			apellido=document.getElementById('apellido').value;
			email=document.getElementById('email').value;
			pais=document.getElementById('pais').selectedIndex;		
			paquete=document.getElementById('paquete').selectedIndex;		
			hotel=document.getElementById('hotel').selectedIndex;		
			if ((nombre == "") || (apellido == "") || (email == "") || (pais == 0)){
				alert("Si no es usuario debe completar los campos obligatorios.");
				return false;
			}
			if ((hotel == 0) && (paquete == 0)){
				alert("La reserva debe estar asociada a un hotel o a un paquete o a ambos.");		
				return false;
			}

			// verifico la validez del email
			if (validar_mail(email) == false){
				return false;
			}
			// si se completaron todos los campos cambio la accion del formulario para que mande el mail directamente
			document.getElementById('form_reserva').action="index.php?id=22&cod_op=2";
			return true;

		}
		// si se ingreso username o password tambien se tiene que ingresar el otro campo
		if ((document.getElementById('username').value == "") || (document.getElementById('password').value == "")){
			alert("Si es usuario debe ingresar username y password");
			return false;
		}
		return true;
		
	}