var HM_DOM = (document.getElementById) ? true : false;
var HM_NS4 = (document.layers) ? true : false;
var HM_IE = (document.all) ? true : false;
var HM_IE4 = HM_IE && !HM_DOM;
var HM_Mac = (navigator.appVersion.indexOf("Mac") != -1);
var HM_IE4M = HM_IE4 && HM_Mac;
var HM_IsMenu = (HM_DOM || HM_NS4 || (HM_IE && !HM_IE4M));
if(!HM_IsMenu) event = null;
var zz, zv, d, fTSR;
var gBF=false;
var g_MINY = 1601;
var g_MAXY = 4500;
var g_month = 0;
var g_day = 0;
var g_year = 0;
var g_yLow = 1990;
var g_eC=null;
var g_eCV="";
var rgMC = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
d = new Date();
fTSR=0;
zv = d.getTime();
zz = "&zz="+zv;
var esletra = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-ÑñáéíóúüÁÉÍÓÚÜ&";
var esetckt = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
var esnumero = "0123456789";
var DiasPorMes=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ie5=(ie4 && navigator.userAgent.indexOf('MSIE 5')>0);
var x = 0;
var y = 0;
var trk = 0;
var offsetx=-85;
var offsety=14;
var diaSeleccionado= ""+diaSeleccionado;

function callayerWrite(txt){
    if (ns4) {
        var lyr = document.ptsDiv.document
        lyr.write(txt)
        lyr.close()
    }
    else if (ie4) document.all["calendario"].innerHTML = txt
}

function MM_SIR(){
    var i,x,a=document.MM_sr;
    for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
    x.src=x.oSrc;
}

function MM_PI(){
    var d=document;
    if(d.images){
      if(!d.MM_p) d.MM_p=new Array();
      var i,j=d.MM_p.length,a=MM_PI.arguments;
      for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0){
         d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
      }
    }
}

function MM_FO(n, d) {
    var p,i,x;
    if(!d) d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) x=d.all[n];
    for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_FO(n,d.layers[i].document); return x;
}

function MM_SI(){
    var i,j=0,x,a=MM_SI.arguments;
    document.MM_sr=new Array;
    for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_FO(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*Escribe los options con valores desde ini hasta fi de 1 en 1*/
var fechaActual = new Date();
var iniAnio = fechaActual.getYear();
function escriu_options1(ini, fi, sel){
	var i=parseInt(ini);
	while (i<=parseInt(fi)){
		if (sel!='' && i==parseInt(sel,10))
			document.write('<option selected="selected">'+i+'</option>');
		else
			document.write("<option value='"+i+"'>"+i+"</option>");
		i++;
	}
}

/*Como escriu_options pero para el anio*/
function anyo_options(ini, fi, sel){
	var i=parseInt(ini);
	while (i<=parseInt(fi)){
		if (i==iniAnio)
			document.write("<option selected value='"+i+"'>"+i+"</option>");
		else
			document.write("<option value='"+i+"'>"+i+"</option>");
		i++;
	}
}

var elementType;
var fe_dia ;
var fe_mes;
var fe_anyo;
var fs_dia;
var	fs_mes;
var fs_anyo;
var fe;
var fs;

function Calendario(tipo,pais_an,x ,y, elementTyp, fe_di, fe_me, fe_any, fs_di, fs_me, fs_any, fe_date, fs_date){
     elementType = elementTyp;
     fe_dia = fe_di;
     fe_mes = fe_me;
     fe_anyo =  fe_any;
     fs_dia =  fs_di;
     fs_mes = fs_me;
     fs_anyo = fs_any;
     fe = fe_date;
     fs = fs_date;
	// Las fechas q se seleccionen en el calendario desplegable pueden querer ser almacenadas en 2 tipos de elementos del formulario
	//desde el que se llama al calendario:
	// - o en un type select, en cuyo caso tendremos una select para el dia de entrada (fe_dia), otra para el mes de entrada(fe_mes), año de entrada
	//(fe_anyo), dia de salida (fs_dia), mes de salida (fs_mes), año de salida (fs_anyo)
	// - o en un type input text, en cuyo caso tendremos un input text para la fecha de entrada (fe) y otro para la fecha de salida (fs)
	if ( elementType ==null){
		elementType = 'input';
		fe = document.AIR.fechaI;
		fs = document.AIR.fechaV;
	}
    if (x!=null){
       xCalendario=x;
       yCalendario=y;
    }else{
       xCalendario="245";
       yCalendario="320";
    }
	tipoFecha=tipo;
	pais=pais_an;
	if (calendario.style.visibility=="visible")	{
	   cerrarCalendario();
  	   return;
	}
	abrirCalendario(tipo);
}

function showObject(obj){
	if (ns4) obj.visibility = "show"
	else if (ie4) obj.visibility = "visible"
}

function hideObject(obj){
	if (ns4) obj.visibility = "hide"
	else if (ie4) obj.visibility = "hidden"
}

var nombresMeses = new Array("ENERO", "FEBRERO", "MARZO", "ABRIL", "MAYO", "JUNIO", "JULIO", "AGOSTO", "SEPTIEMBRE", "OCTUBRE", "NOVIEMBRE", "DICIEMBRE");
function abrirCalendario(tipoFecha){
  try{cerrarCalendario();}catch(err){}
  var text_cal="";
  fecha_real =new Date();
  anio_real = fecha_real.getFullYear();
  mes_real = fecha_real.getMonth();
  dia_real = fecha_real.getDate();
  if (tipoFecha=='I')  {
     if (elementType.toLowerCase()=='input'){
		 fechaInputSeleccionada=fe.value.substring(fe.value.indexOf("/"),fe.value.length);
		 diaYaSeleccionado=1*fe.value.substring(0,fe.value.indexOf('/'));
	 } else {
		 if (fe_mes.options[fe_mes.selectedIndex].value.length==1) {
			fechaInputSeleccionada='/'+'0'+fe_mes.options[fe_mes.selectedIndex].value+'/'+fe_anyo.options[fe_anyo.selectedIndex].value.substring(2,4);
		 } else {
			fechaInputSeleccionada='/'+fe_mes.options[fe_mes.selectedIndex].value+'/'+fe_anyo.options[fe_anyo.selectedIndex].value.substring(2,4);
		 }
		 if (fe_dia.options[fe_dia.selectedIndex].value.length==1) {
			diaYaSeleccionado='0'+fe_dia.options[fe_dia.selectedIndex].value;
  		 } else {
			diaYaSeleccionado=fe_dia.options[fe_dia.selectedIndex].value;
         }
	 }
  }
  else if(tipoFecha=='V') {
     if (elementType.toLowerCase()=='input'){
		 fechaInputSeleccionada=fs.value.substring(fs.value.indexOf("/"),fs.value.length);
		 diaYaSeleccionado=1*fs.value.substring(0,fs.value.indexOf('/'));
	 } else {
  		if (fs_mes.options[fs_mes.selectedIndex].value.length==1) {
  			fechaInputSeleccionada='/'+'0'+fs_mes.options[fs_mes.selectedIndex].value+'/'+fs_anyo.options[fs_anyo.selectedIndex].value.substring(2,4);
		} else {
			fechaInputSeleccionada='/'+fs_mes.options[fs_mes.selectedIndex].value+'/'+fs_anyo.options[fs_anyo.selectedIndex].value.substring(2,4);
	    }
		if (fs_dia.options[fs_dia.selectedIndex].value.length==1) {
			diaYaSeleccionado='0'+fs_dia.options[fs_dia.selectedIndex].value;
  		} else {
			diaYaSeleccionado=fs_dia.options[fs_dia.selectedIndex].value;
        }
	 }
  }else if (tipoFecha=='CI') {
     fechaInputSeleccionada=document.FormRicerca.calendarioI.value.substring(document.FormRicerca.calendarioI.value.indexOf("/"),document.FormRicerca.calendarioI.value.length);
     diaYaSeleccionado=1*document.FormRicerca.calendarioI.value.substring(0,document.FormRicerca.calendarioI.value.indexOf('/'));
  }
  else if (tipoFecha=='CV'){
	 fechaInputSeleccionada=document.FormRicerca.calendarioV.value.substring(document.FormRicerca.calendarioV.value.indexOf("/"),document.FormRicerca.calendarioV.value.length);
     diaYaSeleccionado=1*document.FormRicerca.calendarioV.value.substring(0,document.FormRicerca.calendarioV.value.indexOf('/'));
  }
  else if (tipoFecha=="FI") {
	 fechaInputSeleccionada=fe.value;
	 diaYaSeleccionado=fe.value;
  }
  else if (tipoFecha=="FV"){
	 fechaInputSeleccionada=fe.value; 
	 diaYaSeleccionado=fe.value;
  }
  ano = "" +Hoy.getYear();
  mes = (Hoy.getMonth()+1);
  mes = (mes<10?"0":"")+mes;
  fechaSeleccionada="/"+mes+"/"+ano.substring(2,4);

  var Anyo=Hoy.getYear(); //Si el año es anterior a 2000 debe sumarse 1900 a la cantidad obtenida
  //El anyo se contabiliza a partir de 1900
  var EsteDia=Hoy.getDate();

  //Actualizacion del mes de Febrero (por los anyos bisiestos)
  if (((Anyo % 4 == 0) && (Anyo % 100 != 0)) || (Anyo % 400 == 0))
  DiasPorMes[1] = 29;
  //Numero de dias del mes actual
  NDias =DiasPorMes[Hoy.getMonth()];

  //Calculo que dia de la semana es el primero del mes
  PrimerDia=Hoy;
  PrimerDia.setDate(1);
  //Obtengo el dia de hoy (p.e, 10-11-1999) y calculo q dia de la semana
  //es el dia 1 del mismo mes y anyo (p.e, 1-11-1999)

  Comienzo=PrimerDia.getDay();
  if (Comienzo==0) Comienzo=6;
  else Comienzo=PrimerDia.getDay()-1;

  //Escritura en la pantalla de la tabla correspondiente al mes actual 
  text_cal="<div id='calendario' style='position:absolute; VISIBILITY: hidden;z-index=28;left:"+xCalendario+";top:"+yCalendario+"'>"
  text_cal=text_cal+"<TABLE BORDER=0 cellspacing=0 cellpadding=1><tr><td>" 
  text_cal=text_cal+"<TABLE BORDER=0 cellspacing=0 cellpadding=1 bgcolor=000000 width=150>"
  text_cal=text_cal+"<tr><td>"
  text_cal=text_cal+"<TABLE BORDER=0 height='150' cellspacing=0 cellpadding=0 bgcolor=FFFFFF>"
  text_cal=text_cal+"<TR class=titular_blanco height=15>" 

   //Escribo el nombre del mes en la cabecera de la tabla
   if (Hoy.getMonth() == mes_real && Hoy.getFullYear() == anio_real)
     text_cal=text_cal+"<TD align=left width=20>&nbsp;"
   else
     text_cal=text_cal+"<TD align=center width='20'><a href='Javascript:void(0);' onMouseOut='MM_SIR();' onMouseOver='MM_SI(\"atras\",\"\",\"/pictures/"+pais+"/pic012.gif\",1);' onClick='mesAtras(\""+tipoFecha+"\");MM_SIR();'><img name='atras' src='/pictures/"+pais+"/pic012.gif' border=0 ></a>";
	 text_cal=text_cal+"</TD>"
 	 text_cal=text_cal+'<td COLSPAN=6 align=center>'+nombresMeses[Hoy.getMonth()*1]

   //Los meses se numeran desde 0 hasta 11
   text_cal=text_cal+" "
   text_cal=text_cal+Anyo
   text_cal=text_cal+"</TR>"
   text_cal=text_cal+"<tr><td colspan=7 bgcolor=000000><img src='/pictures/rmbes/t.gif' height=1 border=0></td></tr>"
      if (typeof(DiasSemana)!='undefined')   {
			text_cal=text_cal+"<TR class=tit_rojo_calendario><td align=center>"+DiasSemana[0]+"<td align=center>"+DiasSemana[1]+"<td align=center>"+DiasSemana[2]+"<td align=center>"+DiasSemana[3]+"<td align=center>"+DiasSemana[4]+"<td align=center>"+DiasSemana[5]+"<td align=center>"+DiasSemana[6]+"</TR>"
	  } else {
			text_cal=text_cal+"<TR class=tit_rojo_calendario height=15><td align=center>L<td align=center>M<td align=center>X<td align=center>J<td align=center>V<td align=center>S<td align=center>D</TR>"
	  }
    text_cal=text_cal+"<tr><td colspan=7 bgcolor=000000><img src='/pictures/rmbes/t.gif' height=1 border=0></td></tr>"

 //Escritura de los espacios en blanco de la tabla
  text_cal=text_cal+"<TR>"
  columna=0;
  for (i=0; i<Comienzo; i++){
    text_cal=text_cal+"<TD>"
    columna++;
    text_cal=text_cal+"</TD>"
  }
 //Escritura de los dias del mes
 for (i=1; i<=NDias; i++) {
      text_cal=text_cal+"<TD class=diasCalendario width='20'>"
        if ((i == diaYaSeleccionado)&&(fechaInputSeleccionada == fechaSeleccionada))
           estilo="class='azul'";
        else if (columna == 6)
           estilo="class='rojo_calendario'";
        else 
           estilo="class='normal'";
   if ( Hoy.getMonth() == mes_real && Hoy.getFullYear() == anio_real && i < dia_real)
        text_cal=text_cal+"<center><font face='Verdana, Arial, Helvetica, sans-serif' color='#CCCCCC' size='1'>"+i+"</font></center>"
   else
        text_cal=text_cal+"<center><div id="+i+" style='cursor:hand' onclick='javascript:diaSeleccionado="+i+";verDiaSeleccionado(\""+tipoFecha+"\",\"S\")'><a href='Javascript:void(null)' "+estilo+">"+i+"</a></div></center>"
        if (i == EsteDia || columna == 6)
           text_cal=text_cal
        else if (columna == 0)
           text_cal=text_cal
        text_cal=text_cal+"</TD>"
		columna++;
        if (columna == 7){
        	text_cal=text_cal+"</TR><TR>";
            columna=0;
        }
    }
  text_cal=text_cal+"</TR>"
  text_cal=text_cal+"<TR>"
  text_cal=text_cal+"<TD colspan=5></td><td colspan=2 align=right><a href='Javascript:void(null)' onClick='cerrarCalendario()'><img src='/pictures/"+pais+"/pic014.gif' border=0 ></a>"
  text_cal=text_cal+"</TD>"
  text_cal=text_cal+"</TR>"
  text_cal=text_cal+"</TABLE>"
  text_cal=text_cal+"</TD>"
  text_cal=text_cal+"</TR>"
  text_cal=text_cal+"</TABLE>"
  text_cal=text_cal+"</td>"

//metemos el segundo calendario.
if (Hoy.getMonth()==11){
  	mesActual=0;
  	anoActual=Hoy.getYear()+1;
}
else{
    mesActual=Hoy.getMonth()+1;
    anoActual=Hoy.getYear();
}
HoyCal2=new Date(anoActual,mesActual,1);
Anyo=HoyCal2.getYear(); //Si el año es anterior a 2000 debe sumarse 1900 a la cantidad obtenida
//El anyo se contabiliza a partir de 1900
EsteDia=HoyCal2.getDate();
//Actualizacion del mes de Febrero (por los anyos bisiestos)
if (((Anyo % 4 == 0) && (Anyo % 100 != 0)) || (Anyo % 400 == 0))
  DiasPorMes[1] = 29;
//Numero de dias del mes actual
NDias =DiasPorMes[HoyCal2.getMonth()];
//Calculo que dia de la semana es el primero del mes
PrimerDia=HoyCal2;
PrimerDia.setDate(1);
//Obtengo el dia de hoy (p.e, 10-11-1999) y calculo que dia de la semana
//es el dia 1 del mismo mes y anyo (p.e, 1-11-1999)

  Comienzo=PrimerDia.getDay();
  if (Comienzo==0) Comienzo=6;
  else Comienzo=PrimerDia.getDay()-1;

   text_cal=text_cal+"<td>"
   text_cal=text_cal+"<TABLE BORDER=0 cellspacing=0 cellpadding=1 bgcolor=000000 width=150>"
   text_cal=text_cal+"<tr><td>"
   text_cal=text_cal+"<TABLE BORDER=0 height='150' cellspacing=0 cellpadding=0 bgcolor=FFFFFF>"
   text_cal=text_cal+"<TR class=titular_blanco height=15>" 

   // Escribo en nombre del mes en la cabecera de la tabla
   if (HoyCal2.getMonth() == mes_real && Hoy.getFullYear() == anio_real )
     text_cal=text_cal+"<TD align=left width=20>&nbsp;"
   else
     text_cal=text_cal+'<td COLSPAN=6 align=center>'+nombresMeses[HoyCal2.getMonth()*1]

   //Los meses se numeran desde 0 hasta 11
   text_cal=text_cal+" "
   text_cal=text_cal+Anyo
   text_cal=text_cal+"<TD align=center width='20'><a href='Javascript:void(0)'  onMouseOut='MM_SIR();' onMouseOver='MM_SI(\"atras2\",\"\",\"/pictures/"+pais+"/pic013.gif\",1);' onClick='mesAdelante(\""+tipoFecha+"\");'  ><img name='atras2' src='/pictures/"+pais+"/pic013.gif' border=0 ></a>";
   text_cal=text_cal+"</TD></TR>"
   text_cal=text_cal+"<tr><td colspan=7 bgcolor=000000><img src='/pictures/rmbes/t.gif' height=1 border=0></td></tr>"
   if (typeof(DiasSemana)!='undefined'){
	 text_cal=text_cal+"<TR class=tit_rojo_calendario><td align=center>"+DiasSemana[0]+"<td align=center>"+DiasSemana[1]+"<td align=center>"+DiasSemana[2]+"<td align=center>"+DiasSemana[3]+"<td align=center>"+DiasSemana[4]+"<td align=center>"+DiasSemana[5]+"<td align=center>"+DiasSemana[6]+"</TR>"
   } else {
   	 text_cal=text_cal+"<TR class=tit_rojo_calendario height=15><td align=center>L<td align=center>M<td align=center>X<td align=center>J<td align=center>V<td align=center>S<td align=center>D</TR>"
   }
   text_cal=text_cal+"<tr><td colspan=7 bgcolor=000000><img src='/pictures/rmbes/t.gif' height=1 border=0></td></tr>"

  //Escritura de los espacios en blanco de la tabla
   text_cal=text_cal+"<TR>"
   columna=0;
   for (i=0; i<Comienzo; i++){
        text_cal=text_cal+"<TD>"
        columna++;
        text_cal=text_cal+"</TD>"
    }

   // Escritura de los dias del mes
   for (i=1; i<=NDias; i++){
      text_cal=text_cal+"<TD class=diasCalendario width='20'>"
        if ((i == diaYaSeleccionado)&&(fechaInputSeleccionada == fechaSeleccionada))
           estilo="class='azul'";
        else if (columna == 6)
           estilo="class='rojo_calendario'";
        else 
           estilo="class='normal'";                          
		
   if (HoyCal2.getMonth() == mes_real && HoyCal2.getFullYear() == anio_real && i < dia_real)
        text_cal=text_cal+"<center><font color='#CCCCCC'>"+i+"</font></center>"
   else
        text_cal=text_cal+"<center><div id="+i+" style='cursor:hand' onclick='javascript:diaSeleccionado="+i+";verDiaSeleccionado(\""+tipoFecha+"\",\"I\")'><a href='Javascript:void(null)' "+estilo+">"+i+"</a></div></center>"
        if (i == EsteDia || columna == 6)
             text_cal=text_cal
        else if (columna == 0)
             text_cal=text_cal
        text_cal=text_cal+"</TD>"
		columna++;
        if (columna == 7){
        	text_cal=text_cal+"</TR><TR>";
            columna=0;
        }
    }

  text_cal=text_cal+"</TR>"
  text_cal=text_cal+"<TR>"
  text_cal=text_cal+"<TD colspan=5></td><td colspan=2 align=right><a href='Javascript:void(null)' onClick='cerrarCalendario()'><img src='/pictures/"+pais+"/pic014.gif' border=0 ></a>"
  text_cal=text_cal+"</TD>"
  text_cal=text_cal+"</TR>"
  text_cal=text_cal+"</TABLE>"
  text_cal=text_cal+"</TD>"
  text_cal=text_cal+"</TR>"
  text_cal=text_cal+"</TABLE>"
  text_cal=text_cal+"</td></tr></table>"
  text_cal=text_cal+"</div>"
  text_cal=text_cal+"<iframe id='DivShim' src='javascript:false;' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; display:none;'></iframe>";

  calendario.outerHTML = text_cal;
  calendario.style.visibility = "visible";
  var IfrRef = document.getElementById('DivShim');
  IfrRef.style.width = calendario.offsetWidth;
  IfrRef.style.height = calendario.offsetHeight;
  IfrRef.style.top = calendario.style.top;
  IfrRef.style.left	= calendario.style.left;
  IfrRef.style.zIndex = calendario.style.zIndex - 1;
  IfrRef.style.display = "block";
}//fin de abrir calendario

function cerrarCalendario(){
     calendario.style.visibility="hidden";
     var IfrRef = document.getElementById('DivShim');
     IfrRef.style.display = "none";
}

function verDiaSeleccionado(tipoFecha,cual){
//miramos si el calendario es el superior o el inferior
	if(cual=="S"){
		mesActual=Hoy.getMonth()+1;
		anoActual=Hoy.getYear();
	}
	else if(cual=="I"){
		mesActual=HoyCal2.getMonth()+1;
		anoActual=HoyCal2.getYear();
	}
	anoActual=""+anoActual;
	mesActual= ""+mesActual;
	mesActual = mesActual.length==2 ? mesActual : "0"+mesActual;
	diaSeleccionado= ""+diaSeleccionado;
	diaSeleccionado = diaSeleccionado.length==2 ? diaSeleccionado : "0"+diaSeleccionado;
	
	if (tipoFecha=="I"){
	if (elementType=='input'){
		fe.value=diaSeleccionado+"/"+mesActual+"/"+anoActual.substring(2,4);
	}else{
	i=0; 
	while (i<fe_dia.length){
       if ((fe_dia[i].value==diaSeleccionado&&fe_dia[i].value.length==2)||('0'+fe_dia[i].value==diaSeleccionado&&fe_dia[i].value.length==1)){
		index=i;
		break;
       }
	   i++;
	}
	i=0;
	fe_dia.selectedIndex=index;
	while (i<fe_mes.length){
       if ((fe_mes[i].value==mesActual&&fe_mes[i].value.length==2)||('0'+fe_mes[i].value==mesActual&&fe_mes[i].value.length==1)) {
		index=i;
		break;
       }
	   i++;
	}
	i=0;
	fe_mes.selectedIndex=index;
	while (i<fe_anyo.length){
       if (fe_anyo[i].value.substring(2,4)==anoActual.substring(2,4)){
		index=i;
		break;
       }
	   i++;
	}
	fe_anyo.selectedIndex=index;
	actualizar_fS(fe_dia);
    i=0;
	}
}
else if (tipoFecha=="V"){
	 if (elementType=='input'){
		document.AIR.fechaV.value=diaSeleccionado+"/"+mesActual+"/"+anoActual.substring(2,4);
	 } else {
	    i=0;
		while (i<fs_dia.length)	{
		   if ((fs_dia[i].value==diaSeleccionado&&fs_dia[i].value.length==2)||('0'+fs_dia[i].value==diaSeleccionado&&fs_dia[i].value.length==1)){
			 index=i;
			 break;
		   }
		i++;
		}
		i=0;
		fs_dia.selectedIndex=index;
		while (i<fs_mes.length)	{
		   if ((fs_mes[i].value==mesActual&&fs_mes[i].value.length==2)||('0'+fs_mes[i].value==mesActual&&fs_mes[i].value.length==1))   {
			index=i;
			break;  }
		   i++;
		}
		i=0;
		fs_mes.selectedIndex=index;
		while (i<fs_anyo.length){
		   if (fs_anyo[i].value.substring(2,4)==anoActual.substring(2,4)){
			index=i;
			break;
		   }
		   i++;
		}
		fs_anyo.selectedIndex=index;
		actualizar_Noches(fs_dia);
	 }
}
else if (tipoFecha=="CI") {
	document.FormRicerca.calendarioI.value=diaSeleccionado+"/"+mesActual+"/"+anoActual.substring(2,4);
}
else if (tipoFecha=="CV"){
	document.FormRicerca.calendarioV.value=diaSeleccionado+"/"+mesActual+"/"+anoActual.substring(2,4);
}
else if (tipoFecha=="FI") {
	fe.value=diaSeleccionado;
	fs.value=anoActual+mesActual;
}
else if (tipoFecha=="FV"){
	fe.value=diaSeleccionado;
	fs.value=anoActual+mesActual;
}
cerrarCalendario();
}//fin verDiaSeleccionado

function mesAtras(tipoFecha, elementType, fe_dia, fe_mes, fe_anyo, fs_dia, fs_mes, fs_anyo, fe, fs){
	if (Hoy.getMonth()==0){
		mesActual=11;
		anoActual=Hoy.getYear()-1;
	}else{
		mesActual=Hoy.getMonth()-1;
		anoActual=Hoy.getYear();
	}
    Hoy=new Date(anoActual,mesActual,1);
    abrirCalendario(tipoFecha, elementType, fe_dia, fe_mes, fe_anyo, fs_dia, fs_mes, fs_anyo, fe, fs);
}

function mesAdelante(tipoFecha){
	if (Hoy.getMonth()==11){
	  	mesActual=0;
	  	anoActual=Hoy.getYear()+1;
	}else{
		mesActual=Hoy.getMonth()+1;
		anoActual=Hoy.getYear();
	}
	Hoy=new Date(anoActual,mesActual,1);
	abrirCalendario(tipoFecha);
}

function vacio(){}

function Trim(cad){
   var aux="";
   var i,lg = cad.length;
   for (;lg>0 && cad.charAt(lg-1)==' ';lg--);
   for (i=0;i<lg && cad.charAt(i)==' ';i++);
   for (;i<lg;i++)
       aux = aux + cad.charAt(i);
   return aux;
}

function actualizar_fS(childForm){
     //Busco el formulario al q pertenece el elemento
	 var form;
	 salir  =false;
	 for (i=0;i<document.forms.length ;i++ )	 {
		 for (k=0;k<document.forms[i].length ;k++ )		 {
	 		 if (document.forms[i].elements[k]==childForm){
                 form=document.forms[i];
				 salir=true;
                 break;
             }
		 }
		 if (salir==true) break;
	 }

     if (!isNaN(parseInt(form.fe_dia.options[form.fe_dia.selectedIndex].text,10)) &&
	     !isNaN(parseInt(form.fe_mes.options[form.fe_mes.selectedIndex].text,10)) &&
		 !isNaN(parseInt(form.fe_anyo.options[form.fe_anyo.selectedIndex].text,10)) &&
		 !isNaN(parseInt(form.noches.options[form.noches.selectedIndex].text,10))){
  	    var dia= parseInt(form.fe_dia.options[form.fe_dia.selectedIndex].text,10);
		var mes= parseInt(form.fe_mes.options[form.fe_mes.selectedIndex].text,10);
		var any= parseInt(form.fe_anyo.options[form.fe_anyo.selectedIndex].text,10);
		dia= dia + parseInt(form.noches.options[form.noches.selectedIndex].text,10);
		if (dia > getDaysInMonth(mes-1,any)){
			dia = dia - getDaysInMonth(mes-1,any);
			mes ++;
			if (mes > 12){
				mes = mes - 12;
				any ++;
			}
		}
		form.fs_dia.selectedIndex = dia; 
		form.fs_mes.selectedIndex = mes; 
		i = 0;
    	 while (i < form.fs_anyo.length ) {
			if (form.fs_anyo.options[i].text == any.toString(10)){ 
				form.fs_anyo.selectedIndex = i;
				return;
			}
			else i++;
		}
	 }
	 return;
}

function actualizar_Noches(childForm){
	 var form;
	 salir =false;
	 for (i=0;i<document.forms.length ;i++ ){
		 for (k=0;k<document.forms[i].length ;k++ ){
	 		 if (document.forms[i].elements[k]==childForm){
                 form=document.forms[i];
				 salir=true;
                 break;
             }
		 }
		 if (salir==true) break;
	 }
	 if ( !isNaN(parseInt(form.fs_dia.options[form.fs_dia.selectedIndex].text,10)) &&
	     !isNaN(parseInt(form.fs_mes.options[form.fs_mes.selectedIndex].text,10)) &&
		 !isNaN(parseInt(form.fs_anyo.options[form.fs_anyo.selectedIndex].text,10)) &&
		 !isNaN(parseInt(form.fe_dia.options[form.fe_dia.selectedIndex].text,10)) &&
	     !isNaN(parseInt(form.fe_mes.options[form.fe_mes.selectedIndex].text,10)) &&
		 !isNaN(parseInt(form.fe_anyo.options[form.fe_anyo.selectedIndex].text,10))){
		var diaE= parseInt(form.fe_dia.options[form.fe_dia.selectedIndex].text,10);
		var mesE= parseInt(form.fe_mes.options[form.fe_mes.selectedIndex].text,10);
		var anyE= parseInt(form.fe_anyo.options[form.fe_anyo.selectedIndex].text,10);
		var diaS= parseInt(form.fs_dia.options[form.fs_dia.selectedIndex].text,10);
		var mesS= parseInt(form.fs_mes.options[form.fs_mes.selectedIndex].text,10);
		var anyS= parseInt(form.fs_anyo.options[form.fs_anyo.selectedIndex].text,10);
		var nits;
		
		if ( ( (anyS>anyE) || (anyS==anyE && mesS>mesE) ) || ((anyS==anyE && mesS==mesE) && diaS>diaE) ){
			if (diaE==diaS && mesE==mesS && anyE==anyS)	{
				nits=0;
			}else {
				nits=0;
				while (diaE!=diaS || mesE!=mesS || anyE!=anyS){
					diaE++; nits++;
					if (diaE > getDaysInMonth(mesE-1,anyE)){
						diaE = diaE - getDaysInMonth(mesE-1,anyE);
						mesE ++;
						if (mesE > 12){
							mesE = mesE - 12;
							anyE ++;
						}
					}
				}
			}
		}
		else //fs es anterior a fe!
			nits=0;
		if (nits > 0 && nits < form.noches.length)
			form.noches.selectedIndex = nits;
		else
			form.noches.selectedIndex = 0;
	}
	return;
}

function es_numero(cadena,lg){
   if (lg != cadena.length)  {return 1;}
   for (i=0;i<cadena.length;i++)
   if (esnumero.indexOf(cadena.charAt(i))==-1){return 1;}
   return 0;
}

function es_etckt (cadena){
   lg = cadena.length;
   guion = 0;
   if (lg == 0) {return 1};
   for (i=0;i<cadena.length;i++){
	if (esetckt.indexOf("-")){
		guion = guion + 1;
		if (guion == 2){return 1;}
	}
   	if (esetckt.indexOf(cadena.charAt(i))==-1){return 1;}
   }
   return 0;
}

function es_letra (cadena){
   lg = cadena.length;
   if (lg == 0) {return 1};
   for (i=0;i<cadena.length;i++)
   if (esletra.indexOf(cadena.charAt(i))==-1){return 1;}
   return 0;
}

function initForm() {
  if (navigator.userAgent.indexOf('Gecko') != -1) {
	  document.AIR.D_Day_sel.selectedIndex = 0;
	  document.AIR.R_Day_sel.selectedIndex = 0;
	  document.AIR.D_Month_sel.selectedIndex = 0;
	  document.AIR.R_Month_sel.selectedIndex = 0;
  }
}

function valorFecha(valor) {
  var monthYear_I = document.AIR.D_Month_sel.options[document.AIR.D_Month_sel.selectedIndex].value;
  var monthYear_V = document.AIR.R_Month_sel.options[document.AIR.R_Month_sel.selectedIndex].value;
  var month_I = monthYear_I.substring(4,6);
  var month_V = monthYear_V.substring(4,6);
  var year_I = monthYear_I.substring(2,4);
  var year_V = monthYear_V.substring(2,4);
  var new_fechaI = document.AIR.D_Day_sel.options[document.AIR.D_Day_sel.selectedIndex].value + "/" + month_I + "/" + year_I;
  var new_fechaV = document.AIR.R_Day_sel.options[document.AIR.R_Day_sel.selectedIndex].value + "/" + month_V + "/" + year_V;
  if (valor=='I') {
	  return new_fechaI;
  } else{
	  return new_fechaV;
  }
}

function check_data(flight_type){
    checkstr = "";
    with(document.AIR) {
        tipo_vuelo.value = flight_type;
        SEARCH_BY.value = flight_type;
	var num_adultos = NUMBER.selectedIndex;
	var num_ninios = INFANT.selectedIndex;
	if ( (1*num_ninios + 1*num_adultos) > 5)
	   checkstr += "- "+msg1+"\n";
	if ( num_adultos == 0 ) 
	   checkstr += "- "+msg2+"\n";
	if (!GetInputDate(fechaI.value))
	   checkstr += "- "+msg3+"\n";
	else {
	var dDateValue=(g_year*100+g_month)*100+g_day;
	D_Day.value=g_day;
	D_Month.value="20" + g_year+(g_month<10?"0":"")+g_month;
	var departureDate = new Date(g_year, g_month-1, g_day, 8, 0, 0);
	if (!GetInputDate(fechaV.value))
	   checkstr += "- "+msg4+"\n";
	else {
	var rDateValue=(g_year*100+g_month)*100+g_day;
	R_Day.value=g_day;
	R_Month.value="20" + g_year+(g_month<10?"0":"")+g_month;
	if (rDateValue < dDateValue)
	   checkstr += "- "+msg5+"\n";
	}
	}
	if (D_City.value=="")
	   checkstr += "- "+msg6+"\n";
	if (A_City.value == "")
	   checkstr += "- "+msg7+"\n";
	if(checkstr!=""){
	alert(checkstr);
	return;
	}
    for (i=1 ;i<=num_adultos;i++)
    eval("PaxType"+i+".value='ADT'");
    for (i=(num_adultos+1) ;i<=(num_adultos+num_ninios);i++)
    eval("PaxType"+i+".value='CHD'");
	fecha = fechaI.value;
	pos1 = fecha.indexOf("/");
	trozo1 = fecha.substring(fecha.indexOf("/")+1);
	pos2 = trozo1.indexOf("/");
    D_Day.value = fecha.substring(0,pos1);
    D_Month.value = "20" + trozo1.substring(pos2+1,trozo1.length)+trozo1.substring(0,pos2);
	fecha = fechaV.value;
	pos1 = fecha.indexOf("/");
	trozo1 = fecha.substring(fecha.indexOf("/")+1);
	pos2 = trozo1.indexOf("/");
    R_Day.value = fecha.substring(0,pos1);
    R_Month.value = trozo1.substring(0,pos2);
    R_Month.value = "20" + trozo1.substring(pos2+1,trozo1.length)+trozo1.substring(0,pos2);
	submit();
    }
}

function openwindow(direccion, name, cadena){
  var winf = window.open(direccion,name,cadena);
  winf.focus();
} 

function abrirventana(varHttp, lenX, lenY, bScroll) {
    var winf = open(varHttp, null, "width=" + lenX + ",height=" + lenY + ",status=no,menubar=no,scrollbars=" + bScroll + ",resizable=no");
    winf.focus();
}

function GetInputDate(t) {
	var l = t.length;
	if(0 == l) return false;
	var cSp = '\0';
	var sSp1 = "";
	var sSp2 = "";
	for(var i=0; i<t.length; i++){
	var c=t.charAt(i);
	if(c==' ' || isdigit(c)) continue;
	else if(cSp == '\0' && (c == '/' || c == '-' || c == '.')) {
	cSp = c;
	sSp1 = t.substring(i+1,l);
	} else if(c==cSp) sSp2 = t.substring(i+1,l);
	else if(c != cSp) return false;
	}
	if(0 == sSp1.length) return false;
	var m=atoi(sSp1);
	var d=atoi(t);
	var y;
	if(0 != sSp2.length) y = atoi(sSp2);
	else y = DefYr(m,d);
	if(y < 100){
	y = 1900+y;
	while(y < g_yLow) y = y+100;
	}
	if(y < g_MINY || y > g_MAXY || m < 1 || m > 12) return false;
	if(d < 1 || d > GetMonthCount(m,y)) return false;
	g_month = m;
	g_day = d;
	g_year = y;
	return true;
}

function DefYr(m,d){
	var dt = new Date();
	var yCur = (dt.getYear() < 1000) ? 1900+dt.getYear() : dt.getYear();
	if(m-1 < dt.getMonth() || (m-1 == dt.getMonth() && d < dt.getDate())) return 1+yCur;
	else return yCur;
}

function atoi(s){
	var t=0;
	for(var i=0; i<s.length; i++){
	var c=s.charAt(i);
	if(!isdigit(c)) return t;
	else t = t*10 + (c-'0');
	}
	return t;
}

function isdigit(c){
	return(c >= '0' && c <= '9');
}

function GetMonthCount(m,y){
	var c = rgMC[m-1];
	if((2 == m) && IsLeapYear(y)) c++;
	return c;
}

function IsLeapYear(y){
	if(0 == y % 4 && ((y % 100 != 0) || (y % 400 == 0))) return true;
	else return false;
}

function isEmptyString(s){
   return (s == null || (typeof s == "string" && /^s*$/.test(s)));
} 

function EMailOk(s_email) {
	var addressPattern = /^[^\s\n]+\@[a-zA-Z0-9][a-zA-Z0-9\-\.]*\.[a-zA-Z]{2,4}$/;
	if (! addressPattern.test(s_email)) return false;
	return (s_email.length <= 128);
}

function DS(action, attrs, target){
	form = document.LinkForm;
    if (form != null){
        if (attrs != null){
            for (var name in attrs){
                if (form[name]){
                    form[name].value = attrs[name];
                }
            }
        }
        if (action){
            form.action = action;
        }
        if (target){
            form.target = target;
        } else {
            form.target = "_self";
        }
        form.submit();
    }
}

function QuitarAcentos(st) {
   st = st.replace(/á/gi,"a");
   st = st.replace(/à/gi,"a");
   st = st.replace(/â/gi,"a");
   st = st.replace(/ä/gi,"a");
   st = st.replace(/ª/gi,"a");

   st = st.replace(/é/gi,"e");
   st = st.replace(/è/gi,"e");
   st = st.replace(/ê/gi,"e");
   st = st.replace(/ë/gi,"e");

   st = st.replace(/ì/gi,"i");
   st = st.replace(/í/gi,"i");
   st = st.replace(/î/gi,"i");
   st = st.replace(/ï/gi,"i");

   st = st.replace(/ò/gi,"o");
   st = st.replace(/ó/gi,"o");
   st = st.replace(/ô/gi,"o");
   st = st.replace(/ö/gi,"o");

   st = st.replace(/ú/gi,"u");
   st = st.replace(/ù/gi,"u");
   st = st.replace(/û/gi,"u");
   st = st.replace(/ü/gi,"u");

   st = st.replace(/ç/gi,"c");
   return st;
}

function Location(url, elementcode, elementname){
     locCodeHolder = elementcode;
     locDescHolder = elementname;
     window.open(url,'Aeropuertos', 'resizable=yes,toolbars=no,scrollbars=yes,screenX=0,screenY=0,width=633,height=550');
}
               
function setLocationCode(code){
	locCodeHolder.value = code;
}

function setLocationDesc(name){
	locDescHolder.value = name;
}

function redondeo2decimales2(importe){
 var suma = (importe*100)%parseInt(importe*100) >=.5 ? 1 :0;
 alert("SUMA=["+suma+"]");
 var res = ((parseInt(importe*100)+suma)/100);
 alert("RESTA=["+res+"]");
 var cadena = res + "";
 alert("CADENA=["+cadena+"]");
 var longitud = cadena.length ;
 alert("LOGITUD=["+longitud+"]");
 longitud = longitud-3;
 alert("LOGITUD2=["+longitud+"]");
 if (cadena.indexOf(".") != -1) longitud=longitud-3;
 var res1 = "";
 var incremento = longitud % 3;
 if (incremento < 0){
  res1=cadena;
  return res1;
 }
 else{
  if (incremento == 0) incremento = 3;
  for (var i = 0; i < longitud;) {
     res1 += cadena.substr(i, incremento);
     i += incremento;
   if (i <= longitud){
		res1 += ",";
        incremento = 3;
   }
  }
 res1 += cadena.substr(longitud, 3);
 if (cadena.indexOf(".") != -1)  res1 += cadena.substr(longitud+3, 3);
 return res1;
 }
}

function redondeo2decimales(importe){
	var original=parseFloat(importe);
	var result=Math.round(original*100)/100;
	return result;
}

// sceciliano
// a partir de un nº pasado como string como 1er parametro, se le pone el nº de decimales especificado en su 2º parametro.
function obtainNumDecimal(campo,numDec){
	campo=campo+".";
	var array_campo = campo.split(".");
	var dec =".";
	if (array_campo[1].length < numDec ){
		dec = dec + array_campo[1];
		while (dec.length < numDec+1 )
			dec = dec+"0";
	}
	else
		dec = dec+array_campo[1].substring(0,numDec);
	campo=array_campo[0]+dec;
	return campo;
}

/*Retorna la cadena sin espacios*/
function SinEspacios(cadena){
	var s = new String(cadena);
	var i=0;
    do {
		s = s.replace(" ","");
		i=i+1;
	}
    while ((s.search(/\s*/)!=-1) && (i<15));
    return(s);
}

/*Retorna la cadena sin espacios a derecha ni a izquierda*/
function Trim(str){
  cad = LTrim(RTrim(str));
  return cad;
}

/*Retorna la cadena sin espacios a la izquierda*/
function LTrim(str){
  for (var i = 0; i < str.length && str.charAt(i) == ' '; i++);
  return str.substring(i);
}

/*Retorna la cadena sin espacios a la derecha*/
function RTrim(str){
  for (var i = str.length; i > 0 && str.charAt(i - 1) == ' '; i--);
  return str.substring(0, i);
}

/*convierte eñes en enes*/
function ene(palabra){
  for(var i=0; i<palabra.length; i++){
    if(palabra.charAt(i)=='ñ'){
          palabra=palabra.replace('ñ','n');
          i=i-1;
    }
    if(palabra.charAt(i)=='Ñ'){
          palabra=palabra.replace('Ñ','N');
          i=i-1;
    }
  }
 return palabra;
}

function Cambiar(){
	with (document.forms['frmTopLinksBar'].sCombo){
		if (options[selectedIndex].value != '#' && options[selectedIndex].value != ''){
			document.forms['frmTopLinksBar'].action = options[selectedIndex].value;
			document.forms['frmTopLinksBar'].submit();
		}
	}
}

function addcero(str){
	var str2 = "0"+str;
	return str2.substring(str2.length-2);
}

function triptype(){
	if(flightForm.rrt.checked){
		flightForm.fs_dia.disabled 	= false;
        flightForm.fs_mesanyo.disabled 	= false;
        flightForm.retTime.disabled	= false;
	}
	if(flightForm.row.checked){
		flightForm.fs_dia.disabled = true;
        flightForm.fs_mesanyo.disabled 	= true;
        flightForm.retTime.disabled	= true;
	}
}

function testbuscador(){
   flightForm.depCity.value = "MAD";
   flightForm.arrCity.value = "LON";
   flightForm.fe_dia.value	= "18";
   flightForm.fs_dia.value  = "28";
   flightForm.fe_mesanyo.value = "200710";
   flightForm.fs_mesanyo.value = "200710";
}

//solo permite escribir digitos
function onlyDigits(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true; //Tecla de retroceso (para borrar)
    patron = /\d/; // Solo acepta numeros
    te = String.fromCharCode(tecla);
    return patron.test(te);
}

//permite escribir letras y numeros, pero no simbolos raros
function onlyDigitsKeys(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true;
    patron = /\w/;
    te = String.fromCharCode(tecla);
    return patron.test(te);
}

//permite escribir letras mayusculas y minusculas, espacios y puntos
function onlyKeys(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true;
    patron =/[A-Za-z ]/;
    te = String.fromCharCode(tecla);
    return patron.test(te);
}

/* Elimina espacios en blanco */
function trim(palabra){
  for(var i=0; i<palabra.length; i++){
    if(palabra.charAt(i)==' '){
          palabra=palabra.replace(' ','');
          i=i-1;
    }
  }
 return palabra;
}

function goSubmitBuscador(dat){
var str = "";
// Quito acentos
flightForm.depCity.value = QuitarAcentos(flightForm.depCity.value);
flightForm.arrCity.value = QuitarAcentos(flightForm.arrCity.value);
var msg="";
//groupval(str, nom, islg, isln, isnm)
  msg = doconcat(msg,groupval(flightForm.depCity.value,'Ciudad de salida',1,1,0)); 
  msg = doconcat(msg,groupval(flightForm.arrCity.value,'Ciudad de llegada',1,1,0)); 
  msg = doconcat(msg,groupval(flightForm.fe_dia.options[flightForm.fe_dia.selectedIndex].value,'Dia de salida',0,1,1));
  msg = doconcat(msg,groupval(flightForm.fe_mesanyo.options[flightForm.fe_mesanyo.selectedIndex].value,'Mes de salida',0,1,1));
  var fechadep = flightForm.fe_mesanyo.options[flightForm.fe_mesanyo.selectedIndex].value + "" + flightForm.fe_dia.options[flightForm.fe_dia.selectedIndex].value;
  if (flightForm.queryType[0].checked){
     msg = doconcat(msg,groupval(flightForm.fs_dia.options[flightForm.fs_dia.selectedIndex].value,'Dia de llegada',0,1,1));
     msg = doconcat(msg,groupval(flightForm.fs_mesanyo.options[flightForm.fs_mesanyo.selectedIndex].value,'Mes de llegada',0,1,1));
     var fecharet = flightForm.fs_mesanyo.options[flightForm.fs_mesanyo.selectedIndex].value + "" + flightForm.fs_dia.options[flightForm.fs_dia.selectedIndex].value;
     if (fecharet < fechadep)
      {msg = doconcat(msg,"La fecha de llegada tiene que ser mayor que la de salida \n");}
      flightForm.owOrRt.value="R";
  } else {
  	  flightForm.owOrRt.value="O";
  }
  
    //veo si la fecha de salida es mayor de 2 dias
	var now = new Date();
	now.setTime(dat);
    now.setDate(now.getDate());
    var strnow = now.getFullYear()+""+addcero(now.getMonth()+1)+""+addcero(now.getDate());
    if (fechadep < strnow)
    {msg = doconcat(msg,"Error. No puede buscar vuelos para fechas pasadas. \n");}
   
    var nAdt = 1 * flightForm.paxAdt.options[flightForm.paxAdt.selectedIndex].value;
    var nChd = 1 * flightForm.paxChd.options[flightForm.paxChd.selectedIndex].value;
    var nInf = 1 * flightForm.paxInf.options[flightForm.paxInf.selectedIndex].value;
    if (nInf > nAdt)msg = doconcat(msg,"El número bebes no puede superar al de adultos \n");
    if ((nAdt + nChd) > 9)msg = doconcat(msg,"El número total de adúltos y niños no puede ser mayor a nueve. \n");
    if ((nInf + nChd) > (nAdt * 2) )msg = doconcat(msg,"El número bebes y niños no puede superar, al doble del numero de adultos \n");
	if(flightForm.depTime.value != "" || flightForm.retTime.value != ""){
		flightForm.resultType[1].checked = true;
	}
   
   if (msg != ''){alert(msg);}
   else{
	 str = flightForm.fe_mesanyo.value;
	 flightForm.depDate.value = flightForm.fe_dia.value+"/"+str.substring(4)+"/"+str.substring(0,4);
	 str = flightForm.fs_mesanyo.value;
	 flightForm.retDate.value = flightForm.fs_dia.value+"/"+str.substring(4)+"/"+str.substring(0,4);
	 // try{cookieForms('save', 'flightForm');}catch(err){}
	 flightForm.submit();
    }
}

function muestraCalIda(pais,ruta){
	var sp =pais;
	var path = ruta;
	var browser=navigator.appName;
	if (browser=="Microsoft Internet Explorer"){
		document.write('<!-- BEGIN CALENDARIO IE1 -->');
		document.write('<a href="javascript:Calendario(\'FV\',\''+sp+'\',432,340,\'input\',\'\',\'\',\'\',\'\',\'\',\'\',document.flightForm.fe_dia,document.flightForm.fe_mesanyo);" onMouseOut="MM_SIR();" onMouseOver="MM_SI(\'calendar1\',\'\',\''+ruta+'/pic015.gif\',1)"; ><img name="calendar1" align="absmiddle" src="'+ruta+'/pic015.gif" border=0 title="Mostrar Calendario."></a>');
		document.write('<!-- END CALENDARIO IE1 -->');
	}
}

function muestraCalVuelta(pais,ruta){
	var browser=navigator.appName;
	var sp = pais;
	var path = ruta;
	if (browser=="Microsoft Internet Explorer"){
		document.write('<!-- BEGIN CALENDARIO IE1 -->');
		document.write('<a href="javascript:Calendario(\'FV\',\''+sp+'\',432,367,\'input\',\'\',\'\',\'\',\'\',\'\',\'\',document.flightForm.fs_dia,document.flightForm.fs_mesanyo);" onMouseOut="MM_SIR();" onMouseOver="MM_SI(\'calendar1\',\'\',\''+ruta+'/pic015.gif\',1)"; >');
		document.write('<img name="calendar1" align="absmiddle" src="'+ruta+'/pic015.gif" border=0 title="Mostrar Calendario."></a>');
		document.write('<!-- END CALENDARIO IE1 -->');
	}
}


function goSubmitBuscador2007(dat){
var str = "";
// Quito acentos
flightForm.depCity.value = QuitarAcentos(flightForm.depCity.value);
flightForm.arrCity.value = QuitarAcentos(flightForm.arrCity.value);
var msg="";
//groupval(str, nom, islg, isln, isnm)
  msg = doconcat(msg,groupval(flightForm.depCity.value,'Ciudad de salida',1,1,0)); 
  msg = doconcat(msg,groupval(flightForm.arrCity.value,'Ciudad de llegada',1,1,0)); 
  msg = doconcat(msg,groupval(flightForm.fe_dia.value,'Dia de salida',0,1,1));
  msg = doconcat(msg,groupval(flightForm.fe_mesanyo.value,'Mes de salida',0,1,1));
  var fechadep = flightForm.fe_mesanyo.value + "" + flightForm.fe_dia.value;
  //comprobamos vuelos directos
	  if (flightForm.direct.checked)
	  {
	      flightForm.directOnly.value = 'S';
	  }
	  else
	  {
	      flightForm.directOnly.value = 'N';
	  }
	  
  if (flightForm.queryType[0].checked){
     msg = doconcat(msg,groupval(flightForm.fs_dia.value,'Dia de llegada',0,1,1));
     msg = doconcat(msg,groupval(flightForm.fs_mesanyo.value,'Mes de llegada',0,1,1));
     var fecharet = flightForm.fs_mesanyo.value + "" + flightForm.fs_dia.value;
     if (fecharet < fechadep)
      {msg = doconcat(msg,"La fecha de llegada tiene que ser mayor que la de salida \n");}
      flightForm.owOrRt.value="R";
	  } else {
	  	  flightForm.owOrRt.value="O";
	  }
  	  
    //veo si la fecha de salida es mayor de 2 dias
	var now = new Date();
	now.setTime(dat);
    now.setDate(now.getDate());
    var strnow = now.getFullYear()+""+addcero(now.getMonth()+1)+""+addcero(now.getDate());
    //if (fechadep < strnow)
    //{msg = doconcat(msg,"Error. No puede buscar vuelos para fechas pasadas. \n");}
   
    var nAdt = 1 * flightForm.paxAdt.options[flightForm.paxAdt.selectedIndex].value;
    var nChd = 1 * flightForm.paxChd.options[flightForm.paxChd.selectedIndex].value;
    var nInf = 1 * flightForm.paxInf.options[flightForm.paxInf.selectedIndex].value;
    if (nInf > nAdt)msg = doconcat(msg,"El número bebes no puede superar al de adultos \n");
    if ((nAdt + nChd) > 9)msg = doconcat(msg,"El número total de adúltos y niños no puede ser mayor a nueve. \n");
    if ((nInf + nChd) > (nAdt * 2) )msg = doconcat(msg,"El número bebes y niños no puede superar, al doble del numero de adultos \n");
	if(flightForm.depTime.value != "" || flightForm.retTime.value != ""){
		flightForm.resultType[1].checked = true;
	}
   
   if (msg != ''){alert(msg);}
   else{
	 str = flightForm.fe_mesanyo.value;
	 flightForm.depDate.value = flightForm.fe_dia.value+"/"+str.substring(4)+"/"+str.substring(0,4);
	 str = flightForm.fs_mesanyo.value;
	 flightForm.retDate.value = flightForm.fs_dia.value+"/"+str.substring(4)+"/"+str.substring(0,4);
	 // try{cookieForms('save', 'flightForm');}catch(err){}
	 flightForm.submit();
    }
}



function goSubmitBuscadorVH2007(dat){
var str = "";
// Quito acentos
flightHotelForm.depCity.value = QuitarAcentos(flightHotelForm.depCity.value);
flightHotelForm.arrCity.value = QuitarAcentos(flightHotelForm.arrCity.value);
var msg="";
//groupval(str, nom, islg, isln, isnm)
  msg = doconcat(msg,groupval(flightHotelForm.depCity.value,'Ciudad de salida',1,1,0)); 
  msg = doconcat(msg,groupval(flightHotelForm.arrCity.value,'Ciudad de llegada',1,1,0)); 
  msg = doconcat(msg,groupval(flightHotelForm.fe_dia.value,'Dia de salida',0,1,1));
  msg = doconcat(msg,groupval(flightHotelForm.fe_mesanyo.value,'Mes de salida',0,1,1));
  var fechadep = flightHotelForm.fe_mesanyo.value + "" + flightHotelForm.fe_dia.value;
  if (flightHotelForm.queryType[0].checked){
     msg = doconcat(msg,groupval(flightHotelForm.fs_dia.value,'Dia de llegada',0,1,1));
     msg = doconcat(msg,groupval(flightHotelForm.fs_mesanyo.value,'Mes de llegada',0,1,1));
     var fecharet = flightHotelForm.fs_mesanyo.value + "" + flightHotelForm.fs_dia.value;
     if (fecharet < fechadep)
      {msg = doconcat(msg,"La fecha de llegada tiene que ser mayor que la de salida \n");}
      flightHotelForm.owOrRt.value="R";
  } else {
  	  flightHotelForm.owOrRt.value="O";
  }
  
    //veo si la fecha de salida es mayor de 2 dias
	var now = new Date();
	now.setTime(dat);
    now.setDate(now.getDate());
    var strnow = now.getFullYear()+""+addcero(now.getMonth()+1)+""+addcero(now.getDate());
    //if (fechadep < strnow)
    //{msg = doconcat(msg,"Error. No puede buscar vuelos para fechas pasadas. \n");}
   
    var nAdt = 1 * flightHotelForm.paxAdt.options[flightHotelForm.paxAdt.selectedIndex].value;
    var nChd = 1 * flightHotelForm.paxChd.options[flightHotelForm.paxChd.selectedIndex].value;
    var nInf = 1 * flightHotelForm.paxInf.options[flightHotelForm.paxInf.selectedIndex].value;
    if (nInf > nAdt)msg = doconcat(msg,"El número bebes no puede superar al de adultos \n");
    if ((nAdt + nChd) > 9)msg = doconcat(msg,"El número total de adúltos y niños no puede ser mayor a nueve. \n");
    if ((nInf + nChd) > (nAdt * 2) )msg = doconcat(msg,"El número bebes y niños no puede superar, al doble del numero de adultos \n");
	if(flightHotelForm.depTime.value != "" || flightHotelForm.retTime.value != ""){
		flightHotelForm.resultType[1].checked = true;
	}
   
   if (msg != ''){alert(msg);}
   else{
	 str = flightHotelForm.fe_mesanyo.value;
	 flightHotelForm.depDate.value = flightHotelForm.fe_dia.value+"/"+str.substring(4)+"/"+str.substring(0,4);
	 str = flightHotelForm.fs_mesanyo.value;
	 flightHotelForm.retDate.value = flightHotelForm.fs_dia.value+"/"+str.substring(4)+"/"+str.substring(0,4);
	 // try{cookieForms('save', 'flightHotelForm');}catch(err){}
	 flightHotelForm.submit();
    }
}

function cerrarCapaErrores()
{
  document.getElementById("capaErrores").style.visibility = 'hidden';
  document.getElementById("capaErrores").style.display = 'none';
}
