﻿
$(window).unload(function(){$("#dialogo").dialog("close");});
		
		var txt_country_aux;
		
		$(function() {
			
			getAjaxPruebaCombo_Country();
			getAjaxPruebaCombo_Cities();
			
			$("#txt_country_p").autocomplete({
				autoFocus: true,
				delay: 300,
				source:function( request, response ) {
						$.getJSON("/ajax_request.asp?AEaction=get_countries_prueba", {
							term: request.term
						}, function(data){
								$.each(data, function(key,value){
									if(request.term==value.label){
										country_sel = value.id_country;
										$("#txt_cities_p").removeAttr("disabled");
										$("#txt_cities_p").removeClass("txt_block");
									}
									else{
										$("#txt_cities_p").val("");
										$("#txt_cities_p").attr("disabled","disabled");
										$("#txt_cities_p").addClass("txt_block");
									}	
								});
								response(data);
							}
						);
					},
				minLength: 2,
				select: function( event, ui ) {
					country_sel = ui.item.id_country;
					$("#txt_cities_p").removeAttr("disabled");
					$("#txt_cities_p").removeClass("txt_block");
				},
				focus: function( event, ui ) {
					txt_country_aux = ui.item.label;
					country_sel = ui.item.id_country;
				},
				close: function( event, ui ) {
					if(txt_country_aux!=$("#txt_country_p").val()){
						txt_country_aux="";
						country_sel = "";
					}
					else{
						$("#txt_cities_p").removeAttr("disabled");
						$("#txt_cities_p").removeClass("txt_block");
					}
				},
				open: function(e,ui) {
					$("ul.ui-autocomplete").removeClass("ui-corner-all");
					$("ul.ui-autocomplete li a").removeClass("ui-corner-all");
					var termTemplate = "<strong style='color:#E60000;'>%s</strong>";
					var
					acData = $(this).data('autocomplete');

					acData
					.menu
					.element
					.find('a')
					.each(function() {
						var me = $(this);
						var regex = new RegExp(acData.term, "gi");
						me.html( me.text().replace(regex, function (matched) {
							return termTemplate.replace('%s', matched);
						}) );
					});
				}
			});
			
			$("#txt_cities_p").autocomplete({
				autoFocus: true,
				delay: 300,
				source:function( request, response ) {
						$.getJSON("/ajax_request.asp?AEaction=get_cities_prueba&AEcountry="+encodeURIComponent($("#txt_country_p").val()), {
							term: request.term
						}, function(data){
								$.each(data, function(key,value){
									if(request.term==value.label){
										if(value.dest_url == 1)
										{
											id_url = "1";
											check_checkbox("chk_airport", "1");
											check_checkbox("chk_rail", "2");
											check_checkbox("chk_downtown", "2");
											$("#td_type_location").css({"visibility":"hidden"});
											$("#td_type_location_text").css({"visibility":"hidden"});
											$("#codigo_selected").val(value.label);
											id_url = value.dest_url;
										}
										else
										{
											$("#td_type_location").css({"visibility":"visible"});
											$("#td_type_location_text").css({"visibility":"visible"});
											if(value.label=="girona")
											{
												$("#codigo_selected").val("gerona");
											}
											else
											{
												$("#codigo_selected").val(value.label);
											}
											id_url = value.dest_url;
										}
									}
								});
								response(data);
							}
						);
					},
				minLength: 2,
				select: function( event, ui ) {
					if(ui.item.dest_url == 1)
					{
						id_url = "1";
						check_checkbox("chk_airport", "1");
						check_checkbox("chk_rail", "2");
						check_checkbox("chk_downtown", "2");
						$("#td_type_location").css({"visibility":"hidden"});
						$("#td_type_location_text").css({"visibility":"hidden"});
						$("#codigo_selected").val(ui.item.value);
						id_url = ui.item.dest_url;
					}
					else
					{
						$("#td_type_location").css({"visibility":"visible"});
						$("#td_type_location_text").css({"visibility":"visible"});
						if(ui.item.value=="girona")
						{
							$("#codigo_selected").val("gerona");
						}
						else
						{
							$("#codigo_selected").val(ui.item.value);
						}
						id_url = ui.item.dest_url;
					}
				},
				focus: function( event, ui ) {
					if(ui.item.dest_url == 1)
					{
						id_url = "1";
						check_checkbox("chk_airport", "1");
						check_checkbox("chk_rail", "2");
						check_checkbox("chk_downtown", "2");
						$("#td_type_location").css({"visibility":"hidden"});
						$("#td_type_location_text").css({"visibility":"hidden"});
						$("#codigo_selected").val(ui.item.value);
						id_url = ui.item.dest_url;
					}
					else
					{
						$("#td_type_location").css({"visibility":"visible"});
						$("#td_type_location_text").css({"visibility":"visible"});
						if(ui.item.value=="girona")
						{
							$("#codigo_selected").val("gerona");
						}
						else
						{
							$("#codigo_selected").val(ui.item.value);
						}
						id_url = ui.item.dest_url;
					}
				},
				close: function( event, ui ) {
					if($("#codigo_selected").val()!=$("#txt_cities_p").val() && $("#codigo_selected").val()!="gerona"){
						$("#codigo_selected").val("");
						id_url = "";
					}
				},
				search: function( event, ui ) {
					$("#codigo_selected").val("");
					id_url = "";
				},
				open: function(e,ui) {
					$("ul.ui-autocomplete").removeClass("ui-corner-all");
					$("ul.ui-autocomplete li a").removeClass("ui-corner-all");
					var termTemplate = "<strong style='color:#E60000;'>%s</strong>";
					var
					acData = $(this).data('autocomplete');

					acData
					.menu
					.element
					.find('a')
					.each(function() {
						var me = $(this);
						var regex = new RegExp(acData.term, "gi");
						me.html( me.text().replace(regex, function (matched) {
							return termTemplate.replace('%s', matched);
						}) );
					});
				}
			});
			
			check_checkbox("chk_airport", "1");

			/*$('#selectedDatepicker').datepicker({
			beforeShow: readSelected, onSelect: updateSelected,
			numberOfMonths: 3,
			minDate: new Date(), maxDate: new Date(2014, 12 - 1, 31),
			showOn: 'both', buttonImageOnly: true, buttonImage: 'images/calendar.gif',
			dateFormat: 'm/d/yy', showOtherMonths: true, selectOtherMonths: true, changeMonth: true,changeYear: true, firstDay: 1});

			// Prepare to show a date picker linked to three select controls
			function readSelected()
			{
				$('#selectedDatepicker').val($('#recmonth').val() + '/' +
				$('#recday').val() + '/' + $('#recyear').val());
				return {};
			}

			// Update three select controls to match a date picker selection
			function updateSelected(date)
			{	
				var fecha = new Date(date);
				var fecha_dev;
				
				fecha.setDate(fecha.getDate()+3);
				
				fecha_dev = fecha.getMonth()+1 + "/" + fecha.getDate() + "/" + fecha.getFullYear();
				
				$('#recmonth').val(date.substring(0, date.indexOf("/")));
				$('#recday').val(date.substring(date.indexOf("/")+1, date.lastIndexOf("/")));
				$('#recyear').val(date.substring(date.lastIndexOf("/")+1, date.lastIndexOf("/")+5));
				
				var option = this.id == "selectedDatepicker" ? "minDate" : "maxDate";
				$('#selectedDatepicker2').datepicker( "option", option, date );
				
				$('#devmonth').val(fecha_dev.substring(0, fecha_dev.indexOf("/")));
				$('#devday').val(fecha_dev.substring(fecha_dev.indexOf("/")+1, fecha_dev.lastIndexOf("/")));
				$('#devyear').val(fecha_dev.substring(fecha_dev.lastIndexOf("/")+1, fecha_dev.lastIndexOf("/")+5));

				CheckDiffDate();
	
			}
			
			
			$('#selectedDatepicker2').datepicker({
			beforeShow: readSelected2, onSelect: updateSelected2,
			numberOfMonths: 3,
			minDate: new Date(2011, 1 - 1, 1), maxDate: new Date(2014, 12 - 1, 31),
			showOn: 'both', buttonImageOnly: true, buttonImage: 'images/calendar.gif',
			dateFormat: 'm/d/yy', showOtherMonths: true, selectOtherMonths: true, changeMonth: true,changeYear: true, firstDay: 1});
			//$('#selectedDatepicker2').datepicker($.datepicker.regional['es']);

			// Prepare to show a date picker linked to three select controls
			function readSelected2()
			{
				$('#selectedDatepicker2').val($('#devmonth').val() + '/' +
				$('#devday').val() + '/' + $('#devyear').val());
				return {};
			}

			// Update three select controls to match a date picker selection
			function updateSelected2(date)
			{
				$('#devmonth').val(date.substring(0, date.indexOf("/")));
				$('#devday').val(date.substring(date.indexOf("/")+1, date.lastIndexOf("/")));
				$('#devyear').val(date.substring(date.lastIndexOf("/")+1, date.lastIndexOf("/")+5));
				
				CheckDiffDate();
			}
			*/
		});
		
		$(document).ready(function() {
			
			$('#rec_datetime_date').datepicker({
				showOn: 'both',
				buttonImage: 'images/calendar.gif',
				buttonImageOnly: true,
				buttonText: '...',
				altField: '',
				dateFormat: 'd.mm.yy',
				duration: '',
				firstDay: 1,
				gotoCurrent: true,
				numberOfMonths: 2,
				changeMonth: true,
				changeYear: true,
				minDate: new Date(),
				maxDate: new Date(2014, 12 - 1, 31),
				onSelect: function(dateText, inst) {
				
					var fecha = new Date($('#rec_datetime_date').datepicker('getDate'));
					
					fecha.setDate(fecha.getDate()+7);
					
					$('#dev_datetime_date').datepicker( "option", "minDate", dateText);
				
					$('#dev_datetime_date').datepicker('setDate', fecha );
					
					$('#recday').val(dateText.split('.')[0]);
					$('#recmonth').val(dateText.split('.')[1]);
					$('#recyear').val(dateText.split('.')[2]);
					
					$('#devday').val($('#dev_datetime_date').val().split('.')[0]);
					$('#devmonth').val($('#dev_datetime_date').val().split('.')[1]);
					$('#devyear').val($('#dev_datetime_date').val().split('.')[2]);
					
					CheckDiffDate();
				},
				beforeShowDay: function(date) {

					return [true, ""];
				}
			});
			
			
			$('#dev_datetime_date').datepicker({
				showOn: 'both',
				buttonImage: 'images/calendar.gif',
				buttonImageOnly: true,
				buttonText: '...',
				altField: '',
				dateFormat: 'd.mm.yy',
				duration: '',
				firstDay: 1,
				gotoCurrent: true,
				numberOfMonths: 2,
				changeMonth: true,
				changeYear: true,
				minDate: $('#rec_datetime_date').datepicker('getDate'),
				maxDate: new Date(2014, 12 - 1, 31),
				onSelect: function(dateText, inst) {
				
					$('#recday').val($('#rec_datetime_date').val().split('.')[0]);
					$('#recmonth').val($('#rec_datetime_date').val().split('.')[1]);
					$('#recyear').val($('#rec_datetime_date').val().split('.')[2]);
				
					$('#devday').val(dateText.split('.')[0]);
					$('#devmonth').val(dateText.split('.')[1]);
					$('#devyear').val(dateText.split('.')[2]);
					
					CheckDiffDate();
					
				},
				beforeShowDay: function(date) {
					var year = date.getFullYear();
					var month = date.getMonth() + 1;
					var day = date.getDate();
					var weekday = date.getDay();

					if (month < 10) {
						month = '0' + month;
					}

					if (day < 10) {
						day = '0' + day;
					}

					var datestr = year + '-' + month + '-' + day;

					return [true, ""];
				}
			});
			
			$('#rec_datetime_date').change(
				function()
				{
					$('#recday').val($('#rec_datetime_date').val().split('.')[0]);
					$('#recmonth').val($('#rec_datetime_date').val().split('.')[1]);
					$('#recyear').val($('#rec_datetime_date').val().split('.')[2]);
				
					$('#devday').val($('#dev_datetime_date').val().split('.')[0]);
					$('#devmonth').val($('#dev_datetime_date').val().split('.')[1]);
					$('#devyear').val($('#dev_datetime_date').val().split('.')[2]);
					
					CheckDiffDate();
				}
			);
			
			$('#dev_datetime_date').change(
				function()
				{
					$('#recday').val($('#rec_datetime_date').val().split('.')[0]);
					$('#recmonth').val($('#rec_datetime_date').val().split('.')[1]);
					$('#recyear').val($('#rec_datetime_date').val().split('.')[2]);
				
					$('#devday').val($('#dev_datetime_date').val().split('.')[0]);
					$('#devmonth').val($('#dev_datetime_date').val().split('.')[1]);
					$('#devyear').val($('#dev_datetime_date').val().split('.')[2]);
					
					CheckDiffDate();
				}
			);
			
		});
		
		function check_checkbox(id_chk, accion_chk)
		{
		
			if(accion_chk == "1")
			{
				$("#"+id_chk).attr("checked",true);
				click_checkbox(id_chk);
			}
			
			if(accion_chk == "2")
			{
				$("#"+id_chk).attr("checked",false);
				click_checkbox(id_chk);
			}
		
		}
		
		function click_checkbox(id_chk)
		{
		
			if($("#"+id_chk).attr("checked") == true)
			{
				$("#"+id_chk).button("option","icons",{primary:'ui-icon-check'});
				$("#"+id_chk).button("refresh");
			}
			
			if($("#"+id_chk).attr("checked") == false)
			{
				$("#"+id_chk).button("option","icons",{primary:'ui-icon-closethick'});
				$("#"+id_chk).button("refresh");
			}
		
		}
		
	//Comprueba los destinos propios de Record y no de otros proveedores	
	// AMM 01/10/2007
	
		function RecordDestinations(sValue){
			
			if(sValue=="malaga" || sValue=="alicante" || sValue=="mallorca" || sValue=="majorca" || sValue=="ALC" || sValue=="PMA" || sValue=="MAL")
			{
				bFound = true
			}
			else
			{
				bFound = false
			}
			return bFound;
		}

		// función que determina la diferencia de fechas 
			function CheckDiffDate(){
			   var startdate;
			   var endate;
			   var days;
			   var starthour;
			   var endhour;
			   var startmin;
			   var endmin;
			   
		 
			   startdate  = document.getElementById('recday').value + '/' + document.getElementById('recmonth').value + '/' + document.getElementById('recyear').value;
               endate     = document.getElementById('devday').value + '/' + document.getElementById('devmonth').value + '/' + document.getElementById('devyear').value;

			   // horas y minutos
			   starthour  = document.reserva.select2[document.reserva.select2.selectedIndex].value;
			   startmin   = document.reserva.select3[document.reserva.select3.selectedIndex].value;
			   endhour    = document.reserva.select4[document.reserva.select4.selectedIndex].value;
			   endmin     = document.reserva.select5[document.reserva.select5.selectedIndex].value;
			   
			   days = DiferenciaFechas(startdate,endate,starthour,startmin,endhour,endmin);
			   document.reserva.diffday.value=1*days;
		}
            
		var txt_input;
		var txt_ult_input;
		var tipo_form = 2;
		var posicion;
		var img_height;
		var id_url;
		var url_destino;
		var chk_aeropuerto;
		var	chk_estacion;
		var chk_ciudad;
		var country_sel;
		
		country_sel = "ES";
		
		function getAjaxOficinasAE(id_dest, loc_type,load_text)
		{
			var str;
			
			var txt_country;
			
			var recday
			var recmonth
			var recyear
			var devday
			var devmonth
			var devyear
			
			var rec_hour
			var rec_minute
			var dev_hour
			var dev_minute
			
			recday = $('#recday').attr('value');
			recmonth = $('#recmonth').attr('value');
			recyear = $('#recyear').attr('value');
			devday = $('#devday').attr('value');
			devmonth = $('#devmonth').attr('value');
			devyear = $('#devyear').attr('value');
			
			rec_hour = $('#select2').attr('value');
			rec_minute = $('#select3').attr('value');
			dev_hour = $('#select4').attr('value');
			dev_minute = $('#select5').attr('value');
			
			if($('#txt_country_p').is(":visible"))
			{
				txt_country = $('#txt_country_p').attr('value');
			}
			else
			{
				txt_country = $('#select_country option:selected').text();
			}
			
			$("#dialogo").html("<div id='loading_text' class='loading_text'>"+load_text+"</div><div id='progressbar'></div>");
			
			$(function() {
				$("#progressbar").progressbar({
					value:100
				});
			});
			
			str = 'AEaction=get_Oficina_Vehiculos&AEstr=' + encodeURIComponent(id_dest) + '&AEloc_type=' + encodeURIComponent(loc_type) + '&AEIDCountry=' + encodeURIComponent(country_sel) + '&AETXTCountry=' + encodeURIComponent(txt_country) + '&recday=' + encodeURIComponent(recday) + '&recmonth=' + encodeURIComponent(recmonth) + '&recyear=' + encodeURIComponent(recyear) + '&devday=' + encodeURIComponent(devday) + '&devmonth=' + encodeURIComponent(devmonth) + '&devyear=' + encodeURIComponent(devyear) + '&rec_hour=' + encodeURIComponent(rec_hour) + '&rec_minute=' + encodeURIComponent(rec_minute) + '&dev_hour=' + encodeURIComponent(dev_hour) + '&dev_minute=' + encodeURIComponent(dev_minute) + '&nocache=' + Math.random();
			$.ajax({
				type: "POST",
				url: "/ajax_request.asp",
				dataType: "html",
				data: str,
				success: function(msg) {
					$("#progressbar").hide();
					$("#loading_text").hide();
					$("#dialogo").html($("#dialogo").html()+msg);
					$("#submit_AE").button({disabled:true});
					$("#close_button").button();
					$("#submit_AE2").button({disabled:true});
					$("#close_button2").button();
					$("#dialogo").dialog("option","position","center");
					//alert(msg);
				}
			});
			
		}
		
		function getAjaxPrueba_ID_Country(aux){
			 var str, sel_country;
			 
			 if(aux == 1)
			 {
				sel_country = document.getElementById('txt_country').value;
			 }
			 if(aux == 2)
			 {
				sel_country = $('#select_country option:selected').html();
			 }

			 //$('#loading_img_locations').show();
			 str = 'AEaction=get_id_country_prueba&AEstr=' + encodeURIComponent(sel_country) + "&nocache=" + Math.random();
			 $.ajax({
			   type: "POST",
			   url: "/ajax_request.asp",
			   dataType: "html",
			   data: str,
			   success: function(msg) {
							country_sel = msg;
				}
			});	
		}
		
		function getAjaxPrueba_ID_Cities(){
			 var str, sel_cities;
			 
			 if($('#select_cities > option').length <= 1)
			 {
				sel_cities = document.getElementById('txt_cities').value;
			 }
			 else
			 {
				sel_cities = $('#select_cities option:selected').html();
			 }

			 //$('#loading_img_locations').show();
			 str = 'AEaction=get_id_cities_prueba&AEstr=' + encodeURIComponent(sel_cities) + "&nocache=" + Math.random();
			 $.ajax({
			   type: "POST",
			   url: "/ajax_request.asp",
			   dataType: "html",
			   data: str,
			   success: function(msg) {
							
							var datos_id
							
							datos_id = eval('(' + msg + ')');
							
							document.getElementById('codigo_selected').value=datos_id['ID_DESTINO'];
							id_url = datos_id['ID_URL'];
							
							if(id_url == "1")
							{
								check_checkbox("chk_airport", "1");
								check_checkbox("chk_rail", "2");
								check_checkbox("chk_downtown", "2");
								$("#td_type_location").css({"visibility":"hidden"});
								$("#td_type_location_text").css({"visibility":"hidden"});
							}
							else
							{
								$("#td_type_location").css({"visibility":"visible"});
								$("#td_type_location_text").css({"visibility":"visible"});
							}
				}
			});	
		}
		
		function getAjaxPruebaCombo_Country(){
		
			var str;
			
			if($('#select_country > option').length <= 2)
			{
				str = 'AEaction=get_countries_combo_prueba&nocache=' + Math.random();
				$.ajax({
					type: "POST",
					url: "/ajax_request.asp",
					dataType: "html",
					data: str,
					success: function(msg) {
								rellena_select_JSON(msg,selesp(),'select_country');
								comprueba_combo_country();
					}
				});
				
			}
		}
		
		function getAjaxPruebaCombo_Cities(){
		
			var str, sel_country;
			
			sel_country = $("#select_country").attr('value');
			
			str = 'AEaction=get_cities_combo_prueba&AEcountry=' + encodeURIComponent(sel_country) + '&nocache=' + Math.random();
			$.ajax({
				type: "POST",
				url: "/ajax_request.asp",
				dataType: "html",
				data: str,
				success: function(msg) {
							rellena_select_JSON(msg,'','select_cities');
							comprueba_combo_cities();
				}
			});
		}
		
		function getAjaxtooltip(){
			$('#tooltip_form').show();
			posicion = $('#info_tooltip').offset();
			img_height = $('#tooltip_form').height();
			//alert(img_height);
			$('#tooltip_form').css({'top' : posicion.top-img_height, 'left' : posicion.left+$('#info_tooltip').width()-40});
		}
		
		function rellena_select_JSON(mensaje,op_select,id_select)
		{
			newOptions = eval('(' + mensaje + ')');

			var selectedOption = op_select;

			var select = $('#'+id_select);
			$('option', select).remove();

			$.each(newOptions, function(val, text) {
				if(val==selectedOption)
				{
					select.append($("<option selected='selected'></option>").attr("value",val).text(text));
				}
				else
				{
					select.append($("<option></option>").attr("value",val).text(text));
				}
			});
		}
		
		function rellena_input(id, elem)
		{
			var txt_id;
			
			switch(elem) 
			{
				case "country":
					txt_id = "txt_country";
				break;
				case "cities":
					txt_id = "txt_cities";
				break;
			}
		
			$(".li-hover").removeClass('li-hover').addClass('li-sin-hover');
			$("#"+id).removeClass('li-sin-hover').addClass('li-hover');
			document.getElementById(txt_id).value=document.getElementById(id).innerHTML;
			txt_ult_input=document.getElementById(id).innerHTML;
		}
		
		function vacia_input(id, elem)
		{
			var txt_id;
			
			switch(elem) 
			{
				case "country":
					txt_id = "txt_country";
				break;
				case "cities":
					txt_id = "txt_cities";
				break;
			}
			
			$("#"+id).removeClass('li-hover').addClass('li-sin-hover');
			document.getElementById(txt_id).value = txt_input;
		}
		
		function abrir_selects()
		{
		
			if(tipo_form == 1)
			{
				getAjaxPruebaCombo_Country();
				$("#txt_country_p").hide();
				$("#txt_cities_p").hide();
				$('#img_boc').hide();
				$('#img_boc2').show();
				$("#select_country").show();
				$("#select_cities").show();
				$("#select_cities").attr('disabled','disabled');
				$("#select_country option[value='"+selesp()+"']").attr("selected","selected");
				$("#select_cities option[value='PMA']").attr("selected","selected");
				
				$("#codigo_selected").attr("value","-1");
				tipo_form = 2;
				comprueba_combo_country();
				comprueba_combo_cities();
			}
			else
			{
				$("#txt_country_p").show();
				$("#txt_cities_p").show();
				$('#img_boc').show();
				$('#img_boc2').hide();
				$("#txt_country_p").attr('value','');
				$("#txt_cities_p").attr('value','');
				$("#select_country").hide();
				$("#select_cities").hide();
				
				$("#codigo_selected").attr("value","-1");
				tipo_form = 1;
			}
		
		}
		
		function comprueba_combo_country()
		{
			if($("#select_country").attr('value') != '-1')
			{
				$("#select_cities option[value='-1']").attr("selected","selected");
				
				$("#codigo_selected").attr("value","-1");
				
				$("#select_cities").removeAttr("disabled");
				
				getAjaxPrueba_ID_Country(2);
				getAjaxPruebaCombo_Cities();
			}
			else
			{
				$("#select_cities option[value='-1']").attr("selected","selected");
				$("#select_cities").removeAttr("disabled");
				
				$("#codigo_selected").attr("value","-1");
			}
		}
		
		function comprueba_combo_cities()
		{
			if($("#select_cities").attr('value') != '-1')
			{
				getAjaxPrueba_ID_Cities();
			}
			else
			{
				$("#codigo_selected").attr("value","-1");
			}
		}
		
		function selecciona_dest(dest)
		{
			
			switch(dest) 
			{
				case "ALC":
					tipo_form = 1;
					$("#select_country").hide();
					$("#select_cities").hide();
					$("#txt_country_p").show();
					$("#txt_cities_p").show();
					$("#txt_country_p").attr('value','España');
					$("#txt_cities_p").attr('value','Alicante');
					$("#codigo_selected").attr("value","ALC");
					id_url = "1";
					check_checkbox("chk_airport", "1");
					check_checkbox("chk_rail", "2");
					check_checkbox("chk_downtown", "2");
					$("#td_type_location").css({"visibility":"hidden"});
					$("#td_type_location_text").css({"visibility":"hidden"});
				break;
				case "PMA":
					tipo_form = 1;
					$("#select_country").hide();
					$("#select_cities").hide();
					$("#txt_country_p").show();
					$("#txt_cities_p").show();
					$("#txt_country_p").attr('value','España');
					$("#txt_cities_p").attr('value','Mallorca');
					$("#codigo_selected").attr("value","PMA");
					id_url = "1";
					check_checkbox("chk_airport", "1");
					check_checkbox("chk_rail", "2");
					check_checkbox("chk_downtown", "2");
					$("#td_type_location").css({"visibility":"hidden"});
					$("#td_type_location_text").css({"visibility":"hidden"});
				break;
				case "MAL":
					tipo_form = 1;
					$("#select_country").hide();
					$("#select_cities").hide();
					$("#txt_country_p").show();
					$("#txt_cities_p").show();
					$("#txt_country_p").attr('value','España');
					$("#txt_cities_p").attr('value','Malaga');
					$("#codigo_selected").attr("value","MAL");
					id_url = "1";
					check_checkbox("chk_airport", "1");
					check_checkbox("chk_rail", "2");
					check_checkbox("chk_downtown", "2");
					$("#td_type_location").css({"visibility":"hidden"});
					$("#td_type_location_text").css({"visibility":"hidden"});
				break;
			}
			
		}
		
		function mostrarhorario(id)
		{
			$("#"+id).toggle();
		}
		
		function chck_doloc(id)
		{
			if(document.getElementById(id))
			{
				document.getElementById(id).checked=true;
			}
		}
		
		function bot_cargando()
		{
		
			$("#progressbar").show();
			$("#loading_text").show();
			$("#contenedor_locations").hide();
			$("#dialogo").dialog("option","position","center");
			
		}
		
		function sel_name_loc(name1, name2, num_cont)
		{
		
			if(num_cont == '1')
			{
				
				if(name2 == "")
				{
					$("#hidden_name_loc_rec").val(name1);
					$("#hidden_name_loc_dev").val(name1);
				}
				else
				{
					$("#hidden_name_loc_rec").val(name1+", "+name2);  
					$("#hidden_name_loc_dev").val(name1+", "+name2);
				}
			}
			else
			{
				
				if(name2 == "")
				{
					$("#hidden_name_loc_dev").val(name1);
				}
				else
				{
					$("#hidden_name_loc_dev").val(name1+", "+name2);
				}
			}
		
		}
		
		function comprobar_radio()
		{
			if($('input[name="puloc"]').is(':checked') && $('input[name="doloc"]').is(':checked'))
			{
				$("#submit_AE").button( "option", "disabled", false );
			}
		}
		
		function show_form_questions()
		{
			$("#send_button_form_question").button();
			$("#name_form_question").val("");
			$("#email_form_question").val("");
			$("#textarea_form_question").val("");
			$("#form_question").show();
			$("#form_question_result").hide();
			$("#form_question_id").dialog({draggable:true,modal:true,resizable:false,width:'auto'});
		}
		
