
function mostrarDivisa(moneda) {
	if(moneda=="libra"){
		alert("You have selected Sterling Pounds");
	}else if(moneda=="dolar"){
		alert("You have selected US Dollars");
	}else if(moneda=="euro"){
		alert("You have selected Euro");
	}
}

function explicarHorasLlegada() {
	var hora = document.forms.formulario.hora.value;
	var minutos = document.forms.formulario.minutos.value;
	if(hora==00){
		document.forms.formulario.explicacion.value="midnight";
		alert("midnight");
	}else if(hora>=00 && hora <=07){
		document.forms.formulario.explicacion.value="early hours of morning"
		alert("early hours of morning");
	}else if(hora>=08 && hora <12){
		document.forms.formulario.explicacion.value="morning"
	}else if(hora==12 && minutos==00){
		document.forms.formulario.explicacion.value="noon"
	}else if(hora>=12 && hora <17){
		document.forms.formulario.explicacion.value="afternoon"
	}else if(hora>=17 && hora <20){
		document.forms.formulario.explicacion.value="evening"
	}else if(hora>=20 && hora <=23){
		document.forms.formulario.explicacion.value="night"
	}
}

function explicarHorasSalida() {
	var hora = document.forms.formulario.horaV.value;
	var minutos = document.forms.formulario.minutosV.value;
	if(hora==00){
		document.forms.formulario.explicacionV.value="midnight";
		alert("midnight");
	}else if(hora>=00 && hora <=07){
		document.forms.formulario.explicacionV.value="early hours of morning"
		alert("early hours of morning");
	}else if(hora>=08 && hora <12){
		document.forms.formulario.explicacionV.value="morning"
	}else if(hora==12 && minutos==00){
		document.forms.formulario.explicacionV.value="noon"
	}else if(hora>=12 && hora <17){
		document.forms.formulario.explicacionV.value="afternoon"
	}else if(hora>=17 && hora <20){
		document.forms.formulario.explicacionV.value="evening"
	}else if(hora>=20 && hora <=23){
		document.forms.formulario.explicacionV.value="night"
	}
}

function cambiarPasajerosVuelta(){

	for (var i = 0; i < 50; i++) {
		document.forms.formulario.pasajerosVuelta.options[0] = null;
	}
	for (var i = 1; i < 51; i++) {
		document.forms.formulario.pasajerosVuelta.options[i-1] = new Option(i,i);
		if(i==document.forms.formulario.pasajerosIda.options[document.forms.formulario.pasajerosIda.selectedIndex].value){
			document.forms.formulario.pasajerosVuelta.options[i-1].selected = true;
		}
	}
}

function openWindow(ancho,alto,ruta){
	ventana = window.open(ruta,"Ficha","scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,copyhistory=no,width="+ancho+",height="+alto+",top=100,left=100,");
    ventana.focus();
    document.returnValue = false;
}

function siguiente(dia,mes,ano,numDiasMesIni,horaEEUU,minEEUU) {

origen=document.forms.formulario.origen.selectedIndex; 
destino=document.forms.formulario.destino.selectedIndex; 
if(origen > -1 && destino > -1){
 temp=document.forms.formulario.origen.options[origen].value.split("-");
 nombreOrigen=temp[1];
 nombreDestino=document.forms.formulario.destino.options[destino].value;
}

if(document.forms.formulario.origen.options[origen].text=="Origin" ||
	document.forms.formulario.destino.options[destino].text=="Destination"){

	 nombreOrigen=-1;
	 nombreDestino=-1;
}
pasajerosIda=document.forms.formulario.pasajerosIda.options[document.forms.formulario.pasajerosIda.selectedIndex].value;
pasajerosVuelta=document.forms.formulario.pasajerosVuelta.options[document.forms.formulario.pasajerosVuelta.selectedIndex].value;

valorYearMes=document.forms.formulario.year.options[document.forms.formulario.year.selectedIndex].value.split('/');
anoI=parseInt(valorYearMes[1]); 
mesI=parseInt(valorYearMes[0]);
diaI=parseInt(document.forms.formulario.day.options[document.forms.formulario.day.selectedIndex].value);

hora = parseInt(document.forms.formulario.hora.options[document.forms.formulario.hora.selectedIndex].value);
horaV = parseInt(document.forms.formulario.horaV.options[document.forms.formulario.horaV.selectedIndex].value);
minutos = parseInt(document.forms.formulario.minutos.options[document.forms.formulario.minutos.selectedIndex].value);
minutosV = parseInt(document.forms.formulario.minutosV.options[document.forms.formulario.minutosV.selectedIndex].value);

explicarHorasLlegada();
explicarHorasSalida();

if(document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value!=-1){
	valorYearMes=document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value.split('/');
	anoF=parseInt(valorYearMes[1]); 
	mesF=parseInt(valorYearMes[0]);
}else{
	anoF=-1;mesF=-1;
}
diaF=parseInt(document.forms.formulario.dayF.options[document.forms.formulario.dayF.selectedIndex].value);
//alert(diaI+"/"mesI+"/"+anoI+" "+hora+":"+minutos+" "+diaF+"/"mesF+"/"+anoF+" "+horaV+":"+minutosV);

if(nombreOrigen==-1){
	alert("Error, you must choose a point of departure.!!!");
}
else if(nombreDestino==-1){
	alert("Error, you must choose a point of arrival.!!!");
}

else if(anoI < ano){
	alert("Error selecting year on arrival date!!!");
}
else if(anoI==ano && mesI < mes){
	alert("Error selecting month on arrival date!!!");
}
else if(anoI==ano && mesI==mes && diaI < dia){
	alert("Error selecting the day of arrival date!!. You must choose since "+dia+"th");
}

else if(mesF!=-1 && diaF==-1){
	alert("Error selecting the day of return!!.");
}
else if(mesF!=-1 && anoI==anoF && mesF<mesI){
	alert("Error selecting the month of return. You must choose a return date after arrival");
}
else if(mesF!=-1 && diaF!=-1 && anoI==anoF && mesF==mesI && diaF<diaI){
	alert("Error selecting the day of return. You must choose a return date after arrival.");
}
else if(mesF!=-1 && anoF < ano){
	alert("Error selecting year of return.!!");
}
else if(mesF!=-1 && anoF < anoI){
	alert("Error selecting year of return. You must choose a return date after arrival.");
}
else if(mesF!=-1 && anoF==ano && mesF < mes){
	alert("Error selecting month of return date.!!");
}
else if(mesF==-1 && diaF!=-1){
	alert("Error on the date of return. You must choose a month.!!");
}
else if(mesF!=-1 && diaF!=-1 && mesF==mesI && parseInt(diaF)==parseInt(diaI) && anoI==anoF && 
	horaV<=hora){
	alert("Error selecting the time of return. You must choose a return time after arrival");
}
else if(mesF!=-1 && diaF!=-1 && mesF==mesI && parseInt(diaF)==parseInt(diaI) && anoI==anoF && 
	hora==horaV && minutosV<minutos){
	alert("Error selecting the time of return. You must choose a return time after arrival");
}
else if(mesF!=-1 && diaF!=-1 && mesF==mesI && parseInt(diaF)==parseInt(diaI) && anoI==anoF){
	if(mesF!=-1 && diaF!=-1){
		document.forms["formulario"].elements["tipo"].value = "vuelta";	
	}else{
		document.forms["formulario"].elements["tipo"].value = "ida";
	}
	document.forms["formulario"].action="getnow.php";
	if(pasajerosIda!=pasajerosVuelta &&
		document.forms["formulario"].elements["tipo"].value=="vuelta"){

		if (window.confirm("You have selected a different number of people for your return transfer.\n"+
			"A different mode of transport may be required, and variations in price will be shown accordingly.\n"+
			"All prices are inclusive totals.\n"+
			"To change the number of people travelling, press CANCEL.\n"+
			"To continue, press OK.")){

			if (window.confirm("Your outbound and return transfer are on the same day.\n"+
				"Is such a short trip intentional?\n"+
				"To change, press CANCEL.\n"+
				"To continue, press OK.")){

				document.forms["formulario"].submit();
			}

		}
	}else{
		if (window.confirm("Your outbound and return transfer are on the same day.\n"+
			"Is such a short trip intentional?\n"+
			"To change, press CANCEL.\n"+
			"To continue, press OK.")){

			document.forms["formulario"].submit();
		}
	}
}

else{
	if(mesF!=-1 && diaF!=-1){
		document.forms["formulario"].elements["tipo"].value = "vuelta";	
	}else{
		document.forms["formulario"].elements["tipo"].value = "ida";
	}
	document.forms["formulario"].action="getnow.php";
	if(pasajerosIda!=pasajerosVuelta &&
		document.forms["formulario"].elements["tipo"].value=="vuelta"){

		if (window.confirm("You have selected a different number of people for your return transfer.\n"+
			"A different mode of transport may be required, and variations in price will be shown accordingly.\n"+
			"All prices are inclusive totals.\n"+
			"To change the number of people travelling, press CANCEL.\n"+
			"To continue, press OK.")){

			document.forms["formulario"].submit();
		}
	}else{
		document.forms["formulario"].submit();
	}
}	

}
//En esta funcion lo que hago es recoger los valores del combo year
//y hago un split del valor ya que trae el mes y el aÃ±o seleccionado
function populate(objForm,yearActual,mesActual,diaActual, yearSelected) {

valorYearMes=document.forms.formulario.year.options[document.forms.formulario.year.selectedIndex].value.split('/');
valorMes=valorYearMes[0];
valorYear=valorYearMes[1];
timeA = new Date(valorYear,valorMes,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
var daysInMonth = timeB.getDate();
if(yearSelected==1){
	temp=document.forms.formulario.day.length;
	for (var i = 0; i < temp; i++) {
		document.forms.formulario.day.options[0] = null;
	}
}
	if(parseInt(valorMes)==parseInt(mesActual) && parseInt(yearActual)==parseInt(valorYear)){
		for (var i = diaActual,x=0; i <= daysInMonth; i++,x++) {
			if(i==diaActual+2){
			  document.forms.formulario.day.options[x] = new Option(i,i,"defaultSelected");
			}else{
			  document.forms.formulario.day.options[x] = new Option(i,i);
			}
		}
		if(document.forms.formulario.day.length>=3){
			document.forms.formulario.day.options[2].selected = true;
		}
	}else{
		for (var i = 0; i < daysInMonth; i++) {
			if(i==0){
			  document.forms.formulario.day.options[i] = new Option(i+1,i+1,"defaultSelected");
			}else{
			  document.forms.formulario.day.options[i] = new Option(i+1,i+1);
			}  
		}
	}	
}


function populateF(objForm,yearActual,mesActual,diaActual,yearSelected) {
if(document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value!=-1){
	valorYearMes=document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value.split('/');
	valorMes=valorYearMes[0];
	valorYear=valorYearMes[1];
	timeA = new Date(valorYear,valorMes,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	if(yearSelected==1){
		temp=document.forms.formulario.dayF.length;
		for (var i = 0; i < temp; i++) {
			document.forms.formulario.dayF.options[0] = null;
		}
	}
	if(parseInt(valorMes)==parseInt(mesActual) && parseInt(yearActual)==parseInt(valorYear)){
		for (var i = diaActual,x=0; i <= daysInMonth; i++,x++) {
			if(i==(diaActual+2)){
			  document.forms.formulario.dayF.options[x] = new Option(i,i,"defaultSelected");
			}else{
			  document.forms.formulario.dayF.options[x] = new Option(i,i);
			}
		}
		if(document.forms.formulario.dayF.length>=3){
			document.forms.formulario.dayF.options[2].selected = true;
		}
	}else{
		for (var i = 0; i < daysInMonth; i++) {
			if(i==0){
			  document.forms.formulario.dayF.options[i] = new Option(i+1,i+1,"defaultSelected");
			}else{
			  document.forms.formulario.dayF.options[i] = new Option(i+1,i+1);
			}  
		}
	}	
}else{
	temp=document.forms.formulario.dayF.length;
	for (var i = 0; i < temp; i++) {
		document.forms.formulario.dayF.options[0] = null;
	}
	document.forms.formulario.dayF.options[0] = new Option("no",-1);
	document.forms.formulario.dayF.options[0].selected = true;
}}
window.onLoad = populateF;

//En esta funcion lo que hago es recoger los valores del combo year
//y hago un split del valor ya que trae el mes y el aÃ±o seleccionado
//Esta funcion es utilizada en el primer paso de los hoteles para obtener
//la fecha de entrada
function populateHotel(objForm,yearActual,mesActual,diaActual,yearSelected) {

valorYearMes=document.forms.formulario.year.options[document.forms.formulario.year.selectedIndex].value.split('/');
valorMes=valorYearMes[0];
valorYear=valorYearMes[1];
timeA = new Date(valorYear,valorMes,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
var daysInMonth = timeB.getDate();
if(yearSelected==1){
	temp=document.forms.formulario.day.length;
	for (var i = 0; i < temp; i++) {
		document.forms.formulario.day.options[0] = null;
	}
}
	if(parseInt(valorMes)==parseInt(mesActual) && parseInt(yearActual)==parseInt(valorYear)){
		for (var i = diaActual,x=0; i <= daysInMonth; i++,x++) {
			if(i==diaActual+1){
			  document.forms.formulario.day.options[x] = new Option(i,i,"defaultSelected");
			}else{
			  document.forms.formulario.day.options[x] = new Option(i,i);
			}
		}
		if(document.forms.formulario.day.length>=2){
			document.forms.formulario.day.options[1].selected = true;
		}
	}else{
		for (var i = 0; i < daysInMonth; i++) {
			if(i==0){
			  document.forms.formulario.day.options[i] = new Option(i+1,i+1,"defaultSelected");
			}else{
			  document.forms.formulario.day.options[i] = new Option(i+1,i+1);
			}
		}
	}
	cambiarFechaSalidaAlojamiento(objForm);
}

//Esta función va a cambir la fecha de salida del alojamiento
//Se utiliza en el paso 1 del hotel
function cambiarFechaSalidaAlojamiento(objForm){
	valorYearMes=document.forms.formulario.year.options[document.forms.formulario.year.selectedIndex].value.split('/');
	valorDia=document.forms.formulario.day.options[document.forms.formulario.day.selectedIndex].value.split('/');
	valorMes=valorYearMes[0];
	valorYear=valorYearMes[1];
	timeEntrada = new Date(valorYear,valorMes-1,parseInt(valorDia));
	dia = parseInt(valorDia)+7;
	timeSalida = new Date(valorYear,valorMes-1,dia);

	//Aqui preselecciono el año de salida del alojamiento
	mes = parseInt(timeSalida.getMonth())+1;
	temp=document.forms.formulario.yearF.length;
	for (var i = 0; i < temp; i++) {
		valores = document.forms.formulario.yearF.options[i].value.split('/');
		if(parseInt(valores[0])==mes && parseInt(valores[1])==parseInt(timeSalida.getFullYear())){
			document.forms.formulario.yearF.options[i].selected = true;
		}else{
			document.forms.formulario.yearF.options[i].selected = false;
		}
	}
	//Aqui preselcciono el dia de salida del alojamiento
	diaEntrada=parseInt(document.forms.formulario.day.options[document.forms.formulario.day.selectedIndex].value);
	var diasMes = timeSalida.getDate();

	//Antes de nada vacío ese combo
	temp=document.forms.formulario.dayF.length;
	for (var i = 0; i < temp; i++) {
		document.forms.formulario.dayF.options[0] = null;
	}

	//Compruebo si la suma de los siete dias esta dentro del mes de entrada
	diaFinMes = numeroDiasMes(parseInt(timeSalida.getFullYear()),mes);
	if(parseInt(timeSalida.getMonth())==parseInt(timeEntrada.getMonth())){
		for (var i = 0,x=1,diaInicio=diaEntrada+1; diaInicio <= diaFinMes; i++,x++,diaInicio++) {
			if(x==7){
			  document.forms.formulario.dayF.options[i] = new Option(diaInicio,diaInicio,"defaultSelected");
			}else{
			  document.forms.formulario.dayF.options[i] = new Option(diaInicio,diaInicio);
			}
		}
	}else{
		for (var i = 0; i < diaFinMes; i++) {
			if((i+1)==diasMes){
			  document.forms.formulario.dayF.options[i] = new Option(i+1,i+1,"defaultSelected");
			}else{
			  document.forms.formulario.dayF.options[i] = new Option(i+1,i+1);
			}
		}
	}	
}

//En esta funcion lo que hago es recoger los valores del combo year
//y hago un split del valor ya que trae el mes y el aÃ±o seleccionado
//Esta funcion es utilizada en el primer paso de los hoteles, para obtener la
//fecha de salida
function populateFHotel(objForm,yearActual,mesActual,diaActual,yearSelected) {

if(document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value!=-1){
	valorYearMes=document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value.split('/');
	valorMes=valorYearMes[0];
	valorYear=valorYearMes[1];
	timeA = new Date(valorYear,valorMes,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();

	temp=document.forms.formulario.dayF.length;
	for (var i = 0; i < temp; i++) {
		document.forms.formulario.dayF.options[0] = null;
	}

	if(parseInt(valorMes)==parseInt(mesActual) && parseInt(yearActual)==parseInt(valorYear)){
		for (var i = diaActual,x=0; i <= daysInMonth; i++,x++) {
			if(x==0){
			  document.forms.formulario.dayF.options[x] = new Option(i,i,"defaultSelected");
			}else{
			  document.forms.formulario.dayF.options[x] = new Option(i,i);
			}
		}
	}else{
		for (var i = 0; i < daysInMonth; i++) {
			if(i==0){
			  document.forms.formulario.dayF.options[i] = new Option(i+1,i+1,"defaultSelected");
			}else{
			  document.forms.formulario.dayF.options[i] = new Option(i+1,i+1);
			}
		}
	}
}else{
	temp=document.forms.formulario.dayF.length;
	for (var i = 0; i < temp; i++) {
		document.forms.formulario.dayF.options[0] = null;
	}
}}

function paso2Hotel(url){

	valorYearMes=document.forms.formulario.year.options[document.forms.formulario.year.selectedIndex].value.split('/');
	mesI=parseInt(valorYearMes[0]);
	anoI=parseInt(valorYearMes[1]);
	diaI=parseInt(document.forms.formulario.day.options[document.forms.formulario.day.selectedIndex].value);
	valorYearMes=document.forms.formulario.yearF.options[document.forms.formulario.yearF.selectedIndex].value.split('/');
	mesF=parseInt(valorYearMes[0]);
	anoF=parseInt(valorYearMes[1]);
	diaF=parseInt(document.forms.formulario.dayF.options[document.forms.formulario.dayF.selectedIndex].value);

	if(document.forms.formulario.nombreDestino.value==""){
		alert("Error, you must choose a destination.!!!");
	}else if(mesF!=-1 && anoI==anoF && mesF<mesI){
		alert("Error selecting outbound month. You must choose a return month later than your outbound.");
	}else if(mesF!=-1 && diaF!=-1 && anoI==anoF && mesF==mesI && diaF<diaI){
		alert("Error selecting outbound day. You must choose a return day later than your outbound.");
	}else if(mesF!=-1 && anoF < anoI){
		alert("Error selecting outbound year. You must choose a return year later than your outbound.");
	}else if(mesF==mesI && diaF==diaI && anoI==anoF){
		alert("Error selecting outbound day. You must choose a return day later than your outbound.");
	}else{	
		document.forms["formulario"].action="hotels2.php";
		winOpen(url);
		document.forms["formulario"].submit();
	}
}

function nuevaBusquedaPaso2Hotel(url){

	if(document.forms.formulario.fechaInicio.value==""){
		alert("Error, you must indicate a incoming date");
	}else if(document.forms.formulario.fechaFin.value==""){
		alert("Error, you must indicate a outgoing date");
	}else if(document.forms.formulario.fechaInicio.value.length!=10){
		alert("Error, the date format is: dd/mm/yyyy");
	}else if(document.forms.formulario.fechaFin.value.length!=10){
		alert("Error, the date format is: dd/mm/yyyy");
	}else{
		fechaI=document.forms.formulario.fechaInicio.value.split('/');
		fechaF=document.forms.formulario.fechaFin.value.split('/');
	
		diaI=fechaI[0];
		mesI=fechaI[1];
		anoI=fechaI[2];

		diaF=fechaF[0];
		mesF=fechaF[1];
		anoF=fechaF[2];

		if(fechaI.length!=3 || fechaF.length!=3){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(isNaN(diaI)){
			alert("Error, the date can't have letter, the date format is: dd/mm/yyyy");
		}else if(isNaN(mesI)){
			alert("Error, the date can't have letter, the date format is: dd/mm/yyyy");
		}else if(isNaN(anoI)){
			alert("Error, the date can't have letter, the date format is: dd/mm/yyyy");
		}else if(isNaN(diaF)){
			alert("Error, the date can't have letter, the date format is: dd/mm/yyyy");
		}else if(isNaN(mesF)){
			alert("Error, the date can't have letter, the date format is: dd/mm/yyyy");
		}else if(isNaN(anoF)){
			alert("Error, the date can't have letter, the date format is: dd/mm/yyyy");
		}else if(diaI>31){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(mesI>12){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(anoI<2004 || anoI>2006){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(diaF>31){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(mesF>12){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(anoF<2004 || anoF>2006){
			alert("Error, the date format is: dd/mm/yyyy");
		}else if(mesF!=-1 && anoI==anoF && mesF<mesI){
			alert("Error selecting the month of outgoing. You must choose a return month after incoming");
		}else if(mesF!=-1 && diaF!=-1 && anoI==anoF && mesF==mesI && diaF<diaI){
			alert("Error selecting the day of outgoing. You must choose a return date after incoming.");
		}else if(mesF!=-1 && anoF < anoI){
			alert("Error selecting the year of outgoing. You must choose a return date after incoming.");
		}else if(mesF==mesI && diaF==diaI && anoI==anoF){
			alert("Error selecting the day of outgoing. You must choose a return date after incoming.");
		}else if(mesF==mesI && diaF==diaI && anoI==anoF){
			alert("Error selecting the day of outgoing. You must choose a return date after incoming.");
		}else{	
			document.forms.formulario.nuevaBusqueda.value="1";
			document.forms["formulario"].action="hotels2.php";
			winOpen(url);
			document.forms["formulario"].submit();
		}
	}
}

function cambiarPaginaResultados(numPagina){
	document.forms.formulario.pagina.value=numPagina;
	document.forms["formulario"].action="hotels2.php";
	document.forms["formulario"].submit();
}

//ESTAS DOS FUNCIONES NOS MOSTRARAN HOJAS INTERMEDIAS DE BUSQUEDA
function winOpen(url)
{
	win=window.open(url,'sss','scrollbars=no,toolbar=no,location=no,directories=no,status=no,resizable=no,copyhistory=no,fullscreen');
 	win.self.focus();
}
function winClose(url)
{
	win=window.open(url,'sss');
	win.close();
}

//Esta funcion comprueba si un aÃ±o es bisiesto
function esBisiesto(anyo){
	if((anyo%4==0 || anyo%400==0) && anyo%100!=0){
		res=true;
	} else {
		res=false;
	}
	return res;
}


//Esta funcion devuelve el numero de dias del mes
function numeroDiasMes(anyo,mes){
	if(mes==1){
		num=31;
	} else if(mes==2){
		if(esBisiesto(anyo)){
			num=29;
		}else {
			num=28;
		}
	} else if(mes==3){
		num=31;
	} else if(mes==4){
		num=30;
	} else if(mes==5){
		num=31;
	} else if(mes==6){
		num=30;
	} else if(mes==7){
		num=31;
	} else if(mes==8){
		num=31;
	} else if(mes==9){
		num=30;
	} else if(mes==10){
		num=31;
	} else if(mes==11){
		num=30;
	} else if(mes==12){
		num=31;
	}
	return num;
}

//  End -->
function cargarDestinoDesdeLink(indiceO,indiceD,formulario){
	document.forms.formulario.origen.options[indiceO+1].selected = true;
	num = formulario.destino.length;
	for (var i = 0; i < num; i++) {
		formulario.destino.options[0] = null;
	}
	for (var i = 0; i < matrizId[indiceO].length; i++) {
		formulario.destino.options[i] = new Option(matrizNombre[indiceO][i],matrizId[indiceO][i]);
	}
	document.forms.formulario.destino.options[indiceD].selected = true;
}

function ocultarVisualizarCapas(visible,capa){
	if(visible==0){
		document.getElementById(capa).style.visibility="hidden";
	}else{
		document.getElementById(capa).style.visibility="visible";
	}
}

function descripcionViaje(descripcionTipoViaje, descripcionServicio, tipoViaje){
	mensaje = "-"+descripcionTipoViaje+"\n";
	if(descripcionServicio!=""){
		mensaje = mensaje+"-"+descripcionServicio;
	}
	alert(mensaje);
	document.forms.formulario.tipoViaje[tipoViaje].checked = true;
}

function horas(){
	alert("This is the time of your flights arrival or departure time at the airport.");
}

function seleccionTipoViaje(){
	//Si el usuario no ha seleccionado nada, selecciono un tipo de viaje posible por defecto
	tipo="";
	for(x=0;x<document.forms.formulario.tipoViaje.length;x++){
		if(document.forms.formulario.tipoViaje[x].checked){
			tipo=document.forms.formulario.tipoViaje[x].value;
			break;
		}
	}
	if(tipo==""){
		for(x=0;x<document.forms.formulario.tipoViaje.length;x++){
			if(!document.forms.formulario.tipoViaje[x].disabled){
				document.forms.formulario.tipoViaje[x].checked=true;
				return;
			}
		}
	}
}

function comprobarPrecio(siguientePaso){
  if (!document.forms.formulario.tipoViaje[0].checked &&
      !document.forms.formulario.tipoViaje[1].checked &&
      !document.forms.formulario.tipoViaje[2].checked){

      alert("No availability. Please contact us on phone: (0034) 966830101");
  }else{
		document.forms.formulario.action=siguientePaso;	
		document.forms.formulario.submit();
  }
}
function overTD(td,color){td.bgColor=color;}
function outTD(td,color){td.bgColor=color;}

function mostrarPrecioCombo2CajaTexto(objForm,precio,precioBaseTraslado,combo,cajaTexto,precioT,numExtras){
	cajaTexto.value=parseFloat(combo.options[combo.selectedIndex].value) * parseFloat(precio);
	precio=cajaTexto.value.split(".");
	if(precio.length==1){
		cajaTexto.value = cajaTexto.value+".00";	
	}else if(precio[1].length>2){
		cajaTexto.value = precio[0]+"."+precio[1].substring(0,2);
	}

	//Recorro todos los extras para ir sumando las cantidades
	for(x=1;x<numExtras+1;x++){
		precioBaseTraslado=parseFloat(precioBaseTraslado) + parseFloat(objForm["precioExtra"+x].value);
	}
	precio=precioBaseTraslado.toString().split(".");
	precioT.value=precioBaseTraslado;
	if(precio.length==1){
		precioT.value = precio[0]+".00";	
	}else if(precio[1].length>2){
		precioT.value = precio[0]+"."+precio[1].substring(0,2);
	}
}