function combo(indice){
	if (indice == 0){
		noverCapa('UX');nover('IB','JK','AF','BA','SAS','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 1){
		verCapa('UX');nover('IB','JK','AF','BA','SAS','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 2){
		verCapa('IB');nover('UX','JK','AF','BA','SAS','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 3){
		verCapa('JK');nover('UX','IB','AF','BA','SAS','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 4){
		verCapa('AF');nover('UX','JK','IB','BA','SAS','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 5){
		verCapa('SAS');nover('UX','JK','IB','BA','AF','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 6){
		verCapa('BA');nover('UX','JK','IB','AF','SAS','LH','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 7){
		verCapa('LH');nover('UX','JK','IB','BA','SAS','AF','SW','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 8){
		verCapa('VY');nover('UX','JK','IB','BA','AF','LH','SW','AB','SAS','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 9){
		verCapa('SW');nover('UX','JK','IB','AF','SAS','LH','BA','AB','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 10){
		verCapa('AB');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','TAP','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 11){
		verCapa('TAP');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','AB','FIN','RYAN','AL','XG','QR');
	}
	if (indice == 12){
		verCapa('FIN');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','AB','TAP','RYAN','AL','XG','QR');
	}
	if (indice == 13){
		verCapa('RYAN');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','AB','TAP','FIN','AL','XG','QR');
	}
	if (indice == 14){
		verCapa('AL');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','AB','TAP','FIN','RYAN','XG','QR');
	}
	if (indice == 15){
		verCapa('XG');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','AB','TAP','FIN','RYAN','AL','QR');
	}
	if(indice == 16){
		verCapa('QR');nover('UX','JK','IB','BA','SAS','AF','SW','LH','VY','AB','TAP','FIN','RYAN','AL','XG');
	}
}

function nover(nombre1,nombre2,nombre3,nombre4,nombre5,nombre6,nombre7,nombre8,nombre9,nombre10,nombre11,nombre12,nombre13,nombre14,nombre15){
  document.getElementById(nombre1).style.visibility="hidden";
  document.getElementById(nombre1).style.display="none";
  document.getElementById(nombre2).style.visibility="hidden";
  document.getElementById(nombre2).style.display="none";
  document.getElementById(nombre3).style.visibility="hidden";
  document.getElementById(nombre3).style.display="none";
  document.getElementById(nombre4).style.visibility="hidden";
  document.getElementById(nombre4).style.display="none";
  document.getElementById(nombre5).style.visibility="hidden";
  document.getElementById(nombre5).style.display="none";
  document.getElementById(nombre6).style.visibility="hidden";
  document.getElementById(nombre6).style.display="none";
  document.getElementById(nombre7).style.visibility="hidden";
  document.getElementById(nombre7).style.display="none";
  document.getElementById(nombre8).style.visibility="hidden";
  document.getElementById(nombre8).style.display="none";
  document.getElementById(nombre9).style.visibility="hidden";
  document.getElementById(nombre9).style.display="none";
  document.getElementById(nombre10).style.visibility="hidden";
  document.getElementById(nombre10).style.display="none";
  document.getElementById(nombre11).style.visibility="hidden";
  document.getElementById(nombre11).style.display="none";
  document.getElementById(nombre12).style.visibility="hidden";
  document.getElementById(nombre12).style.display="none";
  document.getElementById(nombre13).style.visibility="hidden";
  document.getElementById(nombre13).style.display="none";
  document.getElementById(nombre14).style.visibility="hidden";
  document.getElementById(nombre14).style.display="none";
  document.getElementById(nombre15).style.visibility="hidden";
  document.getElementById(nombre15).style.display="none";
}

function show_calendar(str_target, str_datetime) {
	var arr_months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
		"Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
	var week_days = ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"White\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+
		str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+
		"<img src=\"http://www.rumbo.es/pictures/rmbes/pic012.gif\" border=\"0\""+
		" alt=\"Mes anterior.\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
		+str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+
		"<img src=\"http://www.rumbo.es/pictures/rmbes/pic013.gif\" border=\"0\""+
		" alt=\"Mes siguiente.\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+
		"<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
		"<input type=\"hidden\" name=\"time\" value=\"\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=250,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
	var re_date = /^(\d+)\/(\d+)\/(\d+)\s/;
	if (!re_date.exec(str_datetime))
		return alert("Invalid Datetime format: "+ str_datetime);
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
	return (new String (dt_datetime.getDate()+"/"+(dt_datetime.getMonth()+1)+"/"+dt_datetime.getFullYear()+" "));
}
function dt2tmstr (dt_datetime) {
	return (new String (dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

function right(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
	return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
		alert("Lo sentimos, el bot?n derecho del rat?n est? inhabilitado");
		return false;
	}
return true;
}

/*****************************************************************/
/*  LIMPIAR ESPACIOS EN BLANCO EN CADENAS		                 */
/*****************************************************************/
function f_trim(str)
{	// Con charAt se accede a las posiciones del par?metro iguales a blanco y luego
    // retornamos el par?metro ya devuelto sin los blancos.
    for (var i=0; str.charAt(i)==" "; i++);
    return str.substring(i,str.length);
}

function esAdobeProblematico(){
    acrobatVersion= trataAdobe();
    ie=false;
    if(navigator.appName == "Microsoft Internet Explorer")
       ie=true;
    return ie && acrobatVersion=="7.0";
}

function noExisteAdobe(){
  acrobatVersion= trataAdobe();
  return acrobatVersion=="0.0";
}

function f_activar_adobe(){
    dd = document.getElementById('adobe');
    dd.style.visibility='visible';
    dd.style.display='block';
}

function DoSubmit(form, action, attrs, target)
{	
   if (form!=null)
   {

      if (action!=null)  {
         var j = action.indexOf("?");
         if ( j != -1){
           var longitud = action.length;
           var nuevaAccion = action.substring(0,j);
           var parametros =  action.substring(j+1,longitud);
           arrayOfStrings = parametros.split("&");
           action = nuevaAccion;
           for (var i=0; i < arrayOfStrings.length; i++) {
              var aux = arrayOfStrings[i];
              var longitud2 = aux.length;
              var k = aux.indexOf("=");
              if (k != -1) {
                  var clave = aux.substring(0,k);
                  var valor = aux.substring(k+1,longitud2);
                  form[clave].value = valor;
              }
          }
         }
         form.action = action;
      }
      if (attrs!=null)
      {
         for (var name in attrs)
         {
            if (form[name])  {
               form[name].value = attrs[name];
            }
         }
      }

      if (target) form.target = target;
      else form.target = '_top';

      form.submit();
   }
}

/* VALIDACI?N DE CAMPOS PARA BUSQUEDA POR DNI */
/*--------------------------------------------*/
function f_validaCamposDNI()
{
    apellido = document.getElementById('dni1').apellido;
    localizador = document.getElementById('dni1').localizador;
    origen = document.getElementById('dni1').origen;
    busqueda = document.getElementById('dni1').busqueda;

    // Comprobamos que los campos del formulario no esten vac?os.
    //-----------------------------------------------------------

    // Campo apellido vac?o. Error
    if (f_campoVacio(apellido, document.getElementById('dni1').apellidoErrorVacio.value)==-1) return -1

    // Campo localizador vac?o. Error
    if (f_campoVacio(localizador, document.getElementById('dni1').localizadorErrorVacio.value)==-1) return -1

    // Campo origen vac?o. Error
    if (f_campoVacio(origen, document.getElementById('dni1').origenErrorVacio.value)==-1) return -1

    return 0;
}

/* VALIDACI?N DE CAMPOS PARA BUSQUEDA POR PASAPORTE */
/*--------------------------------------------------*/
function f_validaCamposPasaporte()
{
    apellido = document.getElementById('pasaporte').apellido;
    localizador = document.getElementById('pasaporte').localizador;
    origen = document.getElementById('pasaporte').origen;
    busqueda = document.getElementById('pasaporte').busqueda;

    // Comprobamos que los campos del formulario no esten vac?os.
    //-----------------------------------------------------------

    // Campo apellido vac?o. Error.
    if (f_campoVacio(apellido, document.getElementById('pasaporte').apellidoErrorVacio.value)==-1) return -1

    // Campo localizador vac?o. Error.
    if (f_campoVacio(localizador, document.getElementById('pasaporte').localizadorErrorVacio.value)==-1) return -1

    // Campo origen vac?o. Error.
    if (f_campoVacio(origen, document.getElementById('pasaporte').origenErrorVacio.value)==-1) return -1

    return 0;
}

/* VALIDACI?N DE CAMPOS PARA BUSQUEDA POR TARJETA IBERIA PLUS */
/*------------------------------------------------------------*/
function f_validaCamposTarjetaIberiaPlus()
{
    apellido = document.getElementById('tarjetaIberiaPlus').apellido;
    localizador = document.getElementById('tarjetaIberiaPlus').localizador;
    origen = document.getElementById('tarjetaIberiaPlus').origen;
    busqueda = document.getElementById('tarjetaIberiaPlus').busqueda;

    // Comprobamos que los campos del formulario no esten vac?os.
    //-----------------------------------------------------------

    // Campo tarjeta Apellido vac?o. Error.
    if (f_campoVacio(apellido, document.getElementById('tarjetaIberiaPlus').apellidoErrorVacio.value)==-1)
    {
        // Error
        return -1
    }

    // Campo tarjeta iberia plus vac?o.
    if (f_campoVacio(localizador, document.getElementById('tarjetaIberiaPlus').localizadorErrorVacio.value)==-1)
    {
        // Error
        return -1
    }

	//Comprobaciones de FF y pin adicionales
    var resultOK=false;
	//Guardamosel formulario de login original    
    var oldForm=formularioLogin;
    //Establecemos el nuevo
    formularioLogin="document.forms['ckiFFCheckForm']";    
    var theForm=eval(formularioLogin);
    //Ponemos los valores y validamos
    theForm.vLogin.value=apellido.value;
    theForm.vPassword.value=localizador.value;
    result=ValidFormLogin();
    //Restauramos formulario original
    formularioLogin=oldForm;
    if (!result)
    	return -1;
    //Fin comprobaciones de FF y pin adicionales
	        

    // Campo origen vac?o.
    if (f_campoVacio(origen, document.getElementById('tarjetaIberiaPlus').origenErrorVacio.value)==-1)
    {
        // Error
        return -1
    }

    return 0;
}

/* VALIDACI?N DE CAMPOS PARA BUSQUEDA POR CODIGO DE RESERVA */
/*----------------------------------------------------------*/
function f_validaCamposCodigoReserva()
{
    apellido = document.getElementById('codigoReserva').apellido;
    localizador = document.getElementById('codigoReserva').localizador;
    origen = document.getElementById('codigoReserva').origen;
    busqueda = document.getElementById('codigoReserva').busqueda;

    // Comprobamos que los campos del formulario no esten vac?os.
    //-----------------------------------------------------------

    // Campo apellido vac?o.
    if (f_campoVacio(apellido, document.getElementById('codigoReserva').apellidoErrorVacio.value)==-1)
    {
        // Error
        return -1
    }

    // Campo localizador vac?o.
    if (f_campoVacio(localizador, document.getElementById('codigoReserva').localizadorErrorVacio.value)==-1)
    {
        // Error
        return -1
    }

    // Campo origen vac?o.
    if (f_campoVacio(origen, document.getElementById('codigoReserva').origenErrorVacio.value)==-1)
    {
        // Error
        return -1
    }

    return 0;
}

/*****************************************************************/
/*  VALIDACION PARA QUE LOS CAMPOS DE TEXTO NO ESTEN VACIOS.     */
/*****************************************************************/

function f_campoVacio(campo, errorVacio)
{
    // Si se ha mostrado un mensaje de error de otra validaci?n anterior, nos salimos.
    if(error == 1)
    {
        return 0;
    }

    // Comprobamos que el campo no este vacio ni este a null.
    if(f_trim(campo.value) == '' || campo.value == null)
    {
        alert(errorVacio);
        campo.focus();
        error = 1;

        // Error
        return -1;
    }

    return 0;
}

function submitDNI()
{
    if(noPulsado){
        noPulsado=false;
        javascript:DoSubmit(document.BusquedaFormDNI,'https://www.iberia.com/OneToOne/v3/buscarPorDNI.do',{},null);
    }
}
function submitPP()
{
    if(noPulsado){
        noPulsado=false;
        javascript:DoSubmit(document.BusquedaFormPP,'https://www.iberia.com/OneToOne/v3/buscarPorPP.do',{},null);
    }
}
function submitFF()
{
    if(noPulsado){
        noPulsado=false;
        javascript:DoSubmit(document.BusquedaFormFF,'https://www.iberia.com/OneToOne/v3/buscarPorFF.do',{},null);
    }
}
function submitLOC()
{
    if(noPulsado){
        noPulsado=false;
        javascript:DoSubmit(document.BusquedaFormLOC,'https://www.iberia.com/OneToOne/v3/buscarPorLOC.do',{},null);
    }
}

function submit(form){
	form.submit();
}

function DoRedirectSubmit(form, action, attrs, target)
{
   if (form!=null)
   {

      if (action!=null)  {
         var j = action.indexOf("?");
         if ( j != -1){
           var longitud = action.length;
           var nuevaAccion = action.substring(0,j);
           var parametros =  action.substring(j+1,longitud);
           arrayOfStrings = parametros.split("&");
           action = nuevaAccion;
           for (var i=0; i < arrayOfStrings.length; i++) {
              var aux = arrayOfStrings[i];
              var longitud2 = aux.length;
              var k = aux.indexOf("=");
              if (k != -1) {
                  var clave = aux.substring(0,k);
                  var valor = aux.substring(k+1,longitud2);
                  form[clave].value = valor;
              }
          }
         }
         var jj = action.lastIndexOf("/");
         var redAccion = action.substring(0,jj);
         var redirectPage = action.substring(jj,action.length);
         form["redirectPage"].value = redirectPage;
         form.action = redAccion + "/jsp/common/redirect.jsp";
      }
      if (attrs!=null)
      {
         for (var name in attrs)
         {
            if (form[name])  {
               form[name].value = attrs[name];
            }
         }
      }

      if (target) form.target = target;
      else form.target = '_top';
      form.submit();
   }
}


var noPulsado = true;
function f_ejecutarValidaciones(tipoBusqueda)
{
    error = 0;

    switch(tipoBusqueda)
    {
        // Validaciones de campos para Busqueda por D.N.I.
        case "1":

            // Si se ha producido algun error.
            if (f_validaCamposDNI()== -1)
            {
                // Error
                return -1;
            }else{
                break;
            }

        // Validaciones de campos para Busqueda por Pasaporte.
        case "2":

            // Si se ha producido algun error.
            if (f_validaCamposPasaporte()== -1)
            {
                // Error
                return -1;
            }else{
                break;
            }

        // Validaciones de campos para Busqueda por Tarjeta Iberia Plus.
        case "3":

            // Si se ha producido algun error.
            if (f_validaCamposTarjetaIberiaPlus()== -1)
            {
                // Error
                return -1;
            }else{
                break;
            }

        // Validaciones de campos para Busqueda por C?digo de Reserva.
        case "4":

            // Si se ha producido algun error.
            if (f_validaCamposCodigoReserva()== -1)
            {
                // Error
                return -1;
            }else{
                break;
            }
    }
    return 0;
}

//check in Spanair
function ShowDetails(id) {
	if (id == 'ET') {
		document.all.item('PT').style.display = 'none';
		document.all.DocNr.value = '';
		document.all.item('ET').style.display = '';
	    /*if (document.all.item('ET').rows[1].all.tags("INPUT")[0].checked) {
			document.all.item('ETC').style.display = '';
			document.all.item('ETB').style.display = 'none';
	    } else if (document.all.item('ET').rows[3].all.tags("INPUT")[0].checked) {
			document.all.item('ETB').style.display = '';
			document.all.item('ETC').style.display = 'none';
	    } else {
			document.all.item('ETB').style.display = 'none';
			document.all.item('ET').rows[1].all.tags("INPUT")[0].checked = true;
			document.all.item('ETC').style.display = '';
	    }*/
	} else if (id == 'ETC') {
		document.all.item('PT').style.display = 'none';
		document.all.item('ETB').style.display = 'none';
		document.all.EBookingRefNr.value = '';
		document.all.DocNr.value = '';
		document.all.item('ET').style.display = '';
		document.all.item('ETC').style.display = '';
		document.all.item('ET').rows[1].all.tags("INPUT")[0].checked = true;
	} else if (id == 'ETB') {
		document.all.item('PT').style.display = 'none';
		document.all.item('ETC').style.display = 'none';
		document.all.ECardNr.value = '';
		document.all.DocNr.value = '';
		document.all.item('ET').style.display = '';
		document.all.item('ETB').style.display = '';
		//document.all.item('ET').rows[3].all.tags("INPUT")[0].checked = true;
	} else if (id == 'TP') {
		document.all.item('PT').style.display = 'none';
		document.all.item('ET').style.display = 'none';
		document.all.EBookingRefNr.value = '';
		document.all.DocNr.value = '';
		document.all.ECardNr.value = '';
		document.all.item('TP').style.display = '';
	} else {
		document.all.item('ET').style.display = 'none';
		document.all.ECardNr.value = '';
		document.all.EBookingRefNr.value = '';
		document.all.item('PT').style.display = '';
	}
}

function validar(){
	document.FindForm.submit();
}