function dia_calendario(fecha,que_formulario,que_calendario){
actualizar_meses(que_formulario,que_calendario);

var form = document.getElementById(que_formulario);

arr_fecha = fecha.split("/");
// Divide cadena
var dia = arr_fecha[0];
var mes = arr_fecha[1];
var anio = arr_fecha[2];
// Quita espacio y pone 0
anio = anio.split(" ");
if (dia <10) dia = '0'+dia;
if (mes <10) mes = '0'+mes;

eval("form.fecha_dia_"+que_calendario+".value = dia");
eval("form.fecha_mesanio_"+que_calendario+".value = anio[0]+mes");

var gualdrapa = document.getElementById('rumbo_gualdrapa');
var calendario = document.getElementById('rumbo_cal');

gualdrapa.style.display = 'none';
calendario.style.display = 'none';

}
function dt_nuevafecha (str_fecha) {
	var re_date = /^(\d+)\/(\d+)\/(\d+)\s/;
	if (!re_date.exec(str_fecha))
		return alert("Invalid Datetime format: "+ str_fecha);
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function fecha_a_fechastr (dt_mueve_mes) {
	return (new String (dt_mueve_mes.getDate()+"/"+(dt_mueve_mes.getMonth()+1)+"/"+dt_mueve_mes.getFullYear()+" "));
}
function abrir_calendario(e,que_formulario,que_calendario,str_fecha,mover){

	var arr_meses = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
	var arr_dias_semana = ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"];
	var n_inicio_semana = 1; // Día de inicio de la semana (Domingo-Lunes  0-1)
	var dt_fecha = (str_fecha == null || str_fecha =="" ?  new Date() : dt_nuevafecha(str_fecha));

	var dt_fecha_hoy = new Date();
	var anio_hoy = dt_fecha_hoy.getFullYear();
	var mes_hoy = dt_fecha_hoy.getMonth();
	var anio_fecha = dt_fecha.getFullYear();
	var mes_fecha = dt_fecha.getMonth();

	
	if (anio_fecha == anio_hoy+1 && mes_hoy == mes_fecha)
	{
	return;
	}
	if (anio_fecha == anio_hoy && mes_hoy-1 == mes_fecha)
	{
	return;
	}
	
	var dt_fecha_menos_un_mes = new Date(dt_fecha);
	dt_fecha_menos_un_mes.setMonth(dt_fecha.getMonth()-1);
	var dt_fecha_mas_un_mes = new Date(dt_fecha); 
	dt_fecha_mas_un_mes.setMonth(dt_fecha.getMonth()+1);
	var dt_primer_dia_calendario = new Date(dt_fecha);
	dt_primer_dia_calendario.setDate(1);
	dt_primer_dia_calendario.setDate(1-(7+dt_primer_dia_calendario.getDay()-n_inicio_semana)%7);	
	var dt_ultimo_dia_calendario = new Date(dt_fecha_mas_un_mes);
	dt_ultimo_dia_calendario.setDate(0);

var gualdrapa = document.getElementById('rumbo_gualdrapa');
var calendario = document.getElementById('rumbo_cal');

	var str_buffer = new String ( 
	"<table align='center' class='rumbo_cal_fondo' cellspacing='0' cellpadding='0' border='0' width='100%' height='15'>"+
		"<tr>"+
			"<td>"+
				"<table align='center' style='border-collapse: collapse;' width='100%' height='100%' border='0'>"+
					"<tr>"+
"<td style='cursor: hand; cursor: pointer;' align='left' onclick='abrir_calendario(\"\",\""+que_formulario+"\",\""+que_calendario+"\",\""+fecha_a_fechastr(dt_fecha_menos_un_mes)+"\", \"mover\");'>"+
"<img border='0' src='imagenes/anterior.gif' alt='mes anterior' /></td>"+

"<td align='center' class='rumbo_cal_titulo'>"+arr_meses[dt_fecha.getMonth()]+" "+dt_fecha.getFullYear()+"</td>"+

"<td style='cursor: hand; cursor: pointer;' align='right' onclick='abrir_calendario(\"\",\""+que_formulario+"\",\""+que_calendario+"\",\""+fecha_a_fechastr(dt_fecha_mas_un_mes)+"\", \"mover\");'>"+
"<img border='0' src='imagenes/siguiente.gif' alt='mes siguiente' /></td>"+

					"</tr>"+
				"</table>"+
			"</td>"+
		"</tr>"+
		"<tr>"+
			"<td>"+
				"<table align='center' width='100%' class='rumbo_cal_dias_semana'>"+
					"<tr>"
	);

	var dt_dia_actual = new Date(dt_primer_dia_calendario);
	str_buffer += "<tr>";
	for (var n=0; n<7; n++)
	if(n==5||n==6)
	{
		str_buffer += "<td align='center' style='color: #FF3333;' >"+arr_dias_semana[(n_inicio_semana+n)%7]+"</td>";
	}
	else
	{
		str_buffer += "<td align='center'>"+arr_dias_semana[(n_inicio_semana+n)%7]+"</td>";
	}
		
	str_buffer += ("</tr>"+
			"</table>"+
		"</td>"+
	"</tr>"+
	"<tr>"+
		"<td>"+
			"<table class='rumbo_cal_tab_dias' align='center' width='100%'>");
	var solounavez = true;//solo pinto el número de día de hoy una vez
	while (dt_dia_actual.getMonth() == dt_fecha.getMonth() ||
		dt_dia_actual.getMonth() == dt_primer_dia_calendario.getMonth()) {
		// Imprimir cabecera columna
		str_buffer += "<tr>\n";
		for (var n_actual_dia_semana=0; n_actual_dia_semana<7; n_actual_dia_semana++) {
				
				if (dt_dia_actual.getDate() == dt_fecha.getDate() &&
					mes_hoy == mes_fecha && solounavez)
				{
					solounavez = false;
					// Imprimir hoy
					str_buffer += "	<td class=\"rumbo_dia_actual\" style='cursor: pointer; cursor: hand;' align=\"center\" ";
					str_buffer += " onclick='dia_calendario(\""+fecha_a_fechastr(dt_dia_actual)+"\",\""+que_formulario+"\",\""+que_calendario+"\")'> ";
				}
				else if (dt_dia_actual.getDay() == 0 || dt_dia_actual.getDay() == 6)
				{
					// Fines de semana
					if (( mes_hoy == mes_fecha )&&( dt_dia_actual < dt_fecha ))//si es día pasado deshabilito
					{
					str_buffer += "	<td class=\"rumbo_finde_deshabilitado\" align=\"center\" ";
					str_buffer += " > ";
					}	
					else
					{
					str_buffer += "	<td class=\"rumbo_finde\" style='cursor: pointer; cursor: hand;' align=\"center\" ";
					str_buffer += " onclick='dia_calendario(\""+fecha_a_fechastr(dt_dia_actual)+"\",\""+que_formulario+"\",\""+que_calendario+"\")'> ";
					}
				}
				else
				{
					// Días laborables del mes
					if (( mes_hoy == mes_fecha )&&( dt_dia_actual < dt_fecha ))//si es día pasado deshabilito
					{
					str_buffer += "	<td class=\"rumbo_laborables_deshabilitado\" align=\"center\" ";
					str_buffer += " > ";
					}	
					else
					{
					str_buffer += "	<td class=\"rumbo_laborables\" style='cursor: pointer; cursor: hand;' align=\"center\" ";
					str_buffer += " onclick='dia_calendario(\""+fecha_a_fechastr(dt_dia_actual)+"\",\""+que_formulario+"\",\""+que_calendario+"\")'> ";
					}
				}
				str_buffer += dt_dia_actual.getDate()+"</td>\n";
				dt_dia_actual.setDate(dt_dia_actual.getDate()+1);
		}
		// Imprimir pie columna
		str_buffer += "</tr>\n";
	}	
str_buffer += "</table></td></tr>";
	
	
	str_buffer += (
					"<tr>"+
						"<td>"+
							"<table align='center' width='100%' border='0'>"+
								"<tr>"+
									"<td align='center' colspan='2' class='rumbo_cal_cierre' style='cursor: pointer; cursor: hand;' onClick='cerrarCalendario();'>Cerrar</td>"+
								"</tr>"+
							"</table>"+
						"</td>"+
					"</tr>"+
				"</table>"
	);
	
	calendario.innerHTML =  str_buffer;
// Fin cadena calendario


  
    if(document.all){
	
	var x = window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	var y = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	
	}else{
			
			var x = e.pageX;
			var y = e.pageY;
		 }

y = y-'75';
x += 'px';
y += 'px';

// Solo definimos coordenadas calendario si es la primera vez. Porque las otras veces se queda en el mismo sitio.
if(!mover){
gualdrapa.style.left = x;	
gualdrapa.style.top = y;
calendario.style.left = x;	
calendario.style.top = y;
}

gualdrapa.style.display = 'inline';
calendario.style.display = 'inline';

}
function cerrarCalendario(){

var calendario = document.getElementById('rumbo_cal');
calendario.style.display = 'none';
var gualdrapa = document.getElementById('rumbo_gualdrapa');
gualdrapa.style.display = 'none';
}
function rumbo_vervuelos() {
    document.getElementById("rumbo_c450x300_hotel_id").style.display = "none";
    document.getElementById("rumbo_c450x300_vuelos_id").style.display = "";
    document.getElementById("rumbo_c450x300_vueloyhotel_id").style.display = "none";
}
function rumbo_verhoteles() {
    document.getElementById("rumbo_c450x300_hotel_id").style.display = "";
    document.getElementById("rumbo_c450x300_vuelos_id").style.display = "none";
    document.getElementById("rumbo_c450x300_vueloyhotel_id").style.display = "none";
}
function rumbo_vervh() {
    document.getElementById("rumbo_c450x300_hotel_id").style.display = "none";
    document.getElementById("rumbo_c450x300_vuelos_id").style.display = "none";
    document.getElementById("rumbo_c450x300_vueloyhotel_id").style.display = "";
}
function goSubmitVuelos () {

		var formulario = document.getElementById('rumbo_c450x300_vuelos');
		var origen =  formulario.depCity.value;
		var destino = formulario.arrCity.value;
		var bebes = parseInt(formulario.paxInf.value);
		var	ninios = parseInt(formulario.paxChd.value);
		var adultos = parseInt(formulario.paxAdt.value);
		var alerta = "";
		
		if (origen == ""){
		alerta = "Debe completar el campo Origen.\n";
		}
		if (destino == ""){
		alerta += "Debe completar el campo Destino.\n";
		}
		if (bebes > adultos){
		alerta += "El número de bebés no puede superar al de adultos.\n";
		}
		if ( (ninios+adultos) > 9 ){
		alerta += "El número total de adultos y niños no puede ser mayor que 9.";
		}
		if ( bebes+ninios > adultos*2){
		alerta += "El número de bebés y niños no puede superar al doble del número de adultos.";
		}
		if (alerta){
		alert(alerta);
		return;
		}
		formulario.depDate.value = formulario.fecha_dia_entrada_ida.value;
		formulario.depDate.value += "/";
		formulario.depDate.value += (formulario.fecha_mesanio_entrada_ida.value).substring(4,7);
		formulario.depDate.value += "/";
		formulario.depDate.value += (formulario.fecha_mesanio_entrada_ida.value).substring(0,4);

		formulario.retDate.value = formulario.fecha_dia_salida_vuelta.value;
		formulario.retDate.value += "/";
		formulario.retDate.value += (formulario.fecha_mesanio_salida_vuelta.value).substring(4,7);
		formulario.retDate.value += "/";
		formulario.retDate.value += (formulario.fecha_mesanio_salida_vuelta.value).substring(0,4);
		
		formulario.submit();
}
function goSubmitVH () {
		var formulario = document.getElementById('rumbo_c450x300_vueloyhotel');
		var origen =  formulario.depCity.value;
		var destino = formulario.arrCity.value;
		var bebes = parseInt(formulario.paxInf.value);
		var	ninios = parseInt(formulario.paxChd.value);
		var adultos = parseInt(formulario.paxAdt.value);
		var alerta = "";
		
		if (origen == ""){
		alerta = "Debe completar el campo Origen.\n";
		}
		if (destino == ""){
		alerta += "Debe completar el campo Destino.\n";
		}
		if (bebes > adultos){
		alerta += "El número de bebés no puede superar al de adultos.\n";
		}
		if ( (ninios+adultos) > 9 ){
		alerta += "El número total de adultos y niños no puede ser mayor que 9.";
		}
		if ( bebes+ninios > adultos*2){
		alerta += "El número de bebés y niños no puede superar al doble del número de adultos.";
		}
		if (alerta){
		alert(alerta);
		return;
		}
		formulario.depDate.value = formulario.fecha_dia_entrada_ida.value;
		formulario.depDate.value += "/";
		formulario.depDate.value += formulario.fecha_mesanio_entrada_ida.value.substring(4,7);
		formulario.depDate.value += "/";
		formulario.depDate.value += formulario.fecha_mesanio_entrada_ida.value.substring(0,4);

		formulario.retDate.value = formulario.fecha_dia_salida_vuelta.value;
		formulario.retDate.value += "/";
		formulario.retDate.value += formulario.fecha_mesanio_salida_vuelta.value.substring(4,7);
		formulario.retDate.value += "/";
		formulario.retDate.value += formulario.fecha_mesanio_salida_vuelta.value.substring(0,4);

		formulario.submit();
}
function goSubmitHoteles ()
{
	 formulario = document.getElementById('rumbo_c450x300_hotel');
	 var personas = formulario.paxHab.options[formulario.paxHab.selectedIndex].value;
     var nAdt = 0;
     var nChd = 0;
     if (personas == '1A0N')
     {
     	nAdt = 1;
     	nChd = 0;
     }
     if (personas == '2A0N')
     {
     	nAdt = 2;
     	nChd = 0;
     }
     if (personas == '3A0N')
     {
     	nAdt = 3;
     	nChd = 0;
     }
     if (personas == '2A1N')
     {
     	nAdt = 2;
     	nChd = 1;
     }
     if (personas == '2A2N')
     {
     	nAdt = 2;
     	nChd = 2;
     }
     if (personas == '3A1N')
     {
     	nAdt = 3;
     	nChd = 1;
     }

		formulario.paxAdt.value = nAdt;	
		formulario.paxChd.value = nChd;	

		formulario.depDate.value = formulario.fecha_mesanio_entrada_ida.value;
		formulario.depDate.value += formulario.fecha_dia_entrada_ida.value;

		formulario.retDate.value = formulario.fecha_mesanio_salida_vuelta.value;
		formulario.retDate.value += formulario.fecha_dia_salida_vuelta.value;
		
		formulario.submit();
}
function edadNinhos()
{	
	var	formulario = document.getElementById('rumbo_c450x300_hotel');
	var numHabitaciones = formulario.numRooms.value;
	var numNinhos = formulario.paxHab.value.substring(2,3);	//número de niños
	
	//todos los valores edad a 0
	
	formulario.child1.value = '';
	formulario.child2.value = '';
	formulario.child3.value = '';
	formulario.child4.value = '';
	formulario.child5.value = '';
	formulario.child6.value = '';
	formulario.child7.value = '';
	formulario.child8.value = '';
	formulario.child9.value = '';
	formulario.child10.value = '';
	
	//texto edades a 0
	
	document.getElementById("edades").innerHTML = '';
	document.getElementById("botonEdades").style.visibility = 'hidden';
	
	if(numNinhos!=0)//si hay niños
	{			
		document.getElementById("rellenarEdades").style.visibility = 'visible';
		document.getElementById("rellenarEdades").style.display = 'block';

		hab1 = document.getElementById("divHabitacion1");
		hab2 = document.getElementById("divHabitacion2");
		hab3 = document.getElementById("divHabitacion3");
		hab4 = document.getElementById("divHabitacion4");
		hab5 = document.getElementById("divHabitacion5");

		//se muestran habitaciones
		
		if (numHabitaciones =='1')
		{
			hab1.style.display = 'inline';
			hab2.style.display = 'none';
			hab3.style.display = 'none';
			hab4.style.display = 'none';
			hab5.style.display = 'none';
			
			habi1 = true;
			habi2 = false;
			habi3 = false;
			habi4 = false;
			habi5 = false;
			
			document.getElementById("rumbo_gualdrapa2").style.display = 'none';			
		}
		if (numHabitaciones =='2')
		{
			hab1.style.display = 'inline';
			hab2.style.display = 'inline';
			hab3.style.display = 'none';
			hab4.style.display = 'none';
			hab5.style.display = 'none';
			
			habi1 = true;
			habi2 = true;
			habi3 = false;
			habi4 = false;
			habi5 = false;
			
			document.getElementById("rumbo_gualdrapa2").style.display = 'inline';
			document.getElementById("rumbo_gualdrapa2").style.height = '132px';
		}
		if (numHabitaciones =='3')
		{
			hab1.style.display = 'inline';
			hab2.style.display = 'inline';
			hab3.style.display = 'inline';
			hab4.style.display = 'none';
			hab5.style.display = 'none';
			
			habi1 = true;
			habi2 = true;
			habi3 = true;
			habi4 = false;
			habi5 = false;
			
			document.getElementById("rumbo_gualdrapa2").style.display = 'inline';	
			document.getElementById("rumbo_gualdrapa2").style.height = '162px';
		}
		if (numHabitaciones =='4')
		{
			hab1.style.display = 'inline';
			hab2.style.display = 'inline';
			hab3.style.display = 'inline';
			hab4.style.display = 'inline';
			hab5.style.display = 'none';
			
			habi1 = true;
			habi2 = true;
			habi3 = true;
			habi4 = true;
			habi5 = false;
			
			document.getElementById("rumbo_gualdrapa2").style.display = 'inline';	
			document.getElementById("rumbo_gualdrapa2").style.height = '195px';			
		}
		if (numHabitaciones =='5')
		{
			hab1.style.display = 'inline';
			hab2.style.display = 'inline';
			hab3.style.display = 'inline';
			hab4.style.display = 'inline';
			hab5.style.display = 'inline';
			
			habi1 = true;
			habi2 = true;
			habi3 = true;
			habi4 = true;
			habi5 = true;
			
			document.getElementById("rumbo_gualdrapa2").style.display = 'inline';	
			document.getElementById("rumbo_gualdrapa2").style.height = '225px';			
		}

		var nino1 = document.getElementById('ninho1');
		var nino2 = document.getElementById('ninho2');
		var nino3 = document.getElementById('ninho3');
		var nino4 = document.getElementById('ninho4');
		var nino5 = document.getElementById('ninho5');
		var nino6 = document.getElementById('ninho6');
		var nino7 = document.getElementById('ninho7');
		var nino8 = document.getElementById('ninho8');
		var nino9 = document.getElementById('ninho9');
		var nino10 = document.getElementById('ninho10');

		if (numNinhos == '0') // Todos los campos ocultos
		{
			nino1.style.display = 'none';
			nino2.style.display = 'none';
			nino3.style.display = 'none';
			nino4.style.display = 'none';
			nino5.style.display = 'none';
			nino6.style.display = 'none';
			nino7.style.display = 'none';
			nino8.style.display = 'none';
			nino9.style.display = 'none';
			nino10.style.display = 'none';
			
			nin1 = false;
			nin2 = false;
			nin3 = false;
			nin4 = false;
			nin5 = false;
			nin6 = false;
			nin7 = false;
			nin8 = false;
			nin9 = false,
			nin10 = false;
		}
		if (numNinhos == '1') // Mostramos solo la edad del primer hijo
		{
			nino1.style.display = 'inline';
			nino2.style.display = 'none';
			nino3.style.display = 'inline';
			nino4.style.display = 'none';
			nino5.style.display = 'inline';
			nino6.style.display = 'none';
			nino7.style.display = 'inline';
			nino8.style.display = 'none';
			nino9.style.display = 'inline';
			nino10.style.display = 'none';
			
			nin1 = true;
			nin2 = false;
			nin3 = true;
			nin4 = false;
			nin5 = true;
			nin6 = false;
			nin7 = true;
			nin8 = false;
			nin9 = true;
			nin10 = false;
			
			if (numHabitaciones == '2')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '135px';	
			}
			if (numHabitaciones == '3')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '165px';	
			}
			if (numHabitaciones == '4')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '195px';	
			}
			if (numHabitaciones == '5')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '225px';	
			}			
		}
		if (numNinhos == '2') // Mostramos la edad de los dos hijos
		{
			nino1.style.display = 'inline';
			nino2.style.display = 'inline';
			nino3.style.display = 'inline';
			nino4.style.display = 'inline';
			nino5.style.display = 'inline';
			nino6.style.display = 'inline';
			nino7.style.display = 'inline';
			nino8.style.display = 'inline';
			nino9.style.display = 'inline';
			nino10.style.display = 'inline';

			nin1 = true;
			nin2 = true;
			nin3 = true;
			nin4 = true;
			nin5 = true;
			nin6 = true;
			nin7 = true;
			nin8 = true;
			nin9 = true;
			nin10 = true;
			
			if (numHabitaciones == '2')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '170px';	
			}
			if (numHabitaciones == '3')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '220px';	
			}
			if (numHabitaciones == '4')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '250px';	
			}
			if (numHabitaciones == '5')
			{
				document.getElementById("rumbo_gualdrapa2if").style.height = '270px';	
			}
		}			
	}
	else
	{
		document.getElementById("rellenarEdades").style.visibility = 'hidden';
		document.getElementById("rellenarEdades").style.display = 'none';
		document.getElementById("botonEdades").style.visibility = 'hidden';
	}
}
function aceptarEdadesNinos()
{	
	formulario = document.getElementById('rumbo_c450x300_hotel');
	var edades = 'Edades: '
	var	texto_edad;
	
	var n = '1';
	for (i=1; i<=5; i++)
	{
		if( (eval("habi"+i)) )
		{
			if( (eval("nin"+n))&&(eval("formulario.child"+n+".value")) )//Si presentamos celda para el primer niño de la habitación y tiene valor
			{
			    if (!/^([0-9])*$/.test(eval("formulario.child"+n+".value")))
				{
   				   var mensajec ="No es un número";
  				}
				if(eval("formulario.child"+n+".value") > 11)
				{
					var mensajeb = "Es mayor de 11 años";
				}
				texto_edad = eval("formulario.child"+n+".value");
				edades = edades+"("+texto_edad+")";
			}
			if ( (eval("nin"+n))&&!(eval("formulario.child"+n+".value")) )//Si faltó por introducir algún valor 
			{
				var mensaje = "Falta rellenar la edad de algún niño";
			}
			n++;
			if( (eval("nin"+n))&&(eval("formulario.child"+n+".value")) )//Si presentamos celda para el segundo niño de la habitación y tiene valor
			{
				if (!/^([0-9])*$/.test(eval("formulario.child"+n+".value")))
				{
   				   var mensajec ="No es un número";
  				}
				if(eval("formulario.child"+n+".value") > 11)
				{
					var mensajeb = "Es mayor de 11 años";
				}
				texto_edad = eval("formulario.child"+n+".value");
				edades = edades+"("+texto_edad+")";
			}
			if ( (eval("nin"+n))&&!(eval("formulario.child"+n+".value")) )//Si faltó por introducir algún valor 
			{
				var mensaje = "Falta rellenar la edad de algún niño";
			}
		}
		n++;
	}
	if (mensaje)
	{
		alert(mensaje);
		var fallo = true;
	}
	if (mensajeb)
	{
		alert(mensajeb);
		var fallo = true;		
	}
	if (mensajec)
	{
		alert(mensajec);
		var fallo = true;		
	}
	if (!fallo)
	{
		document.getElementById("rellenarEdades").style.visibility = 'hidden';
		document.getElementById("rellenarEdades").style.display = 'none';
		document.getElementById("rumbo_gualdrapa2").style.display = 'none';
		//pintamos la capa de las edades
		var capaPintarEdades = document.getElementById("edades");
		var botoncambioedades = document.getElementById("botonEdades");
		capaPintarEdades.style.visibility = 'visible';
		capaPintarEdades.style.display = 'block';	
		botoncambioedades.style.visibility = 'visible';
		
		capaPintarEdades.innerHTML = edades;
	}
}
function rumbo_crear_fechas(idform,direccion) {
	if (direccion == "entrada_ida")
	{
    document.write('<input type="hidden" name="depDate" value="" />');
	}
	if (direccion == "salida_vuelta")
	{
    document.write('<input type="hidden" name="retDate" value="" />');
	}
    var tabla_meses = new Array('Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic');
    var tabla_dias = new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	var fecha_hoy = new Date();
	var dia_actual = fecha_hoy.getDate();
	var mes_actual = fecha_hoy.getMonth ();
    var anio_actual = fecha_hoy.getFullYear ();
		var numero_dias_mes = rumbo_dame_numero_dias_mes(anio_actual,mes_actual);// salida >>
    var nombre_dia = tabla_dias[dia_actual];
	var nombre_mes = tabla_meses[mes_actual];
	var anio_corto = anio_actual.toString().substring(2,4);

	document.writeln('<select class="rumbo_c450x300_select" name="fecha_dia_'+direccion+'">');
		 				for (i = dia_actual; i <= numero_dias_mes; i++){
        				var j = (i < 10) ? "0"+i : i; 
         				document.write('<option value='+j+'>'+j+'<\/option>');
						}
	document.write('<\/select>&nbsp;');

    document.writeln('<select class="rumbo_c450x300_select" name="fecha_mesanio_'+direccion+'"');
	document.writeln('onChange="actualizar_meses(\''+idform+'\',\''+direccion+'\');">');
    document.write('<option value='+rumbo_dame_valor_aniomes(anio_actual,mes_actual)+' selected="selected">'+nombre_mes+' '+anio_corto+'<\/option>');
         var i = mes_actual + 1;
         if (mes_actual == 0){
              j = 11;
         } else{ 
            j = mes_actual - 1;
         }
		 // 13 meses en presentar
         for (k=1; k < 13; k++){
           			if (i == 12){
            		i = 0;
					anio_actual+=1;
            		anio_corto = anio_actual.toString().substring(2,4);
           			}          			
	 			 	nombre_mes = tabla_meses[i];
         			document.write(' <option value='+rumbo_dame_valor_aniomes(anio_actual,i)+'>'+nombre_mes+' '+anio_corto+'<\/option>');
         			i++;
          }
	document.write('<\/select>');
}
function rumbo_dame_numero_dias_mes(anio_actual, mes_actual){
  		var mes_siguiente = new Date();
  		mes_siguiente.setFullYear(anio_actual,mes_actual + 1,0);
  		return (mes_siguiente.getDate());
}
function rumbo_dame_valor_aniomes(anio, mes){
  var val_anio = anio.toString();
	mes++;
  var val_mes = mes.toString();
  
  if (mes < 10){
     val_mes = "0" + val_mes;
  }
  return val_anio+val_mes;
}
function soloidavuelos(idform,idavuelta,ida) {
	
	var formulario = document.getElementById(idform);
	var iv = idavuelta;
	var i = ida;
	
	if(document.getElementById(iv).checked)
	{
		formulario.fecha_mesanio_salida_vuelta.disabled = false;
		formulario.fecha_dia_salida_vuelta.disabled = false;
		formulario.fecha_mesanio_salida_vuelta.style.background = "";	
		formulario.fecha_dia_salida_vuelta.style.background = "";		
	}
	if(document.getElementById(i).checked)
	{
		formulario.fecha_mesanio_salida_vuelta.disabled = true;
		formulario.fecha_dia_salida_vuelta.disabled = true;
		formulario.fecha_mesanio_salida_vuelta.style.background = "#088DD6";	
		formulario.fecha_dia_salida_vuelta.style.background = "#088DD6";
	}

}
function actualizar_meses (idform,direccion) {

var	formulario = document.getElementById(idform);

//cogemos valores fecha actual
var dt_fecha = new Date();
var anio = dt_fecha.getFullYear().toString();
var dia = dt_fecha.getDate().toString();
var mes = (dt_fecha.getMonth()+1).toString();
if (mes < 10)
{
mes = 0+mes;//meses con 0 por delante
}
//cogemos valores fecha selección
var indice_dia_selec = eval("formulario.fecha_dia_"+direccion+".options.selectedIndex");
var valor_indice_dia_selec = eval("formulario.fecha_dia_"+direccion+".options[indice_dia_selec].value");
var mesanio_selec = eval("formulario.fecha_mesanio_"+direccion+".options.selectedIndex");
var valor_mesanio_selec = eval("formulario.fecha_mesanio_"+direccion+".options[mesanio_selec].value");


	for (i=1; i<=31 ;i++ )
	{
		var j=i;
		if (j<10)
		{
		j="0"+j;//para valores menores que 10 - 0 por delante
		}
		if (j == valor_indice_dia_selec)
		{
		eval("formulario.fecha_dia_"+direccion+".options[i-1] = new Option (j,j,'defauldSelected')");
		}
		else
		{	
		eval("formulario.fecha_dia_"+direccion+".options[i-1] = new Option (j,j)");
		}
		j++;
	}
	return;



}	
function cerrarEdades()
{	
	var	formulario = document.getElementById('rumbo_c450x300_hotel');
	document.getElementById("rumbo_gualdrapa2").style.display = 'none';
	document.getElementById("rellenarEdades").style.visibility = 'hidden';
	document.getElementById("rellenarEdades").style.display = 'none';
	document.rumbo_c450x300_hotel.paxHab.value = '2A0N';
	for(i=1; i<=10; i++)
	{
		eval("formulario.child"+i+".value = ''");
	}
	document.getElementById("edades").innerHTML = '';
}