function showAdultos(strForm) {

	if (!(typeof strForm != 'undefined')) {
		strForm = 'frmPaquete';
	}
	
	tipo = '';
	
	obj_val = document.getElementById("tipo_activo");

	if (obj_val != null) {
		tipo = obj_val.value;
	}	
	
	eval("objForm = this.document."+strForm+";");

	var cantidadAdultos = objForm.totalAdultos.value;

	for(i=1;i<=totalSelectAdultos;i++) {
	
		strIDName = "datosAdulto"+tipo+i;

		var tableId = this.document.getElementById(strIDName);

		if (i <= cantidadAdultos) {
			
			tableId.style.display = 'block';

		} else {
		
			tableId.style.display = 'none';

		}
	
	}

}

function ShowCardTypes(obj) {
	
	var tipo_tarjeta_s = obj.value;
	
	if (tipo_tarjeta_s != '-')
	{
		document.getElementById("datos_tarjetas").style.display = 'block';
		document.getElementById("notapie").style.display = 'none';
	
		if (tipo_tarjeta_s == "Nacional Colombia" || tipo_tarjeta_s == "Nacional Aventura") {
			document.getElementById("tipo_activo").value = 'N';
			document.getElementById("top_nacional").style.display = 'block';
			document.getElementById("datos_salida").style.display = 'block';
			document.getElementById("notapie").style.display = 'block';
			HideAll("I");		
		}
		if (tipo_tarjeta_s == "Internacional") {
			document.getElementById("tipo_activo").value = 'I';
			document.getElementById("top_nacional").style.display = 'none';
			document.getElementById("datos_salida").style.display = 'none';
			HideAll("N");		
		}	
		showAdultos('frmTarjeta');
	}
	else
	{
		document.getElementById("datos_tarjetas").style.display = 'none';
	}
}

function HideAll(tipo) {
	
	for(i=1;i<=totalSelectAdultos;i++) {
	
		var tableId = this.document.getElementById("datosAdulto"+tipo+i);
	
		tableId.style.display = 'none';
		
	}
	
}

function showNinos(strForm) {

	if (!(typeof strForm != 'undefined')) {
		strForm = 'frmPaquete';
	}

	eval("objForm = this.document."+strForm+";");

	var cantidadNinos = objForm.totalNinos.value;

	for(i=1;i<=totalSelectNinos;i++) {
	
		var tableId = this.document.getElementById("datosNino"+i);
	
		if (i <= cantidadNinos) {
			
			tableId.style.display = 'block';
		
		} else {
		
			tableId.style.display = 'none';
		
		}
	
	}

}

//Este script y otros muchos pueden
//descarse on-line de forma gratuita
//en El Código: www.elcodigo.net
//
//	Version 1
//	03/02/2001

function DiferenciaFechas (strFecha1, strFecha2) {

   //Obtiene los datos del formulario
   CadenaFecha1 = strFecha1;
   CadenaFecha2 = strFecha2;
   
   //Obtiene dia, mes y año
   var fecha1 = new fecha( CadenaFecha1 )   
   var fecha2 = new fecha( CadenaFecha2 )
   
   //Obtiene objetos Date
   var miFecha1 = new Date( fecha1.anio, fecha1.mes, fecha1.dia )
   var miFecha2 = new Date( fecha2.anio, fecha2.mes, fecha2.dia )

   //Resta fechas y redondea
   var diferencia = miFecha1.getTime() - miFecha2.getTime()
   var dias = Math.floor(diferencia / (1000 * 60 * 60 * 24))
   var segundos = Math.floor(diferencia / 1000)
   
 //  alert ('La diferencia es de ' + dias + ' dias,\no ' + segundos + ' segundos.')
   
   return dias;
   
   //return false
}

function fecha( cadena ) {

   //Separador para la introduccion de las fechas
   var separador = "/"

   //Separa por dia, mes y año
   if ( cadena.indexOf( separador ) != -1 ) {
	   // 1983/01/21
        var posi1 = 0
        var posi2 = cadena.indexOf( separador, posi1 + 1 )
        var posi3 = cadena.indexOf( separador, posi2 + 1 )
		
       /* this.anio = cadena.substring( posi1, posi2 )
        this.mes = cadena.substring( posi2 + 1, posi3 )
        this.dia = cadena.substring( posi3 + 1, cadena.length )*/

        this.dia = cadena.substring( posi1, posi2 )
        this.mes = cadena.substring( posi2 + 1, posi3 )
        this.anio = cadena.substring( posi3 + 1, cadena.length )
		
   } else {
        this.dia = 0
        this.mes = 0
        this.anio = 0   
   }
}

function ContarNoches() {

	var nochesval = DiferenciaFechas(document.frmPaquete.fecha_salida.value, document.frmPaquete.fecha_llegada.value);
	
	if (nochesval < 0) {
		nochesval = 0;	
	}
	
	document.frmPaquete.noches.value = nochesval;
	
	setTimeout("ContarNoches()", 1000);
}

function ContarTotalNoches(formulario, objsalida, objllegada, objnoches, int_incremento) {

	if (!(typeof int_incremento != 'undefined')) {
		int_incremento = 0;
	}

	eval("var fecha_inicial = document." + formulario +" ."+objsalida+".value;");
	eval("var fecha_final = document." + formulario +" ."+objllegada+".value;");	

	var nochesval = DiferenciaFechas(fecha_inicial, fecha_final);
	
	if (nochesval >= 0) {
		nochesval = nochesval + int_incremento;
	}
	
	if (nochesval < 0) {
		nochesval = 0;	
	}
	
	eval("document." + formulario + "."+objnoches+".value = nochesval;");
	
	var functcall = "ContarTotalNoches('"+formulario+"', '"+objsalida+"', '"+objllegada+"', '"+objnoches+"', "+int_incremento+")";
	
	setTimeout(functcall, 1000);
	
}

function ValidarFecha() {

	// Validar la fecha de solicitud
	
	if (DiferenciaFechas(document.frmPaquete.fecha.value, fechaToday) < 0) {
		alert('La fecha de solicitud debe superior o igual a la actual '+'('+fechaToday+')');
		return false;
	}

	// Validar fecha de llegada
	
	var diferencia = DiferenciaFechas(document.frmPaquete.fecha_llegada.value, fechaToday);

	if (diferencia < 0) {
		alert('La fecha de llegada debe ser superior a la fecha actual '+'('+fechaToday+')');
		return false;
	}
	
	// Validar fecha de llegada y fecha de salida
	
	if (DiferenciaFechas(document.frmPaquete.fecha_salida.value, document.frmPaquete.fecha_llegada.value) <= 0) {
		alert('La diferencia entre fecha de llegada y fecha de salida \ndebe de ser de más de un día');
		return false;
	}
	
	return true;

}


function ValidarSoloSolicitud() {

	if (DiferenciaFechas(document.frmPaquete.fecha.value, fechaToday) < 0) {
		alert('La fecha de solicitud debe superior o igual a la actual '+'('+fechaToday+')');
		return false;
	}
	
}

function ValidarFechaMsg(strDateFrom, strDateTo, strMsg) {
	
	if (DiferenciaFechas(strDateTo, strDateFrom) > 0) {
		alert(strMsg);
		return false;
	}
	
	return true;	
	
}

function ValidarEspFechas() {
	
	if (!(ValidarFechaMsg(document.frmEspectaculo.fecha.value,fechaToday, 'La fecha de solicitud debe ser mayor que la fecha actual ('+fechaToday+')'))) {
		return false;
	}
	
	return ValidarFechaMsg(document.frmEspectaculo.fecha_solicitada.value,fechaToday, 'La fecha solicitada debe ser mayor que la fecha actual ('+fechaToday+')');	
	
}

function ValidarFechasCircuito() {

	// Validar la fecha de solicitud
	
	if (DiferenciaFechas(document.frmCircuito.fecha.value, fechaToday) < 0) {
		alert('La fecha de solicitud debe superior o igual a la actual '+'('+fechaToday+')');
		return false;
	}

	// Validar fecha de llegada
	
	var diferencia = DiferenciaFechas(document.frmCircuito.fecha_solicitada.value, fechaToday);

	if (diferencia < 0) {
		alert('La fecha solicitada debe ser superior a la fecha actual '+'('+fechaToday+')');
		return false;
	}	

}

function ValidarFechasFrancia() {

	// Validar la fecha de solicitud
	
	if (DiferenciaFechas(document.frmPaquete.fecha.value, fechaToday) < 0) {
		alert('La fecha de solicitud debe superior o igual a la actual '+'('+fechaToday+')');
		return false;
	}

}

function ValidarFechasTarjeta() {

	// Validar la fecha de solicitud
	
	if (DiferenciaFechas(document.frmTarjeta.fecha_salida.value, fechaToday) < 0) {
		alert('La fecha de salida debe superior o igual a la actual '+'('+fechaToday+')');
		return false;
	}

	// Validar solicitud con la de regreso
	
	if (DiferenciaFechas(document.frmTarjeta.fecha_regreso.value, document.frmTarjeta.fecha_salida.value) <= 0) {
		alert('La diferencia entre fecha de salida y fecha de regreso \ndebe de ser de más de un día');
		return false;
	}

}

function ValidarVehiculo() {
	
	// Validar la fecha de recogida
	
	if (DiferenciaFechas(document.frmVehiculo.fecha_recogida.value, fechaToday) < 0) {
		alert('La fecha de recogida debe superior o igual a la actual '+'('+fechaToday+')');
		return false;
	}
	
	// Validar solicitud con la de entrega
	
	if (DiferenciaFechas(document.frmVehiculo.fecha_entrega.value, document.frmVehiculo.fecha_recogida.value) <= 0) {
		alert('La diferencia entre fecha de entrega y fecha de recogida \ndebe de ser de más de un día');
		return false;
	}	
	
}

function chooseOption(obj) {
	if (obj.value == "Traslado de Salida") {
		document.getElementById('t_salida').style.display = 'block';
		document.getElementById('t_llegada').style.display = 'none';
	}
	if (obj.value == "Traslado de Llegada") {
		document.getElementById('t_llegada').style.display = 'block';
		document.getElementById('t_salida').style.display = 'none';
	}
}

function fillSelectTerminales(obj) {
	var valor = obj.value;
	objfill = "terminal_llegada";	
	
	ResetSelect(objfill);
	//alert(obj.name + " - " +objfill);
	if (valor == 'PARIS - ORLY') {
		strTerminals = 'SUD###SUD|OUEST###OUEST';
	} else 	if (valor == 'PARIS - CHARLES DE GAULLE') {
		strTerminals = 'CDG - 1###CDG - 1|CDG - 2 A###CDG - 2 A|CDG - 2 B###CDG - 2 B|CDG - 2 D###CDG - 2 D|CDG - 2 E###CDG - 2 E|CDG - 2 F###CDG - 2 F|CDG - 3###CDG - 3';
	} else {
		strTerminals = '-###[ - ]';
	}
	
	FillSelectFromArray(objfill, strTerminals);
}

function fillSelectOpcion(obj) {
	var valor = obj.value;
	ResetSelect('opcion');
	document.getElementById("opcion_tr").style.display = 'none';
	document.getElementById("nota").style.display = 'none';
	document.getElementById("hotel_option").style.display = 'none';	
	if (valor == 'Gratis') {
		//strDatos = 'Traslado de llegada Aeropuerto Charles de Gaulle hasta el hotel seleccionado###Traslado de llegada Aeropuerto Charles de Gaulle hasta el hotel seleccionado|Tour de Paris con recogida en el hotel###Tour de Paris con recogida en el hotel|Tour Nocturno Iluminaciones de Paris con recogida en su hotel###Tour Nocturno Iluminaciones de Paris con recogida en su hotel';
		strDatos = new Array('Traslado de llegada', 'Tour de París', 'Tour nocturno iluminaciones de París');
		document.getElementById("opcion_tr").style.display = 'block';
		document.getElementById("nota").style.display = 'block';
	} else 	if (valor == 'Opcion x 30 Euros') {
		//strDatos = 'Visita al Castillo de Versailles###Visita al Castillo de Versailles|Tour de Montmartre - Torre Eiffel y Crucero por el sena###Tour de Montmartre - Torre Eiffel y Crucero por el sena|Crucero Río Sena e Iluminaciones de Paris###Crucero Río Sena e Iluminaciones de Paris';
		strDatos = new Array('Visita al Castillo de Versailles', 'Tour de Montmartre', 'Torre Eiffel y Crucero por el Sena', 'Crucero río Sena mas iluminaciones de Paris');
		document.getElementById("opcion_tr").style.display = 'block';
		document.getElementById("nota").style.display = 'block';
	} else 	if (valor == 'Hotel') {
		document.getElementById("hotel_option").style.display = 'block';
	} else {		
		strDatos = new Array('[ - ]');
	}
	
	FillSelectArray('opcion', strDatos);
}

function enableOtherHotel(obj) {
	if (obj.value == '-') {
		document.getElementById("otro_hotel").disabled = false;
	} else {
		document.getElementById("otro_hotel").disabled = true;
	}
}

function FillHotelParque() {

	var v_parque = document.frmParque.parque.value;
	var v_tipo_hotel = document.frmParque.tipo_hotel.value;
	
	ResetSelect('hotel');
	
	var arrDatos = new Array('[ - ]');
	
	if (v_parque == 'Disney') {
		this.document.getElementById('tipo_hotel').style.display = 'block';
	} else {
		this.document.getElementById('tipo_hotel').style.display = 'none';
	}
	
	if (v_parque == 'Disney' && v_tipo_hotel == 'Hoteles Cuatro Estrellas') {
		arrDatos = new Array('Disneyland Hotel','Disney’s Hotel New York','Viena Internacional Dream Castle','Holiday Inn','Radisson SAS Hotel');
	} 
	if (v_parque == 'Disney' && v_tipo_hotel == 'Hoteles Primera') {
		arrDatos = new Array('Disney´s Hotel New Port Bay Club','Disney´s Sequoia Lodge','Hotel L´Elysées Val D´Europe','My Travels Explorer Hotel');
	} 
	if (v_parque == 'Disney' && v_tipo_hotel == 'Hoteles Familiares') {
		arrDatos = new Array('Disney´s Hotel Cheyenne','Disney’s Hotel Santa Fé','Disney´s Davy Crockett Ranch','Kyriad Hotel ( Dos Estrellas )');
	}
	if (v_parque == 'Futuroscope') {
		//arrDatos = new Array('Hôtel des Trois Hiboux','Hôtel Partenaires');
		arrDatos = new Array('Hotel Du Futuroscope *', 'Hotel Du Parc *', 'Hotel Express By Holiday Inn **', 'Hotel Campanile Futuroscope **', 'Comfort Hotel Alteora **', 'Hotel Ibis Futuroscope **', 'Hotel Mercure Aquatis ***', 'Hotel Novotel Futuroscope ***', 'Quality Hotel Alteora ***', 'Hotel Plaza ***', 'Hotel Top Club Plaza **');
	}
	if (v_parque == 'Parque Asterix') {
		arrDatos = new Array('Hôtel des Trois Hiboux', 'Hôtel Partenaires');

	}	
		
	FillSelectArray('hotel', arrDatos);
}