var groups=8; 
var group=new Array(groups);
for (i=0; i<groups; i++)
group[i]=new Array();

group[0][0]=new Option("seleccione...","");

group[1][0]=new Option("Gran Canaria","LPA");
group[1][1]=new Option("La Palma","SPC");
group[1][2]=new Option("Fuerteventura","FUE");
group[1][3]=new Option("Lanzarote","ACE");
group[1][4]=new Option("El Hierro","VDE");
//group[0][4]=new Option(unescape("Marrakech"),"RAK");

//group[2][0]=new Option("La Palma","SPC");
//group[2][1]=new Option("Gran Canaria","LPA");
//group[2][2]=new Option("Fuerteventura","FUE");
//group[2][3]=new Option("Lanzarote","ACE");


group[2][0]=new Option("Tenerife Norte","TFN");
//group[2][1]=new Option("Tenerife Sur","TFS");
group[2][1]=new Option("La Palma","SPC");
group[2][2]=new Option("Fuerteventura","FUE");
group[2][3]=new Option("Lanzarote","ACE");
group[2][4]=new Option("El Hierro","VDE");
//group[2][4]=new Option(unescape("El Aaiún"),"EUN");
//group[2][5]=new Option(unescape("Marrakech"),"RAK");

group[3][0]=new Option("Tenerife Norte","TFN");
//group[4][1]=new Option("Tenerife Sur","TFS");
group[3][1]=new Option("Gran Canaria","LPA");
group[3][2]=new Option("Fuerteventura","FUE");
group[3][3]=new Option("Lanzarote","ACE");
group[3][4]=new Option("El Hierro","VDE");
//group[3][5]=new Option(unescape("Marrakech"),"RAK");

group[4][0]=new Option("Tenerife Norte","TFN");
group[4][1]=new Option("Gran Canaria","LPA");
group[4][2]=new Option("La Palma","SPC");
group[4][3]=new Option("Lanzarote","ACE");
group[4][4]=new Option("El Hierro","VDE");
//group[4][4]=new Option(unescape("Marrakech"),"RAK");

group[5][0]=new Option("Tenerife Norte","TFN");
group[5][1]=new Option("Gran Canaria","LPA");
group[5][2]=new Option("La Palma","SPC");
group[5][3]=new Option("Fuerteventura","FUE");
group[5][4]=new Option("El Hierro","VDE");
//group[5][4]=new Option(unescape("Marrakech"),"RAK");
//group[6][0]=new Option("Gran Canaria","LPA");

group[6][0]=new Option("Tenerife Norte","TFN");
group[6][1]=new Option("Gran Canaria","LPA");
group[6][2]=new Option("La Palma","SPC");
group[6][3]=new Option("Fuerteventura","FUE");
group[6][4]=new Option("Lanzarote","ACE");




function copiaDNI (pasajero, valor){
if ((document.getElementById('passengers['+pasajero+'].document.type').value=="d" ) || (document.getElementById('passengers['+pasajero+'].document.type').value=="t" ))
		document.getElementById('passengers['+pasajero+'].auth.number').value=valor;
	else
		document.getElementById('passengers['+pasajero+'].auth.number').value="";
	
}

function seleccionarcombotarifa(combo,elemento) {
   var cantidad = combo.length;
   for (i = 0; i < cantidad; i++) {
	   valor=combo[i].value.split("#");
      if (valor[0] == elemento) {
         combo[i].selected = true;
      }   
   }
}

function seleccionar(combo,elemento) {
   var cantidad = combo.length;
   for (i = 0; i < cantidad; i++) {
      if (combo[i].value == elemento) {
         combo[i].selected = true;
      }   
   }
}

function muestraidentificacion (){
		
	 aux='<table width="200" border="0">';
     aux+=' <tr>';
     aux+='        <td colspan="2"><select name="TipoDoc" id="TipoDoc" >';
     aux+='          <option value="-2">Seleccione...</option>';
     aux+='          <option value="-1">N PAS.FRECUENTE</option>';
     aux+='          <option value="1">DNI</option>';
     aux+='          <option value="2">NIE</option>';
     aux+='          <option value="3">PASAPORTE</option>';
     aux+='          <option value="4">CIF</option>';
	 aux+='          <option value="5">N AGENTE</option>';	 
     aux+='          </select></td>';
     aux+='        </tr>';
     aux+='      <tr>';
     aux+='        <td>Usuario:</td>';
     aux+='        <td><input name="Tusuario" id="Tusuario" class="box_nar" size="11" type="text" /></td>';
     aux+='        </tr>';
     aux+='      <tr>';
     aux+='        <td>Contrase&ntilde;a</td>';
     aux+='        <td><input name="Tpassword" id="Tpassword" class="box_nar" size="11" type="password" /></td>';
     aux+='      </tr>';
     aux+='    </table>';
	 return aux;
}
/*******************************************************/

function sumatasas (tarifa,indice,tasas,numplazas){
							for (ic=1; ic<=document.getElementById(tarifa+indice).length-1; ic++) {
								icimporte=document.getElementById(tarifa+indice).options[ic].value.split("#");
								icimporte[1]=redondear(icimporte[1]*1+tasas*numplazas);
								document.getElementById(tarifa+indice).options[ic].text+=" | "+icimporte[1] +" €"; 
								document.getElementById(tarifa+indice).options[ic].value+="#"+tasas;
								//document.getElementById(tarifa+indice).options[ic].value+="-"+vtasas;
							}
						}

/*******************************************************/

function generanumerosa (tipo, literal){

	var comboAdultoR=document.getElementById(tipo).options[document.getElementById(tipo).selectedIndex].value;
	aux='';
			if (comboAdultoR != ''){
			
			for (i=1;i<=comboAdultoR*1;i++){
aux+='<tr><td>'+literal+' '+i+'</td>';
aux+='<td><select name="datosFamilia'+tipo+'['+i+']" id="datosFamilia'+tipo+'['+i+']">';
aux+='<option value="ADTDC">'+txt7+'</option>';
aux+='<option value="ADTDCF1">'+txt8+'</option>';
aux+='<option value="ADTDCF2">'+txt9+'</option>';
aux+='</select><td></tr>';
			}
}
			return aux;
}

/*********************************************************/

function familianumerosa (valor){
	if (valor==1)
		document.getElementById("numerosaenvio").innerHTML="<table>"+generanumerosa("txtAdultoR",txt1)+generanumerosa("txtNinoR",txt2)+generanumerosa("txtBebeR",txt3)+generanumerosa("txtAdultoNR",txt4)+generanumerosa("txtNinoNR",txt5)+generanumerosa("txtBebeNR",txt6)+"</table>";
	else
		document.getElementById("numerosaenvio").innerHTML="";
}

/**********************************************************/

function paso1 (){
		document.getElementById('DisponibilidadVuelo').style.display='block';
		document.getElementById('PlandeVuelo').style.display='none';
}

/***********************************************************/
function getCondicionesTarifa(fare, tipo, aliasfare){

 if (aliasfare != 0) 
 	fare = aliasfare;

 if (tipo == 'ida') { 			
	document.getElementById("condTarifaIda").innerHTML='<a href="javascript:v=window.open(\'condicionestarifa.php?fare='+ fare + '&idioma=es\', \'tAndCIda\', \'width=720,height=500,resizable=no,scrollbars=yes\');v.focus();"><strong>Ver condiciones de la tarifa de Ida</strong></a><br />';
 } else {
	
	document.getElementById("condTarifaVuelta").innerHTML='<a href="javascript:v=window.open(\'condicionestarifa.php?fare='+ fare + '&idioma=es\', \'tAndCVuelta\', \'width=720,height=500,resizable=no,scrollbars=yes\');v.focus();"><strong>Ver condiciones de la tarifa de Vuelta</strong></a><br />';
 }
}

function getCondicionesExtra(fare) {
		
	
		switch (fare) {
			case "TZZ":
			case "TCD":
			case "LUOW":
			case "WMILAC":
			case "WMILAC1":			
			case "WMILAC2":
			case "OERCOW":
				document.getElementById("cond1").innerHTML = "<br>Como en alguno de los tramos he elegido una tarifa con condiciones especiales: Tarifa Universitaria, Militar, Universal, 60 Plus o Joven, me comprometo a presentar la documentación correspondiente o en caso contrario ISLAS me denegará el embarque con ese billete.<br>";
			break;
			
			
			case "EPROMO":
			case "E2PROMO":
				document.getElementById("cond2").innerHTML = "<br>En alguno de los tramos he seleccionado la tarifa ADULTO+NIÑO GRATIS, cuyas condiciones son:<br>* El niño debe ir acompañado por un adulto mayor de 18 años.<br>* Todos los pasajeros incluidos en la búsqueda/reserva se acogerán a las condiciones de la tarifa.<br><br><b>NOTA: Realice compras por separado para aquellos adultos que no deseen las condiciones especiales de la Tarifa Adulto+Niños Gratis</b>";
				break;
				
			
			case "XOLD":
			case "X2OLD":
				document.getElementById("cond2").innerHTML = "<br>En alguno de los tramos he seleccionado la tarifa ADULTO+ADULTO MAYOR DE 60 GRATIS, cuyas condiciones son:<br>* Al menos un Adulto deberá tener 60 años o más.<br>* Deberán viajar juntos todos los tramos.";
				break;
			
		} 
	
	return;
}


function paso2 (tipoida, tipovuelta){
	var error="";

	opcionIda = tarifaseleccionada(tipoida);

	
	if (opcionIda < 0)  
		error="Debe Seleccionar tarifa para el vuelo de ida.\n";
	else {			
		var comboIda = document.getElementById('tarifa'+tipoida+opcionIda).options[document.getElementById('tarifa'+tipoida+opcionIda).selectedIndex].value.split("#");
	
		document.getElementById("cond1").innerHTML = "";
		document.getElementById("cond2").innerHTML = "";
		getCondicionesExtra(comboIda[0]);
		getCondicionesTarifa(comboIda[0], 'ida', comboIda[6]);
	
		if (tipovuelta != "") {
			opcionVuelta =  tarifaseleccionada(tipovuelta);
			if (opcionVuelta < 0)
				error+="Debe Seleccionar tarifa para el vuelo de vuelta.\n";
			/******************************************************************/	
			///if ((opcionIda >= 0) && (opcionVuelta >=0)) {
			else {			
				var comboVuelta = document.getElementById('tarifa'+tipovuelta+opcionVuelta).options[document.getElementById('tarifa'+tipovuelta+opcionVuelta).selectedIndex].value.split("#");
				

				if ((comboIda[5] > 99) || (comboVuelta[5] > 99)) {
					if ((comboIda[5] == comboVuelta[5]) || (comboVuelta[5] == 0) || (comboIda[5] == 0)){
					}else{
						error+="Las tarifas seleccionadas NO son combinables.\n\nPor favor, elija la misma tarifa tanto a la ida como a la vuelta\npara poder continuar su compra.";
					}
				} else if (comboIda[5] != comboVuelta[5]) 
						error+="Las tarifas seleccionadas NO son combinables.\n\nPor favor, elija la misma tarifa tanto a la ida como a la vuelta\npara poder continuar su compra.";
					
				if (error == "") {	
				/***añadido hertz***/
					if (document.getElementById('datoscoche') != undefined) {
						if (farebasishertz[comboVuelta[0]]==1){
							document.getElementById("datoscoche").style.display="";					
							document.getElementById("cochehertzpost").value=1;
							document.getElementById("aceptoCondicionesRC").className="R";
							document.getElementById("hrecogida").className="R";
							document.getElementById("hdevolucion").className="R";										
							document.getElementById("Calle").className="R";										
							document.getElementById("Poblacion").className="R";										
							document.getElementById("Localidad").className="R";										
							document.getElementById("CP").className="R";																														
						}
						else{
							document.getElementById("datoscoche").style.display="none";
							document.getElementById("cochehertzpost").value=0;		
							document.getElementById("aceptoCondicionesRC").className="";
							document.getElementById("hrecogida").className="";
							document.getElementById("hdevolucion").className="";		
							document.getElementById("Calle").className="";										
							document.getElementById("Poblacion").className="";										
							document.getElementById("Localidad").className="";										
							document.getElementById("CP").className="";																														
						}
					}
					/****/
					getCondicionesExtra(comboVuelta[0]);
					getCondicionesTarifa(comboVuelta[0], 'vuelta', comboVuelta[6]);
				}
		
			}
			/*******************************************************************/	
		}
	}
	
	
	if (error == "") {
		if (comboIda[7] != 0)  {
			if (document.getElementById('role').value == "")
				error+="Debe utilizar su usuario y contraseña de pasajero frecuente para poder comprar esta tarifa.";
		}
	}
	
	
	
	if (error != "")
		alert (error);
	else {
		document.getElementById('DisponibilidadVuelo').style.display='none';
		document.getElementById('PlandeVuelo').style.display='block';
		window.scroll(0,0);
	}
}


/**************************************************/

function redondear(num)      { 		
var original=parseFloat(num); 		
var result=Math.round(original*100)/100 ; 		
return result; 	
}

/***************************************************/

function seleccionarcombo (combo, opcion){
	
 for(ii=0;ii<document.getElementById(combo).options.length;ii++){
        if(document.getElementById(combo).options[ii].value == opcion){
            document.getElementById(combo).options[ii].selected=true;
        }
    }	
}

/**************************************************/

function redirect(x,temp){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}

/**************************************/

var numvuelo = new Array();
var fechade = new Array();
var origen = new Array();
var destino = new Array();
var horasalida = new Array();
var horallegada = new Array();
var stasas = new Array();

var numvuelov = new Array();
var fechadev = new Array();
var origenv = new Array();
var destinov = new Array();
var horasalidav = new Array();
var horallegadav = new Array();
var stasasv = new Array();

var ntarifas = new Array(2);
var vofertas = new Array(2);
vofertas[0]=0;
vofertas[1]=0;

var vofertasfee = new Array(2);
vofertasfee[0]=0;
vofertasfee[1]=0;

var vtasas = new Array(2);
vtasas[0]=0;
vtasas[1]=0;

var vcond = new Array(2);
vcond[0]=0;
vcond[1]=0;


var vmostrar = new Array(2);
vmostrar[0]=0;
vmostrar[1]=0;


var vtarifas = new Array(2);
vtarifas[0]=0;
vtarifas[1]=0;

var vfees = new Array(2);
vfees[0]=999;
vfees[1]=999;



/***************************************************/

function buscartarifa (tipo,vector, farebasis,salida){
		
for (i=0;i<vector.length;i++)
	if ((vector[i][0]==tipo) && (vector[i][1]==farebasis)){
		/*if  (salida==3)
			return redondear(vector[i][salida]*1-vector[i][5]*1);
		else{
			return redondear(vector[i][salida]*1);
		}*/
		return redondear(vector[i][salida]*1);
	}
}


/***************************************************/

function buscarfee (tipo,tarifa, farebasis,oferta){


	Fee=buscartarifa ('ida',tarifa, ntarifas[0],3);
//	alert (Fee);
	if (tipo=='vuelta'){
		FeeVuelta=buscartarifa ('vuelta',tarifa, ntarifas[1],3);
		if (((FeeVuelta < Fee) && (FeeVuelta != 0)) || Fee==0) {				
			if (oferta==1)
				Fee=FeeVuelta-buscartarifa ('vuelta',tarifa, ntarifas[1],5);
			else
				Fee=FeeVuelta;
		}
		else {
		//	alert (Fee);
			if (oferta==1)
				Fee=Fee-buscartarifa ('ida',tarifa, ntarifas[0],5);
		}
	}
	else if (tipo=='ida'){
		if (oferta==1)
				Fee=Fee-buscartarifa ('ida',tarifa, ntarifas[0],5);
	}
	return Fee;
}

/*****************************************************/

/*
function tarifaseleccionada (tipo){
	
	var combo="";
	var ultimaopcion=document.getElementsByName("vuelo"+tipo)[document.getElementsByName("vuelo"+tipo).length-1].value;
resta=1;
    for (i=1;i<=ultimaopcion;i++)
	if (document.getElementById('fila'+tipo+i)){
		if ((document.getElementsByName("vuelo"+tipo)[i-resta].checked)&& (document.getElementById('tarifa'+tipo+i).options[document.getElementById('tarifa'+tipo+i).selectedIndex].value != "") )
		 	return true;			
		}
else
			resta++; 
	return false;
}*/

function tarifaseleccionada (tipo){
	
	var combo="";
	var ultimaopcion=document.getElementsByName("vuelo"+tipo)[document.getElementsByName("vuelo"+tipo).length-1].value;
resta=1;
    for (i=1;i<=ultimaopcion;i++)
	if (document.getElementById('fila'+tipo+i)){
		if ((document.getElementsByName("vuelo"+tipo)[i-resta].checked)&& (document.getElementById('tarifa'+tipo+i).options[document.getElementById('tarifa'+tipo+i).selectedIndex].value != "") )
		 	return (i);			
		}
else
			resta++; 
	return -1;
}

/****************************************************/

function marcafila(tipo,opcion,ntarifas,vtarifas,vtasas,vofertas,TAr,TNr,TBr,TA,TN,TB,TArt1,TNrt1,TBrt1,TAt1,TNt1,TBt1,TArt2,TNrt2,TBrt2,TAt2,TNt2,TBt2,NumPlazas){
	
var i;
var j=0;
var fechasalida="";
var fechallegada="";
document.getElementById('opcion'+tipo).value=opcion;

if (document.getElementById('opcionida').value != "")
	fechasalida=fechade[document.getElementById('opcionida').value][0]*1;
	
if (document.getElementById('opcionvuelta').value != "")
	fechallegada=fechadev[document.getElementById('opcionvuelta').value][0]*1;

if (fechasalida==fechaactual){
	vhorasalida=horasalida[document.getElementById('opcionida').value][0].split(":");
	
minutossalida=vhorasalida[0]*60+vhorasalida[1]*1;

	if (minutossalida <= minutosactual+rango){
		alert ("Debe hacer la reserva con al menos 1 hora antes de la salida del vuelo. Contacte con 902 477 478 para obtener más información");  
		document.getElementById('tarifa'+tipo+opcion).selectedIndex=0;
		return;
	}
}
if (fechasalida==fechallegada){

	if (horasalidav[document.getElementById('opcionvuelta').value][0] <= horallegada[document.getElementById('opcionida').value][numvuelo[document.getElementById('opcionida').value].length-1]){
	
	alert ("La hora de vuelta no puede ser menor o igual que la de ida");	
	document.getElementById('tarifa'+tipo+opcion).selectedIndex=0;
	return;
	}
}

/*if (fechasalida==document.getElementById('fechahoy').value){
	Si (hora actual+1==horasalida)
		alert ("Por favor, seleccione otro vuelo de Ida ya que la hora actual está muy próxima a la hora de salida.\nPara más información contacte con el 902 477 478.");	
		document.getElementById('tarifa'+tipo+opcion).selectedIndex=0;
		return;
} */

var combo = document.getElementById('tarifa'+tipo+opcion).options[document.getElementById('tarifa'+tipo+opcion).selectedIndex].value.split("#");
document.getElementById('tarifa'+tipo).value=combo[0];

if (tipo=="vuelta") 
	document.getElementById("valorfeevuelta").value=combo[2];	
else
	document.getElementById("valorfeeida").value=combo[2];		


var combotext=document.getElementById('tarifa'+tipo+opcion).options[document.getElementById('tarifa'+tipo+opcion).selectedIndex].text;
var ultimaopcion=document.getElementsByName("vuelo"+tipo)[document.getElementsByName("vuelo"+tipo).length-1].value;

    for (i=1;i<=ultimaopcion;i++){
		if (document.getElementById('fila'+tipo+i)){
			if (document.getElementsByName("vuelo"+tipo)[j].value==opcion){
				 document.getElementById('fila'+tipo+i).style.backgroundColor="#f6b366";
				 document.getElementsByName("vuelo"+tipo)[j].checked=1; 
				 j++;
			}
			else {
           document.getElementById('fila'+tipo+i).style.backgroundColor="#FFFFFF";
		   document.getElementsByName("vuelo"+tipo)[j].checked=0; 
		   j++;
			}
		}
    }
		   if (tipo=="vuelta"){
			  ntarifas[1]=combo[0]; 
			  vtarifas[1]=combo[1];
			  vfees[1]=combo[2];
			  vtasas[1]=combo[9];  //ULTIMA POSISICIÓN DEL VALUE
			  vcond[1]=combo[6];
			  vmostrar[1]=combo[8];
			  vofertas[1]=combo[3];
  			  vofertasfee[1]=combo[4];
			  document.getElementById('VueltaTasas').value=stasasv[opcion];
			  numescalas=numvuelov[opcion].length;
			  /* inicializamos los vuelos **/
  		      for (ivuelo=1;ivuelo<=3;ivuelo++){
			 	document.getElementById('vueloVuelta['+ivuelo+'].numVuelo').value="";				
				document.getElementById('vueloVuelta['+ivuelo+'].origen').value="";
				document.getElementById('vueloVuelta['+ivuelo+'].destino').value="";
				document.getElementById('vueloVuelta['+ivuelo+'].fechaSalida').value="";
				document.getElementById('vueloVuelta['+ivuelo+'].clase').value="";
				document.getElementById('vueloVuelta['+ivuelo+'].HoraSalida').value="";
				document.getElementById('vueloVuelta['+ivuelo+'].HoraLlegada').value="";
			  }
			  
  		      for (ivuelo=1;ivuelo<=numescalas;ivuelo++){
			 	document.getElementById('vueloVuelta['+ivuelo+'].numVuelo').value=numvuelov[opcion][ivuelo-1];				
				document.getElementById('vueloVuelta['+ivuelo+'].origen').value=origenv[opcion][ivuelo-1];
				document.getElementById('vueloVuelta['+ivuelo+'].destino').value=destinov[opcion][ivuelo-1];
				document.getElementById('vueloVuelta['+ivuelo+'].fechaSalida').value=fechadev[opcion][ivuelo-1];
				document.getElementById('vueloVuelta['+ivuelo+'].clase').value=combo[0].substr(0,1);
				document.getElementById('vueloVuelta['+ivuelo+'].HoraSalida').value=horasalidav[opcion][ivuelo-1];
				document.getElementById('vueloVuelta['+ivuelo+'].HoraLlegada').value=horallegadav[opcion][ivuelo-1];
			  }
			  /*hora devolución hertz */
			  if (document.getElementById('hdevolucion') != undefined) {
				  document.getElementById('hdevolucion').value=horasalidav[opcion][numescalas-1];
			  }
			  
			  /***/
		   }
			else{
				
				ntarifas[0]=combo[0];
				vtarifas[0]=combo[1];
				vfees[0]=combo[2];
				vtasas[0]=combo[9];  //ULTIMA POSISICIÓN DEL VALUE
			    vcond[0]=combo[6];
				vmostrar[0]=combo[8];
				vofertas[0]=combo[3];
				vofertasfee[0]=combo[4];
				document.getElementById('IdaTasas').value=stasas[opcion];
				numescalas=numvuelo[opcion].length;
				for (ivuelo=1;ivuelo<=3;ivuelo++){
					document.getElementById('vueloIda['+ivuelo+'].numVuelo').value="";				
					document.getElementById('vueloIda['+ivuelo+'].origen').value="";
					document.getElementById('vueloIda['+ivuelo+'].destino').value="";
					document.getElementById('vueloIda['+ivuelo+'].fechaSalida').value="";
					document.getElementById('vueloIda['+ivuelo+'].clase').value="";
					document.getElementById('vueloIda['+ivuelo+'].HoraSalida').value="";
					document.getElementById('vueloIda['+ivuelo+'].HoraLlegada').value="";
				}				
				for (ivuelo=1;ivuelo<=numescalas;ivuelo++){
					document.getElementById('vueloIda['+ivuelo+'].numVuelo').value=numvuelo[opcion][ivuelo-1];				
					document.getElementById('vueloIda['+ivuelo+'].origen').value=origen[opcion][ivuelo-1];
					document.getElementById('vueloIda['+ivuelo+'].destino').value=destino[opcion][ivuelo-1];
					document.getElementById('vueloIda['+ivuelo+'].fechaSalida').value=fechade[opcion][ivuelo-1];
					document.getElementById('vueloIda['+ivuelo+'].clase').value=combo[0].substr(0,1);
					document.getElementById('vueloIda['+ivuelo+'].HoraSalida').value=horasalida[opcion][ivuelo-1];
					document.getElementById('vueloIda['+ivuelo+'].HoraLlegada').value=horallegada[opcion][ivuelo-1];
				}
			  /*hora recogida hertz */
			  if (document.getElementById('hrecogida') != undefined) {
				  document.getElementById('hrecogida').value=horasalida[opcion][numescalas-1];
				  document.getElementById('hrecogidatext').innerHTML=horasalida[opcion][numescalas-1];
				  document.getElementById('hdevoluciontext').innerHTML=horasalida[opcion][numescalas-1];
			  }
			  /***/

			}
			
/*********************************************/			
			
function RellenaFormulario (TipoPasajero,tarifa,npasajeros,idayvuelta){
var Pasajeros;


if ((document.getElementById(TipoPasajero).value !="") && (document.getElementById(TipoPasajero).value !="0")){
	Pasajeros=document.getElementById(TipoPasajero).value*1;
	document.getElementById('IdaFareBasis').value=ntarifas[0];
	document.getElementById('IdaFareBasisAlias').value=vcond[0];
	
	ImporteIda=buscartarifa ("ida",tarifa, ntarifas[0],2)/Pasajeros;
	OfertaIda=buscartarifa ("ida",tarifa, ntarifas[0],4)/Pasajeros;
	OfertaFeeIda=buscartarifa ("ida",tarifa, ntarifas[0],5)/Pasajeros;	

	
	Fee=buscarfee (tipo,tarifa, ntarifas,1);
	//alert (Fee);
	
	npasajeroscopia=npasajeros;
	for (i=1;i<=Pasajeros;i++){
		document.getElementById('passengers['+npasajeros+'].precio.tarifa.ida').value=redondear(ImporteIda);
		document.getElementById('passengers['+npasajeros+'].precio.fee').value=redondear(Fee*1/Pasajeros);
		document.getElementById('passengers['+npasajeros+'].descuento.billete.ida').value=redondear(OfertaIda);
		document.getElementById('passengers['+npasajeros+'].descuento.fee.ida').value=redondear(OfertaFeeIda);		
		npasajeros++;
	}
	if (idayvuelta==1){
		ImporteVuelta=buscartarifa ("vuelta",tarifa, ntarifas[1],2)/Pasajeros;
		OfertaVuelta=buscartarifa ("vuelta",tarifa, ntarifas[1],4)/Pasajeros;		
		OfertaFeeVuelta=buscartarifa ("vuelta",tarifa, ntarifas[1],5)/Pasajeros;	
		//alert(OfertaFeeVuelta);
		document.getElementById('VueltaFareBasis').value=ntarifas[1];
		document.getElementById('VueltaFareBasisAlias').value=vcond[1];
		
		for (i=1;i<=Pasajeros;i++){
			document.getElementById('passengers['+npasajeroscopia+'].precio.tarifa.vuelta').value=redondear(ImporteVuelta);
			document.getElementById('passengers['+npasajeroscopia+'].descuento.billete.vuelta').value=redondear(OfertaVuelta);			
			document.getElementById('passengers['+npasajeroscopia+'].descuento.fee.vuelta').value=redondear(OfertaFeeVuelta);						
			npasajeroscopia++;
		}
	}
}
return npasajeros;
}

/*************************************************/
			
if  (SoloIda){
	document.getElementById("ImporteTotal").style.display="block";
	document.getElementById("SinImporteTotal").style.display="none";
}

//if ((vtarifas[0] > 0) && (vtarifas[1] > 0)){
if ((vtasas[0] > 0) && (vtasas[1] > 0)){
	document.getElementById("ImporteTotal").style.display="block";
	document.getElementById("SinImporteTotal").style.display="none";
	
	//en ida y vuelta: si alguno es 0 aplicamos el maximo.
	if ( ((vfees[0]*1) == 0) || ((vfees[1]*1) == 0) ) {
		if (vfees[0] <= vfees[1]) {
			document.getElementById("valorfee").value=vfees[1];
			combo[4]=vofertasfee[1];
		} else {
			document.getElementById("valorfee").value=vfees[0];
			combo[4]=vofertasfee[0];
		}
		
	} else 
		document.getElementById("valorfee").value=redondear(Math.min(vfees[0]*1,vfees[1]*1));
	combo[2] = document.getElementById("valorfee").value;
	
	
	if (combo[4]==0)	
		document.getElementById("rfee").innerHTML=document.getElementById("valorfee").value+"&nbsp;&euro;";
	else 
		document.getElementById("rfee").innerHTML="<span style='text-decoration: line-through;'>"+redondear(combo[2])
	+"&nbsp;&euro;</span><br><span class='oferta'>"+redondear(combo[2]-combo[4])+"&nbsp;&euro;</span>";
/*		document.getElementById("rfee").innerHTML="<span class='oferta'>"+redondear(combo[2]-combo[4])+"&nbsp;&euro;</span>";*/
	
	
	

	
	
	if ((vofertas[0]==0) && (vofertas[1]==0)){
		document.getElementById("rtarifa").innerHTML=redondear(vtarifas[0]*1+vtarifas[1]*1)+"&nbsp;&euro;";		
	//	document.getElementById("tdtarifa").style.display="none";
	}
	else{

		if ((vmostrar[0] != 0) || (vmostrar[1] != 0)) 
				document.getElementById("rtarifa").innerHTML="<span class='oferta'>"+redondear(vtarifas[0]*1+vtarifas[1]*1)+"&nbsp;&euro;</span>";		


		else 
			document.getElementById("rtarifa").innerHTML="<span style='text-decoration: line-through;'>"+redondear(vtarifas[0]*1+vofertas[0]*1+vtarifas[1]*1+vofertas[1]*1)+"&nbsp;&euro;</span><br><span class='oferta'>"+redondear(vtarifas[0]*1+vtarifas[1]*1)+"&nbsp;&euro;</span>";		
		
		/*document.getElementById("rtarifa").innerHTML="<span class='oferta'>"+redondear(vtarifas[0]*1+vtarifas[1]*1)+"&nbsp;&euro;</span>";		
//		document.getElementById("rtarifa").innerHTML=redondear(vtarifas[0]*1+vofertas[0]*1+vtarifas[1]*1+vofertas[1]*1);*/
	}
	
	if ((vofertas[0]==0) && (vofertas[1]==0) && combo[4]==0){
			document.getElementById("PrecioTotal").value=redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1);	
		    document.getElementById("rtotal").innerHTML=redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1);		
	}
	else {
	document.getElementById("PrecioTotal").value=redondear((vtarifas[0]*1+vofertas[0]*1+vtarifas[1]*1+vofertas[1]*1)+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1);
	if ((vmostrar[0] != 0) || (vmostrar[1] != 0)) {
		document.getElementById("rtotal").innerHTML="<span class='ofertabgnaranja'>"+redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1-combo[4]*1)	+"&nbsp;&euro;</span>";
	} else {
		document.getElementById("rtotal").innerHTML="<span style='text-decoration: line-through;'>"+redondear(vtarifas[0]*1+vofertas[0]*1+vtarifas[1]*1+vofertas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1)+"&nbsp;&euro;</span><br><span class='ofertabgnaranja'>"+redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1-combo[4]*1)	+"&nbsp;&euro;</span>";	
	}

		/*document.getElementById("rtotal").innerHTML="<span class='ofertabgnaranja'>"+redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1-combo[4]*1)	+"&nbsp;&euro;</span>";*/

		
	}
	
//	document.getElementById("dtarifa").innerHTML=redondear(vofertas[0]*1+vofertas[1]*1);
	document.getElementById("rtasas").innerHTML=redondear(redondear(vtasas[0]*1+vtasas[1]*1)*NumPlazas);
	
	//document.getElementById("drfee").innerHTML=redondear(combo[4]*1);	
	//document.getElementById("rtotal").innerHTML=redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1-combo[4]*1);		
	document.getElementById("ResumenTotal").innerHTML=redondear(vtarifas[0]*1+vtarifas[1]*1+(vtasas[0]*1+vtasas[1]*1)*NumPlazas+combo[2]*1-combo[4]*1);
	
		
	/*****************************************************/
			
	if (document.getElementById("RTAR"))
		document.getElementById("RTAR").innerHTML=buscartarifa ("ida",TAr, ntarifas[0],2)+buscartarifa ("vuelta",TAr, ntarifas[1],2);
		

	if (document.getElementById("RTARt1"))
		document.getElementById("RTARt1").innerHTML=buscartarifa ("ida",TArt1, ntarifas[0],2)+buscartarifa ("vuelta",TArt1, ntarifas[1],2);
		
	if (document.getElementById("RTARt2"))
		document.getElementById("RTARt2").innerHTML=buscartarifa ("ida",TArt2, ntarifas[0],2)+buscartarifa ("vuelta",TArt2, ntarifas[1],2);
		
		/******************** DESCUENTO TARIFA **********************/
		
/*	if (document.getElementById("RTARD"))
		document.getElementById("RTARD").innerHTML=buscartarifa ("ida",TAr, ntarifas[0],4)+buscartarifa ("vuelta",TAr, ntarifas[1],4);				

	if (document.getElementById("RTARDt1"))
		document.getElementById("RTARDt1").innerHTML=buscartarifa ("ida",TArt1, ntarifas[0],4)+buscartarifa ("vuelta",TArt1, ntarifas[1],4);
		
	if (document.getElementById("RTARDt2"))
		document.getElementById("RTARDt2").innerHTML=buscartarifa ("ida",TArt2, ntarifas[0],4)+buscartarifa ("vuelta",TArt2, ntarifas[1],4);*/
		
/********************************************************/

if (document.getElementById("RTaAR"))
		document.getElementById("RTaAR").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NAdultoR").value*1;
		
if (document.getElementById("RTaARt1"))
		document.getElementById("RTaARt1").innerHTML=redondear(redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NAdultoRt1").value*1);

if (document.getElementById("RTaARt2"))
		document.getElementById("RTaARt2").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NAdultoRt2").value*1;
		
/*************************** TARIFAS NIÑO RESIDENTE*****************************/		
		
	if (document.getElementById("RTNR"))
		document.getElementById("RTNR").innerHTML=redondear(buscartarifa ("ida",TNr, ntarifas[0],2)+buscartarifa ("vuelta",TNr, ntarifas[1],2));

	if (document.getElementById("RTNRt1"))
		document.getElementById("RTNRt1").innerHTML=redondear(buscartarifa ("ida",TNrt1, ntarifas[0],2)+buscartarifa ("vuelta",TNrt1, ntarifas[1],2));

	if (document.getElementById("RTNRt2"))
		document.getElementById("RTNRt2").innerHTML=redondear(buscartarifa ("ida",TNrt2, ntarifas[0],2)+buscartarifa ("vuelta",TNrt2, ntarifas[1],2));

/*	if (document.getElementById("RTNRD"))
		document.getElementById("RTNRD").innerHTML=buscartarifa ("ida",TNr, ntarifas[0],4)+buscartarifa ("vuelta",TNr, ntarifas[1],4);

	if (document.getElementById("RTNRDt1"))
		document.getElementById("RTNRDt1").innerHTML=buscartarifa ("ida",TNrt1, ntarifas[0],4)+buscartarifa ("vuelta",TNrt1, ntarifas[1],4);

	if (document.getElementById("RTNRDt2"))
		document.getElementById("RTNRDt2").innerHTML=buscartarifa ("ida",TNrt2, ntarifas[0],4)+buscartarifa ("vuelta",TNrt2, ntarifas[1],4);*/
		
/*********************************************************/		
		
if (document.getElementById("RTaNR"))
		document.getElementById("RTaNR").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NNinoR").value*1;	

if (document.getElementById("RTaNRt1"))
		document.getElementById("RTaNRt1").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NNinoRt1").value*1;	

if (document.getElementById("RTaNRt2"))
		document.getElementById("RTaNRt2").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NNinoRt2").value*1;	
		
/***************** TARIFAS BEBE RESIDENTE*********************/		

	if (document.getElementById("RTBR"))
		document.getElementById("RTBR").innerHTML=redondear(buscartarifa ("ida",TBr, ntarifas[0],2)+buscartarifa ("vuelta",TBr, ntarifas[1],2));
		
	if (document.getElementById("RTBRt1"))
		document.getElementById("RTBRt1").innerHTML=redondear(buscartarifa ("ida",TBrt1, ntarifas[0],2)+buscartarifa ("vuelta",TBrt1, ntarifas[1],2));

	if (document.getElementById("RTBRt2"))
		document.getElementById("RTBRt2").innerHTML=redondear(buscartarifa ("ida",TBrt2, ntarifas[0],2)+buscartarifa ("vuelta",TBrt2, ntarifas[1],2));
		
		
	/*if (document.getElementById("RTBRD"))
		document.getElementById("RTBRD").innerHTML=buscartarifa ("ida",TBr, ntarifas[0],4)+buscartarifa ("vuelta",TBr, ntarifas[1],4);
		
	if (document.getElementById("RTBRDt1"))
		document.getElementById("RTBRDt1").innerHTML=buscartarifa ("ida",TBrt1, ntarifas[0],4)+buscartarifa ("vuelta",TBrt1, ntarifas[1],4);

	if (document.getElementById("RTBRDt2"))
		document.getElementById("RTBRDt2").innerHTML=buscartarifa ("ida",TBrt2, ntarifas[0],4)+buscartarifa ("vuelta",TBrt2, ntarifas[1],4);*/
				
/**************************************/		
		
	if (document.getElementById("RTaBR"))
		document.getElementById("RTaBR").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NBebeR").value*1;
		
			if (document.getElementById("RTaBRt1"))
		document.getElementById("RTaBRt1").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NBebeRt1").value*1;
		
			if (document.getElementById("RTaBRt2"))
		document.getElementById("RTaBRt2").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NBebeRt2").value*1;

/******************************** TARIFAS ADULTO ***********************************************************************/

	if (document.getElementById("RTA"))
		document.getElementById("RTA").innerHTML=redondear(buscartarifa ("ida",TA, ntarifas[0],2)+buscartarifa ("vuelta",TA, ntarifas[1],2));

	if (document.getElementById("RTAt1"))
		document.getElementById("RTAt1").innerHTML=redondear(buscartarifa ("ida",TAt1, ntarifas[0],2)+buscartarifa ("vuelta",TAt1, ntarifas[1],2));

	if (document.getElementById("RTAt2"))
		document.getElementById("RTAt2").innerHTML=redondear(buscartarifa ("ida",TAt2, ntarifas[0],2)+buscartarifa ("vuelta",TAt2, ntarifas[1],2));
		
	/*if (document.getElementById("RTAD"))
		document.getElementById("RTAD").innerHTML=buscartarifa ("ida",TA, ntarifas[0],4)+buscartarifa ("vuelta",TA, ntarifas[1],4);

	if (document.getElementById("RTADt1"))
		document.getElementById("RTADt1").innerHTML=buscartarifa ("ida",TAt1, ntarifas[0],4)+buscartarifa ("vuelta",TAt1, ntarifas[1],4);

	if (document.getElementById("RTADt2"))
		document.getElementById("RTADt2").innerHTML=buscartarifa ("ida",TAt2, ntarifas[0],4)+buscartarifa ("vuelta",TAt2, ntarifas[1],4);*/
		
/**********************************/		
		
	if (document.getElementById("RTaA"))
		document.getElementById("RTaA").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NAdultoNR").value*1;

	if (document.getElementById("RTaAt1"))
		document.getElementById("RTaAt1").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NAdultoNRt1").value*1;

	if (document.getElementById("RTaAt2"))
		document.getElementById("RTaAt2").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NAdultoNRt2").value*1;

/************ TARIFAS NIÑO *************/		
		
	if (document.getElementById("RTN"))
		document.getElementById("RTN").innerHTML=redondear(buscartarifa ("ida",TN, ntarifas[0],2)+buscartarifa ("vuelta",TN, ntarifas[1],2));

	if (document.getElementById("RTNt1"))
		document.getElementById("RTNt1").innerHTML=redondear(buscartarifa ("ida",TNt1, ntarifas[0],2)+buscartarifa ("vuelta",TNt1, ntarifas[1],2));

	if (document.getElementById("RTNt2"))
		document.getElementById("RTNt2").innerHTML=redondear(buscartarifa ("ida",TNt2, ntarifas[0],2)+buscartarifa ("vuelta",TNt2, ntarifas[1],2));
		
/*	if (document.getElementById("RTND"))
		document.getElementById("RTND").innerHTML=buscartarifa ("ida",TN, ntarifas[0],4)+buscartarifa ("vuelta",TN, ntarifas[1],4);

	if (document.getElementById("RTNDt1"))
		document.getElementById("RTNDt1").innerHTML=buscartarifa ("ida",TNt1, ntarifas[0],4)+buscartarifa ("vuelta",TNt1, ntarifas[1],4);

	if (document.getElementById("RTNDt2"))
		document.getElementById("RTNDt2").innerHTML=buscartarifa ("ida",TNt2, ntarifas[0],4)+buscartarifa ("vuelta",TNt2, ntarifas[1],4);*/
		
/************************/

	if (document.getElementById("RTaN"))
		document.getElementById("RTaN").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NNinoNR").value*1;

	if (document.getElementById("RTaNt1"))
		document.getElementById("RTaNt1").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NNinoNRt1").value*1;

	if (document.getElementById("RTaNt2"))
		document.getElementById("RTaNt2").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NNinoNRt2").value*1;
		
/************* TARIFAS BEBE **********/		
		
	if (document.getElementById("RTB"))
		document.getElementById("RTB").innerHTML=redondear(buscartarifa ("ida",TB, ntarifas[0],2)+buscartarifa ("vuelta",TB, ntarifas[1],2));

	if (document.getElementById("RTBt1"))
		document.getElementById("RTBt1").innerHTML=redondear(buscartarifa ("ida",TBt1, ntarifas[0],2)+buscartarifa ("vuelta",TBt1, ntarifas[1],2));

	if (document.getElementById("RTBt2"))
		document.getElementById("RTBt2").innerHTML=redondear(buscartarifa ("ida",TBt2, ntarifas[0],2)+buscartarifa ("vuelta",TBt2, ntarifas[1],2));
		
	/*if (document.getElementById("RTBD"))
		document.getElementById("RTBD").innerHTML=redondear(buscartarifa ("ida",TB, ntarifas[0],4)+buscartarifa ("vuelta",TB, ntarifas[1],4));

	if (document.getElementById("RTBDt1"))
		document.getElementById("RTBDt1").innerHTML=redondear(buscartarifa ("ida",TBt1, ntarifas[0],4)+buscartarifa ("vuelta",TBt1, ntarifas[1],4));

	if (document.getElementById("RTBDt2"))
		document.getElementById("RTBDt2").innerHTML=redondear(buscartarifa ("ida",TBt2, ntarifas[0],4)+buscartarifa ("vuelta",TBt2, ntarifas[1],4));*/
		
/**********************/
		
	if (document.getElementById("RTaB"))
		document.getElementById("RTaB").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NBebeNR").value*1;

	if (document.getElementById("RTaBt1"))
		document.getElementById("RTaBt1").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NBebeNRt1").value*1;

	if (document.getElementById("RTaBt2"))
		document.getElementById("RTaBt2").innerHTML=redondear(vtasas[0]*1+vtasas[1]*1)*document.getElementById("NBebeNRt2").value*1;

/***********rellenar formulario *************/

npasajeros=1;
npasajeros=RellenaFormulario ("NAdultoRt1",TArt1,npasajeros,1);
npasajeros=RellenaFormulario ("NAdultoRt2",TArt2,npasajeros,1);
npasajeros=RellenaFormulario ("NAdultoR",TAr,npasajeros,1);

npasajeros=RellenaFormulario ("NNinoR",TNr,npasajeros,1);
npasajeros=RellenaFormulario ("NNinoRt1",TNrt1,npasajeros,1);
npasajeros=RellenaFormulario ("NNinoRt2",TNrt2,npasajeros,1);

npasajeros=RellenaFormulario ("NBebeR",TBr,npasajeros,1);
npasajeros=RellenaFormulario ("NBebeRt1",TBrt1,npasajeros,1);
npasajeros=RellenaFormulario ("NBebeRt2",TBrt2,npasajeros,1);

npasajeros=RellenaFormulario ("NAdultoNR",TA,npasajeros,1);
npasajeros=RellenaFormulario ("NAdultoNRt1",TAt1,npasajeros,1);
npasajeros=RellenaFormulario ("NAdultoNRt2",TAt2,npasajeros,1);

npasajeros=RellenaFormulario ("NNinoNR",TN,npasajeros,1);
npasajeros=RellenaFormulario ("NNinoNRt1",TNt1,npasajeros,1);
npasajeros=RellenaFormulario ("NNinoNRt2",TNt2,npasajeros,1);

npasajeros=RellenaFormulario ("NBebeNR",TB,npasajeros,1);
npasajeros=RellenaFormulario ("NBebeNRt1",TBt1,npasajeros,1);
npasajeros=RellenaFormulario ("NBebeNRt2",TBt2,npasajeros,1);

/******************/

}
//else if (vtarifas[0] >= 0){
else if ((vtasas[0] > 0) && (SoloIda)){
	if ((vofertas[0]==0) && (vofertas[1]==0)){
		document.getElementById("rtarifa").innerHTML=redondear(vtarifas[0]*1)+"&nbsp;&euro;";
		// document.getElementById("tdtarifa").style.display="none";
document.getElementById("PrecioTotal").value=redondear(vtarifas[0]*1+vtasas[0]*NumPlazas+combo[2]*1);			
	}
	else{
		
		if ((vmostrar[0] != 0) || (vmostrar[1] != 0)) 
		document.getElementById("rtarifa").innerHTML="<span class='oferta'>"+redondear(vtarifas[0])+"&nbsp;&euro;</span>";	
		
		else 
		document.getElementById("rtarifa").innerHTML="<span style='text-decoration: line-through;'>"+redondear(vtarifas[0]*1+vofertas[0]*1)+"&nbsp;&euro;</span><br><span class='oferta'>"+redondear(vtarifas[0])+"&nbsp;&euro;</span>";	
		
		
		//document.getElementById("rtarifa").innerHTML="<span class='oferta'>"+redondear(vtarifas[0])+"&nbsp;&euro;</span>";	
		document.getElementById("PrecioTotal").value=redondear(vtarifas[0]*1+vofertas[0]*1+vtasas[0]*NumPlazas+combo[2]*1);	
	}
	//document.getElementById("dtarifa").innerHTML=redondear(vofertas[0]);
	document.getElementById("rtasas").innerHTML=redondear(vtasas[0]*NumPlazas);
	if (combo[4]==0){		
		//alert("entro ida");
		document.getElementById("valorfee").value=redondear(Math.min(vfees[0]*1,vfees[1]*1));
		document.getElementById("rfee").innerHTML=document.getElementById("valorfee").value+"&nbsp;&euro;";
	}
	else
		document.getElementById("rfee").innerHTML="<span style='text-decoration: line-through;'>"+redondear(combo[2])
	+"&nbsp;&euro;</span><br><span class='oferta'>"+redondear(combo[2]-combo[4])+"&nbsp;&euro;</span>";
	
	
	//document.getElementById("drfee").innerHTML=redondear(combo[4]);
		if ((vofertas[0]==0) && (vofertas[1]==0) && (combo[4]==0) || (combo[6] != 0)){
				document.getElementById("rtotal").innerHTML=redondear(vtarifas[0]*1+vtasas[0]*NumPlazas+combo[2]*1-combo[4]*1)+"&nbsp;&euro;";	

		}
		else
	document.getElementById("rtotal").innerHTML="<span style='text-decoration: line-through;'>"+redondear(vtarifas[0]*1+vofertas[0]*1+vtasas[0]*NumPlazas+combo[2]*1)+"&nbsp;&euro;</span><br><span class='ofertabgnaranja'>"+redondear(vtarifas[0]*1+vtasas[0]*1*NumPlazas+combo[2]*1-combo[4]*1)+"&nbsp;&euro;</span>";	
	document.getElementById("ResumenTotal").innerHTML=redondear(vtarifas[0]*1+vtasas[0]*NumPlazas+combo[2]*1-combo[4]*1);		
/*	document.getElementById("rtotal").innerHTML="<span class='ofertabgnaranja'>"+redondear(vtarifas[0]*1+vtasas[0]*1*NumPlazas+combo[2]*1-combo[4]*1)+"&nbsp;&euro;</span>";	
	document.getElementById("ResumenTotal").innerHTML=redondear(vtarifas[0]*1+vtasas[0]*NumPlazas+combo[2]*1-combo[4]*1);		*/
	
	
	/****************************************************************************/
	
	if (document.getElementById("RTAR"))
		document.getElementById("RTAR").innerHTML=buscartarifa (tipo,TAr, ntarifas[0],2);
		
	if (document.getElementById("RTARt1"))
		document.getElementById("RTARt1").innerHTML=buscartarifa (tipo,TArt1, ntarifas[0],2);
		
	if (document.getElementById("RTARt2"))
		document.getElementById("RTARt2").innerHTML=buscartarifa (tipo,TArt2, ntarifas[0],2);
		
				/*********************************** DESCUENTO TARIFAS ***************************************/		
		
/*	if (document.getElementById("RTARD"))
		document.getElementById("RTARD").innerHTML=buscartarifa (tipo,TAr, ntarifas[0],4);
		
	if (document.getElementById("RTARDt1"))
		document.getElementById("RTARDt1").innerHTML=buscartarifa (tipo,TArt1, ntarifas[0],4);
		
	if (document.getElementById("RTARDt2"))
		document.getElementById("RTARDt2").innerHTML=buscartarifa (tipo,TArt2, ntarifas[0],4);	*/	
			
	/******************************************************************/		

if (document.getElementById("RTaAR"))
		document.getElementById("RTaAR").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NAdultoR").value*1;
		
if (document.getElementById("RTaARt1"))
		document.getElementById("RTaARt1").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NAdultoRt1").value*1;

if (document.getElementById("RTaARt2"))
		document.getElementById("RTaARt2").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NAdultoRt2").value*1;

/****************************************** TARIFAS NIÑO RESIDENTE *******************************************************/
		
	if (document.getElementById("RTNR"))
		document.getElementById("RTNR").innerHTML=buscartarifa (tipo,TNr, ntarifas[0],2);
		
	if (document.getElementById("RTNRt1"))
		document.getElementById("RTNRt1").innerHTML=buscartarifa (tipo,TNrt1, ntarifas[0],2);

	if (document.getElementById("RTNRt2"))
		document.getElementById("RTNRt2").innerHTML=buscartarifa (tipo,TNrt2, ntarifas[0],2);
		
		/****** DESCUENTOS ***********/
		
/*	if (document.getElementById("RTNRD"))
		document.getElementById("RTNRD").innerHTML=buscartarifa (tipo,TNr, ntarifas[0],4);
		
	if (document.getElementById("RTNRDt1"))
		document.getElementById("RTNRDt1").innerHTML=buscartarifa (tipo,TNrt1, ntarifas[0],4);

	if (document.getElementById("RTNRDt2"))
		document.getElementById("RTNRDt2").innerHTML=buscartarifa (tipo,TNrt2, ntarifas[0],4);*/
				
/************************/		
		
if (document.getElementById("RTaNR"))
		document.getElementById("RTaNR").innerHTML=redondear(vtasas[0])*document.getElementById("NNinoR").value*1;
		
if (document.getElementById("RTaNRt1"))
		document.getElementById("RTaNRt1").innerHTML=redondear(vtasas[0])*document.getElementById("NNinoRt1").value*1;

if (document.getElementById("RTaNRt2"))
		document.getElementById("RTaNRt2").innerHTML=redondear(vtasas[0])*document.getElementById("NNinoRt2").value*1;
		
/*************** TARIFAS BEBE RESIDENTE ***********/		
		
	if (document.getElementById("RTBR"))
		document.getElementById("RTBR").innerHTML=buscartarifa (tipo,TBr, ntarifas[0],2);		

	if (document.getElementById("RTBRt1"))
		document.getElementById("RTBRt1").innerHTML=buscartarifa (tipo,TBrt1, ntarifas[0],2);

	if (document.getElementById("RTBRt2"))
		document.getElementById("RTBRt2").innerHTML=buscartarifa (tipo,TBrt2, ntarifas[0],2);
		
/*	if (document.getElementById("RTBRD"))
		document.getElementById("RTBRD").innerHTML=buscartarifa (tipo,TBr, ntarifas[0],4);		

	if (document.getElementById("RTBRDt1"))
		document.getElementById("RTBRDt1").innerHTML=buscartarifa (tipo,TBrt1, ntarifas[0],4);

	if (document.getElementById("RTBRDt2"))
		document.getElementById("RTBRDt2").innerHTML=buscartarifa (tipo,TBrt2, ntarifas[0],4);*/
				
/**************************************/		

	if (document.getElementById("RTaBR"))
		document.getElementById("RTaBR").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NBebeR").value*1;

	if (document.getElementById("RTaBRt1"))
		document.getElementById("RTaBRt1").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NBebeRt1").value*1;

	if (document.getElementById("RTaBRt2"))
		document.getElementById("RTaBRt2").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NBebeRt2").value*1;

/********* TARIFAS ADULTO ************/

	if (document.getElementById("RTA"))
		document.getElementById("RTA").innerHTML=buscartarifa (tipo,TA, ntarifas[0],2);

	if (document.getElementById("RTAt1"))
		document.getElementById("RTAt1").innerHTML=buscartarifa (tipo,TAt1, ntarifas[0],2);

	if (document.getElementById("RTAt2"))
		document.getElementById("RTAt2").innerHTML=buscartarifa (tipo,TAt2, ntarifas[0],2);
		
/*	if (document.getElementById("RTAD"))
		document.getElementById("RTAD").innerHTML=buscartarifa (tipo,TA, ntarifas[0],4);

	if (document.getElementById("RTADt1"))
		document.getElementById("RTADt1").innerHTML=buscartarifa (tipo,TAt1, ntarifas[0],4);

	if (document.getElementById("RTADt2"))
		document.getElementById("RTADt2").innerHTML=buscartarifa (tipo,TAt2, ntarifas[0],4);*/
				
/*******************/		
		
	if (document.getElementById("RTaA"))
		document.getElementById("RTaA").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NAdultoNR").value*1;
		
	if (document.getElementById("RTaAt1"))
		document.getElementById("RTaAt1").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NAdultoNRt1").value*1;

	if (document.getElementById("RTaAt2"))
		document.getElementById("RTaAt2").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NAdultoNRt2").value*1;
		
/******* TARIFAS NIÑO *********/		
		

		
	if (document.getElementById("RTN"))
		document.getElementById("RTN").innerHTML=buscartarifa (tipo,TN, ntarifas[0],2);

	if (document.getElementById("RTNt1"))
		document.getElementById("RTNt1").innerHTML=buscartarifa (tipo,TNt1, ntarifas[0],2);

	if (document.getElementById("RTNt2"))
		document.getElementById("RTNt2").innerHTML=buscartarifa (tipo,TNt2, ntarifas[0],2);

	/*if (document.getElementById("RTND"))
		document.getElementById("RTND").innerHTML=buscartarifa (tipo,TN, ntarifas[0],4);

	if (document.getElementById("RTNDt1"))
		document.getElementById("RTNDt1").innerHTML=buscartarifa (tipo,TNt1, ntarifas[0],4);

	if (document.getElementById("RTNDt2"))
		document.getElementById("RTNDt2").innerHTML=buscartarifa (tipo,TNt2, ntarifas[0],4);*/

/**********************/		
		
		if (document.getElementById("RTaN"))
		document.getElementById("RTaN").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NNinoNR").value*1;

		if (document.getElementById("RTaNt1"))
		document.getElementById("RTaNt1").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NNinoNRt1").value*1;

		if (document.getElementById("RTaNt2"))
		document.getElementById("RTaNt2").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NNinoNRt2").value*1;

/********** TARIFAS BEBE *********/		
		
	if (document.getElementById("RTB"))
		document.getElementById("RTB").innerHTML=buscartarifa (tipo,TB, ntarifas[0],2);

	if (document.getElementById("RTBt1"))
		document.getElementById("RTBt1").innerHTML=buscartarifa (tipo,TBt1, ntarifas[0],2);

	if (document.getElementById("RTBt2"))
		document.getElementById("RTBt2").innerHTML=buscartarifa (tipo,TBt2, ntarifas[0],2);
		
	/*if (document.getElementById("RTBD"))
		document.getElementById("RTBD").innerHTML=buscartarifa (tipo,TB, ntarifas[0],4);

	if (document.getElementById("RTBDt1"))
		document.getElementById("RTBDt1").innerHTML=buscartarifa (tipo,TBt1, ntarifas[0],4);

	if (document.getElementById("RTBDt2"))
		document.getElementById("RTBDt2").innerHTML=buscartarifa (tipo,TBt2, ntarifas[0],4);
				*/
/*************/		

	if (document.getElementById("RTaB"))
		document.getElementById("RTaB").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NBebeNR").value*1;	

	if (document.getElementById("RTaBt1"))
		document.getElementById("RTaBt1").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NBebeNRt1").value*1;	

	if (document.getElementById("RTaBt2"))
		document.getElementById("RTaBt2").innerHTML=redondear(vtasas[0]*1)*document.getElementById("NBebeNRt2").value*1;	
	
npasajeros=1;
npasajeros=RellenaFormulario ("NAdultoRt1",TArt1,npasajeros,0);
npasajeros=RellenaFormulario ("NAdultoRt2",TArt2,npasajeros,0);
npasajeros=RellenaFormulario ("NAdultoR",TAr,npasajeros,0);

npasajeros=RellenaFormulario ("NNinoR",TNr,npasajeros,0);
npasajeros=RellenaFormulario ("NNinoRt1",TNrt1,npasajeros,0);
npasajeros=RellenaFormulario ("NNinoRt2",TNrt2,npasajeros,0);

npasajeros=RellenaFormulario ("NBebeR",TBr,npasajeros,0);
npasajeros=RellenaFormulario ("NBebeRt1",TBrt1,npasajeros,0);
npasajeros=RellenaFormulario ("NBebeRt2",TBrt2,npasajeros,0);

npasajeros=RellenaFormulario ("NAdultoNR",TA,npasajeros,0);
npasajeros=RellenaFormulario ("NAdultoNRt1",TAt1,npasajeros,0);
npasajeros=RellenaFormulario ("NAdultoNRt2",TAt2,npasajeros,0);

npasajeros=RellenaFormulario ("NNinoNR",TN,npasajeros,0);
npasajeros=RellenaFormulario ("NNinoNRt1",TNt1,npasajeros,0);
npasajeros=RellenaFormulario ("NNinoNRt2",TNt2,npasajeros,0);

npasajeros=RellenaFormulario ("NBebeNR",TB,npasajeros,0);
npasajeros=RellenaFormulario ("NBebeNRt1",TBt1,npasajeros,0);
npasajeros=RellenaFormulario ("NBebeNRt2",TBt2,npasajeros,0);	

}

				
	document.getElementById("ptarifa"+tipo).innerHTML=combotext;
	
	farebasisCond = combo[0];
	if  (combo[6] != 0) 
		farebasisCond = combo[6];
	
	document.getElementById("pcondiciones"+tipo).innerHTML='<a href="#" onclick="javascript:muestratarifa2(\''+farebasisCond+'\',document.getElementById(\'vueloIda[1].origen\').value,document.getElementById(\'vueloIda[1].destino\').value);"><img src="img/ico/ico-condiciones.gif" width="13" height="15"></a>';
	
	document.getElementById("pinfovuelo"+tipo).innerHTML=document.getElementById("infovuelo"+tipo+opcion).innerHTML;
					
		/***************/			
		
		if (document.getElementById("RFAR"))
			document.getElementById("RFAR").innerHTML=buscarfee (tipo,TAr, ntarifas,1);
			//document.getElementById("RFAR").innerHTML=buscartarifa (tipo,TAr, combo[0],3);
			
		if (document.getElementById("RFARt1"))
			document.getElementById("RFARt1").innerHTML=buscarfee (tipo,TArt1, ntarifas,1);
		
		if (document.getElementById("RFARt2"))
			document.getElementById("RFARt2").innerHTML=buscarfee (tipo,TArt2, ntarifas,1);
			
			
			
		/*if (document.getElementById("RFARD"))
			document.getElementById("RFARD").innerHTML=buscartarifa (tipo,TAr, combo[0],5);
			
		if (document.getElementById("RFARDt1"))
			document.getElementById("RFARDt1").innerHTML=buscartarifa (tipo,TArt1, combo[0],5);
		
		if (document.getElementById("RFARDt2"))
			document.getElementById("RFARDt2").innerHTML=buscartarifa (tipo,TArt2, combo[0],5);*/
			
			
			
			
/*********************************/			
			
	if (document.getElementById("RFNR"))		
		document.getElementById("RFNR").innerHTML=buscarfee (tipo,TNr, ntarifas,1);	

	if (document.getElementById("RFNRt1"))		
		document.getElementById("RFNRt1").innerHTML=buscarfee (tipo,TNrt1, ntarifas,1);	

	if (document.getElementById("RFNRt2"))		
		document.getElementById("RFNRt2").innerHTML=buscarfee (tipo,TNrt2, ntarifas,1);	
		
		
	/*if (document.getElementById("RFNRD"))		
		document.getElementById("RFNRD").innerHTML=buscartarifa (tipo,TNr, combo[0],5);	

	if (document.getElementById("RFNRDt1"))		
		document.getElementById("RFNRDt1").innerHTML=buscartarifa (tipo,TNrt1, combo[0],5);	

	if (document.getElementById("RFNRDt2"))		
		document.getElementById("RFNRDt2").innerHTML=buscartarifa (tipo,TNrt2, combo[0],5);	*/
		
		
/*******************************/		
				
if (document.getElementById("RFBR"))		
		document.getElementById("RFBR").innerHTML=buscarfee (tipo,TBr, ntarifas,1);	

if (document.getElementById("RFBRt1"))		
		document.getElementById("RFBRt1").innerHTML=buscarfee (tipo,TBrt1, ntarifas,1);
		
if (document.getElementById("RFBRt2"))		
		document.getElementById("RFBRt2").innerHTML=buscarfee (tipo,TBrt2, ntarifas,1);		
		
/*if (document.getElementById("RFBRD"))		
		document.getElementById("RFBRD").innerHTML=buscartarifa (tipo,TBr, combo[0],5);	

if (document.getElementById("RFBRDt1"))		
		document.getElementById("RFBRDt1").innerHTML=buscartarifa (tipo,TBrt1, combo[0],5);
		
if (document.getElementById("RFBRDt2"))		
		document.getElementById("RFBRDt2").innerHTML=buscartarifa (tipo,TBrt2, combo[0],5);				
				*/
/**********************************/		


	if (document.getElementById("RFA"))
		document.getElementById("RFA").innerHTML=buscarfee(tipo,TA, ntarifas,1);
		
				
	if (document.getElementById("RFAt1"))
		document.getElementById("RFAt1").innerHTML=buscarfee (tipo,TAt1, ntarifas,1);

	if (document.getElementById("RFAt2"))
		document.getElementById("RFAt2").innerHTML=buscarfee (tipo,TAt2, ntarifas,1);
		
	/*if (document.getElementById("RFAD"))
		document.getElementById("RFAD").innerHTML=buscartarifa (tipo,TA, combo[0],5);
				
	if (document.getElementById("RFADt1"))
		document.getElementById("RFADt1").innerHTML=buscartarifa (tipo,TAt1, combo[0],5);

	if (document.getElementById("RFADt2"))
		document.getElementById("RFADt2").innerHTML=buscartarifa (tipo,TAt2, combo[0],5);*/
		
		
/*************************************/		

	if (document.getElementById("RFN"))		
		document.getElementById("RFN").innerHTML=buscarfee (tipo,TN, ntarifas,1);	

	if (document.getElementById("RFNt1"))		
		document.getElementById("RFNt1").innerHTML=buscarfee (tipo,TNt1, ntarifas,1);	

	if (document.getElementById("RFNt2"))		
		document.getElementById("RFNt2").innerHTML=buscarfee (tipo,TNt2, ntarifas,1);	
		
	/*if (document.getElementById("RFND"))		
		document.getElementById("RFND").innerHTML=buscartarifa (tipo,TN, combo[0],5);	

	if (document.getElementById("RFNDt1"))		
		document.getElementById("RFNDt1").innerHTML=buscartarifa (tipo,TNt1, combo[0],5);	

	if (document.getElementById("RFNDt2"))		
		document.getElementById("RFNDt2").innerHTML=buscartarifa (tipo,TNt2, combo[0],5);	*/
		

/****************************************/		
	if (document.getElementById("RFB"))		
		document.getElementById("RFB").innerHTML=buscarfee (tipo,TB, ntarifas,1);

	if (document.getElementById("RFBt1"))		
		document.getElementById("RFBt1").innerHTML=buscarfee (tipo,TBt1, ntarifas,1);

	if (document.getElementById("RFBt2"))		
		document.getElementById("RFBt2").innerHTML=buscarfee (tipo,TBt2, ntarifas,1);
		
	/*if (document.getElementById("RFBD"))		
		document.getElementById("RFBD").innerHTML=buscartarifa (tipo,TB, combo[0],5);

	if (document.getElementById("RFBDt1"))		
		document.getElementById("RFBDt1").innerHTML=buscartarifa (tipo,TBt1, combo[0],5);

	if (document.getElementById("RFBDt2"))		
		document.getElementById("RFBDt2").innerHTML=buscartarifa (tipo,TBt2, combo[0],5);*/
		
		
/************************************/		
		
return vtarifas;
}

/********************************************** MUESTRA TARIFA ***************************/



function muestratarifa2 (fare, origen, destino){

	tarifa = fare;	
		
	window.open('condicionestarifa.php?fare='+ tarifa + '&idioma=' + 'es&Origen='+origen+'&Destino='+destino, 'condicionestarifa', 'width=760,height=500,resizable=yes,scrollbars=yes');
	return false;

}



function muestratarifa (fare, origen, destino){

	tarifa = fare.split("#")[0];	
	if (fare.split("#")[6] != 0) 
		tarifa = fare.split("#")[6];
		
	window.open('condicionestarifa.php?fare='+ tarifa + '&idioma=' + 'es&Origen='+origen+'&Destino='+destino, 'condicionestarifa', 'width=760,height=500,resizable=yes,scrollbars=yes');
	return false;

}

/***********************************/

function olvidocontrasena (){
	window.open('http://www.islaspremium.com/site/fly/microsite/recordar.php', 'condicionestarifa', 'width=611,height=500,resizable=no,scrollbars=no');
	return false;

}

