/*
* Crea el combo con las ciudades de origen.
* El array "ciudad" contiene la lista de ciudades que aparecerá en el combo.
* Cada elemento del array tiene el formato "nombreciudad#codigociudad"; donde
* 'nombreciudad' es el nombre que aparecerá en el combo y 'codigociudad' es
* el valor asociado a ese elemento del combo.
* El valor del elemento seleccionado se le pasa al campo oculto "B_LOCATION_IN" 
* (por defecto le asignamos el primero del array).
*/

function Crear_salida(){ 
	Crear_salida_config('MAD',20)
}

function Crear_salida_config(orig,num){ 
	  if (num == null || num == "") num = 20;
	  if (orig == null || orig == "") orig = "MAD";
	  else orig = orig.toUpperCase();
	  
	  if(navigator.appName== 'Netscape'){
	  	document.write('<input type="text" name="B_LOCATION_IN" maxlength="25" size="25" >');	  
	  }
	  else{
	    document.write('<input type="text" name="B_LOCATION_IN" value="" style="display:none">'); 
       	var ciudad = new Array('--- Nacional ---#','Alicante#ALC','Almeria#LEI','Asturias#OVD','Badajoz#BJZ','Barcelona#BCN','Bilbao#BIO','Fuerteventura#FUE','Gran Canaria#LPA','Granada#GRX','Ibiza#IBZ','Jerez de la Frontera#XRY','La Coruna#LCG','Lanzarote#ACE','Leon#LEN','Logroño#RJL','Madrid#MAD','Malaga#AGP','Menorca#MAH','Murcia#MJV','Palma de Mallorca#PMI','Pamplona#PNA','San Sebastian#EAS','Santander#SDR','Sevilla#SVQ','Sta Cruz de la Palma#SPC','Stgo. de Compostela#SCQ','Tenerife#TCI','Valencia#VLC','Valladolid#VLL','Vigo#VGO','Vitoria#VIT','Zaragoza#ZAZ','--- Internacional ---#','Amsterdan#AMS','Bruselas#BRU','Buenos Aires#BUE','Copenague#CPH','Dublín#DUB','Dusseldorf#DUS','Estocolmo#STO','Frankfurt#FRA','Ginebra#GVA','Lisboa#LIS','Londres#LON','Milán#MIL','Nueva York#NYC','Oporto#OPO','París#PAR','Roma#ROM','Zurich#ZRH','Otro origen...#OTH');
        document.writeln('<select name="ORIGEN" onChange="otro(\'ORIGEN\',\'B_LOCATION_IN\')">');
        for (i=0; i<=ciudad.length-1; i++){
        	var j=ciudad[i].indexOf('#');
        	var nombreciudad = ciudad[i].substring(0,j);
        	var valorciudad = ciudad[i].substring(j+1,ciudad[i].length);
        	if(nombreciudad.length > num) nombreciudad=nombreciudad.substring(0,parseInt(num));
        	if(valorciudad == orig) {
			  document.writeln("<option value="+valorciudad+" selected>"+nombreciudad+"</option>");
            } else {
			  document.writeln("<option value="+valorciudad+">"+nombreciudad+"</option>");
			}
        }
        //document.writeln("<option value='OTH'>OTRO ORIGEN...</option>");
        document.writeln("</select>");			
     	document.RUMBO_AIR.B_LOCATION_IN.value= document.RUMBO_AIR.ORIGEN.options[document.RUMBO_AIR.ORIGEN.options.selectedIndex].value; 
    }  
} 

/*
* Crea el combo con las ciudades de origen, pero limitando el número de caracteres a "num"
* El array "ciudad" contiene la lista de ciudades que aparecerá en el combo.
* Cada elemento del array tiene el formato "nombreciudad#codigociudad"; donde
* 'nombreciudad' es el nombre que aparecerá en el combo y 'codigociudad' es
* el valor asociado a ese elemento del combo.
* El valor del elemento seleccionado se le pasa al campo oculto "B_LOCATION_IN" 
* (por defecto le asignamos el primero del array).
*/

function Crear_salida_mini(num){ 
	Crear_salida_config('MAD',num)
}

/*
* Crea el combo con las ciudades de destino.
* El array "ciudad" contiene la lista de ciudades que aparecerá en el combo.
* Cada elemento del array tiene el formato "nombreciudad#codigociudad"; donde
* 'nombreciudad' es el nombre que aparecerá en el combo y 'codigociudad' es
* el valor asociado a ese elemento del combo.
* El valor del elemento seleccionado se le pasa al campo oculto "E_LOCATION_IN" 
* (por defecto le asignamos el primero del array).
*/

function Crear_destino(){  
	Crear_destino_config('BCN',20)
}

function Crear_destino_config(dest,num){ 
	  if (num == null || num == "") num = 20;
	  if (dest == null || dest == "") dest = "BCN";
	  else dest = dest.toUpperCase();
	  
	  if(navigator.appName== 'Netscape'){
	  	document.write('<input type="text" name="E_LOCATION_IN" maxlength="25" size="25" >');	  
	  }
	  else{
	    document.write('<input type="text" name="E_LOCATION_IN" value="" style="display:none">');
       	var ciudad = new Array('--- Nacional ---#','Alicante#ALC','Almeria#LEI','Asturias#OVD','Barcelona#BCN','Bilbao#BIO','Fuerteventura#FUE','Gran Canaria#LPA','Granada#GRX','Ibiza#IBZ','Jerez de la Frontera#XRY','La Coruna#LCG','Lanzarote#ACE','Madrid#MAD','Malaga#AGP','Menorca#MAH','Palma de Mallorca#PMI','Pamplona#PNA','San Sebastian#EAS','Santander#SDR','Sevilla#SVQ','Stgo. de Compostela#SCQ','Tenerife#TCI','Valencia#VLC','Vigo#VGO','--- Internacional ---#','Amsterdan#AMS','Berlín#BER','Bruselas#BRU','Buenos Aires#BUE','Copenague#CPH','Dublín#DUB','Dusseldorf#DUS','Estocolmo#STO','Frankfurt#FRA','Ginebra#GVA','Lisboa#LIS','Londres#LON','Mexico DF#MEX','Miami#MIA','Milán#MIL','Munich#MUC','Nueva York#NYC','Oporto#OPO','París#PAR','Praga#PRG','Roma#ROM','Stuttgart#STR','Venecia#VCE','Viena#VIE','Zurich#ZRH','Otro destino...#OTH');
        document.writeln('<select name="DESTINO" onChange="otro(\'DESTINO\',\'E_LOCATION_IN\')">');
        for (i=0; i<=ciudad.length-1; i++){
        	var j=ciudad[i].indexOf('#');
        	var nombreciudad = ciudad[i].substring(0,j);
        	var valorciudad = ciudad[i].substring(j+1,ciudad[i].length);
        	if(nombreciudad.length > num) nombreciudad=nombreciudad.substring(0,parseInt(num));
        	if(valorciudad == dest) {
			  document.writeln("<option value="+valorciudad+" selected>"+nombreciudad+"</option>");
            } else {
			  document.writeln("<option value="+valorciudad+">"+nombreciudad+"</option>");
			}
        }
        //document.writeln("<option value='OTH'>OTRO DESTINO...</option>");
        document.writeln("</select>");			
     	document.RUMBO_AIR.E_LOCATION_IN.value= document.RUMBO_AIR.DESTINO.options[document.RUMBO_AIR.DESTINO.options.selectedIndex].value; 
    }  
} 

/*
* Crea el combo con las ciudades de destino, pero limitando el número de caracteres a "num"
* El array "ciudad" contiene la lista de ciudades que aparecerá en el combo.
* Cada elemento del array tiene el formato "nombreciudad#codigociudad"; donde
* 'nombreciudad' es el nombre que aparecerá en el combo y 'codigociudad' es
* el valor asociado a ese elemento del combo.
* El valor del elemento seleccionado se le pasa al campo oculto "E_LOCATION_IN" 
* (por defecto le asignamos el primero del array).
*/

function Crear_destino_mini(num){  
	Crear_destino_config('BCN',num)
}

/*
* Si la opción elegida es "Otro destino" u "otro origen", 
* oculta el combo y muestra el campo de texto correspondiente.
* Si no, asigna al campo de texto oculto, el valor seleccionado
* en el combo.
*/

function otro(combo, campotexto){	
	eval("var seleccionado = document.RUMBO_AIR."+combo+".selectedIndex");
	eval("var ultimo = document.RUMBO_AIR."+combo+".options.length-1");

	if(seleccionado == ultimo){
		eval("document.RUMBO_AIR."+combo+".style.display='none'");
		eval("document.RUMBO_AIR."+campotexto+".value=''");
		eval("document.RUMBO_AIR."+campotexto+".style.display='inline'");
	}
	else{
	  eval("document.RUMBO_AIR."+campotexto+".value= document.RUMBO_AIR."+combo+"[document.RUMBO_AIR."+combo+".selectedIndex].value");
	}
}

function selectPax(ObjMaster,ObjCustom,pass_total) /* to limit num passenger max in combos adults and childs */{
	var minCustom = parseInt(ObjCustom.options[0].value);
	var ObjCustomMaxLength = pass_total*1 - parseInt(ObjMaster.value);
	var ObjCustomLength = ObjCustom.options.length;
	var ObjCustomSelect = ObjCustom.value;
	for (j = ObjCustomLength-1; j >0; j--)
		ObjCustom.options[j] = null;
	for (j=0;j<=ObjCustomMaxLength-minCustom;j++)
		ObjCustom.options[j] = new Option(j+minCustom,j+minCustom);
	if (parseInt(ObjCustomSelect) <= ObjCustomMaxLength)
		ObjCustom.value = ObjCustomSelect;
}

function Crear_ad() {
        document.writeln('<select class=normal name=N_ADULT  onchange="javascript:selectPax(N_ADULT,N_CHILD,5);"><option selected value=1>1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>\n');
}

function Crear_ni() {
        document.writeln('<select class=normal name=N_CHILD><option selected value=0>0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>\n');
}

var alert_location= "Seleccione un origen y un destino"; 
var alert_samelocation= "Ha elegido un origen y un destino idénticos, cambie su selección."; 
var alert_date72= "No se admiten compras efectuadas con menos de 72 horas de antelación (3 días). Para compras con menos de 72 horas de antelación, por favor,  llame a nuestro Call Center al 902 999 345. "; 
var alert_dateorder= "Compruebe que la fecha de salida o de regreso es posterior al día de hoy.";

function validaForm(form){
			//Origen y destino 
			if (form.B_LOCATION_IN.value=="" || form.E_LOCATION_IN.value=="") {
				alert(alert_location);
				return -1
			}
			if (form.B_LOCATION_IN.value==form.E_LOCATION_IN.value) {
				alert(alert_samelocation);
				return -1
			}
			//fechas
		diae		=form.fe_dia.value;
		mese		=form.fe_mesanyo.value.substring(4,6);
		anye		=parseInt(form.fe_mesanyo.value.substring(0,4));

		dateHoyAux	= new Date();
		dateHoy		= new Date(dateHoyAux.getFullYear(), dateHoyAux.getMonth(), dateHoyAux.getDate());
		dateComboe	= new Date(anye, (mese-1), diae);
		//alert("dia="+dateHoy.getDate()+" diae="+diae+" "+((dateComboe - dateHoy)/86400000));
		//alert("diae="+diae+" mese="+form.fe_mesanyo[form.fe_mesanyo.selectedIndex].value.substring(4,6)+" anye="+anye);
		if ( ((dateComboe - dateHoy)/86400000)>=0  ){		//if ( ( (anye>anyh) || (anye==anyh && mese>mesh) ) || 	((anye==anyh && mese==mesh) && diae>diah) )  {   
			dias		=form.fs_dia.value;
			mess		=form.fs_mesanyo.value.substring(4,6);
			anys		=parseInt(form.fs_mesanyo.value.substring(0,4));
			dateComboss		= new Date(anys, (mess-1), dias);

			if ( ((dateComboe - dateHoy)/86400000)<0 )  {   
			//if ( ((dateComboe - dateHoy)/86400000)<2 )  {   
					alert(alert_date72);  
					return -1;
			} 
		} else {
			alert(alert_dateorder);  
			return -1;
		}
		if (form.fs_dia.value!="" || form.fs_mesanyo.value!="") { //if (form.TRIP_TYPE[0].checked) {  //Si esta marcado el radio para ida y vuelta

				   //alert("Resta-->"+((dateComboss - dateComboe)/86400000)+"vuelta: "+dateComboss+"salida:"+dateComboe);
			if ( ((dateComboss - dateComboe)/86400000)>=0)			{//if ( ( (anys>anye) || (anys==anye && mess>mese) ) || 	((anys==anye && mess==mese) && dias>=diae) )  {   
					if (dias==diae  && mess==mese &&anys==anye )  {
							document.RUMBO_AIR.D_DATE.value = document.RUMBO_AIR.fe_mesanyo.value+ document.RUMBO_AIR.fe_dia.value+"0900";
							document.RUMBO_AIR.R_DATE.value = document.RUMBO_AIR.fs_mesanyo.value+ document.RUMBO_AIR.fs_dia.value+"2100";
					} 
			} else {
					alert(alert_dateorder);  
					return -1;
			}
					form.TRIP_TYPE.value="R";
		} else  {form.TRIP_TYPE.value="O";}

}

function search(type) {
			document.RUMBO_AIR.D_DATE.value = document.RUMBO_AIR.fe_mesanyo.value+ document.RUMBO_AIR.fe_dia.value+"0000";
			document.RUMBO_AIR.R_DATE.value = document.RUMBO_AIR.fs_mesanyo.value+ document.RUMBO_AIR.fs_dia.value+"0000";

			res = validaForm(document.RUMBO_AIR);
			if (res==-1) return;
			if (type=='1') {
				document.RUMBO_AIR.flag.value="airavailability";
				document.RUMBO_AIR.B_DATE_1.value=document.RUMBO_AIR.D_DATE.value;
				if (document.RUMBO_AIR.TRIP_TYPE.value=="R") document.RUMBO_AIR.B_DATE_2.value=document.RUMBO_AIR.R_DATE.value;
				else document.RUMBO_AIR.B_DATE_2.value="";
				document.RUMBO_AIR.E_LOCATION_1.value=document.RUMBO_AIR.E_LOCATION_IN.value;
				document.RUMBO_AIR.B_LOCATION_1.value=document.RUMBO_AIR.B_LOCATION_IN.value;
				document.RUMBO_AIR.E_LOCATION_2.value=document.RUMBO_AIR.B_LOCATION_IN.value;
				document.RUMBO_AIR.B_LOCATION_2.value=document.RUMBO_AIR.E_LOCATION_IN.value;
			}
			else document.RUMBO_AIR.flag.value="mpavailability";


	RUMBO_AIR.depDate.value=RUMBO_AIR.fe_dia.value+"/"+RUMBO_AIR.fe_mesanyo.value.substring(4,6)+"/"+parseInt(RUMBO_AIR.fe_mesanyo.value.substring(0,4));
	RUMBO_AIR.retDate.value=RUMBO_AIR.fs_dia.value+"/"+RUMBO_AIR.fs_mesanyo.value.substring(4,6)+"/"+parseInt(RUMBO_AIR.fs_mesanyo.value.substring(0,4));
	RUMBO_AIR.paxAdt.value=RUMBO_AIR.N_ADULT.value;
	RUMBO_AIR.paxChd.value=RUMBO_AIR.N_CHILD.value;
	RUMBO_AIR.depCity.value=RUMBO_AIR.B_LOCATION_IN.value;
	RUMBO_AIR.arrCity.value=RUMBO_AIR.E_LOCATION_IN.value;

                document.RUMBO_AIR.submit();

}

function AddRumboForms(org,clean,target,isFlightNew, callNetfilia) {
		org = (org != null && org != "") ? org : "";
		target = (target != null && target != "") ? target : "_top";
		clean = (clean != null && clean != "") ? clean : "NO";
		AddRumboLinkForm(org,clean,target);
		isFlightNew = "YES";
		if(callNetfilia != null && callNetfilia.toUpperCase() == "YES")
		{
			AddRumboAirForm2(org,clean,target, isFlightNew, callNetfilia);
		}
		else
		{
			AddRumboAirForm(org,clean,target, isFlightNew);
		}
}

function AddRumboLinkForm(org,clean,target) {
        document.writeln('<form name="RumboLinkForm" METHOD="POST" TARGET="'+target+'">\n');
        document.writeln('<input type=hidden name="org" value="'+org+'">\n');
        document.writeln('<input type=hidden name="clean" value="'+clean+'">\n');
        document.writeln('</form>\n');
}

function AddRumboAirForm(org, clean, target) {
	AddRumboAirForm(org, clean, target, null)
}

function AddRumboAirForm(org, clean, target, isFlightNewParam) {
		
		var isFlightNew = isFlightNewParam;
		if(isFlightNew != null && isFlightNew.toUpperCase() == "YES")
		{
			document.writeln('<form name="RUMBO_AIR" ACTION="http://www.rumbo.es/viajes/vuelos/city.do" METHOD="POST" TARGET="'+target+'">\n');
		}
		else
		{
			document.writeln('<form name="RUMBO_AIR" ACTION="http://www.rumbo.es/public/jsp/vuelos_availabilitymp" METHOD="POST" TARGET="'+target+'">\n');
		}
        document.writeln('<input type=hidden name="org" value="'+org+'">\n');
        document.writeln('<input type=hidden name="clean" value="'+clean+'">\n');
        document.writeln('<input type=hidden name="flag" value="mpavailability">\n');
        document.writeln('<input type=hidden name="D_DATE" value="">\n');
        document.writeln('<input type=hidden name="R_DATE" value="">\n');
        document.writeln('<input type=hidden name="B_DATE_1" value="">\n');
        document.writeln('<input type=hidden name="B_LOCATION_1" value="">\n');
        document.writeln('<input type=hidden name="E_LOCATION_1" value="">\n');
        document.writeln('<input type=hidden name="B_DATE_2" value="">\n');
        document.writeln('<input type=hidden name="B_LOCATION_2" value="">\n');
        document.writeln('<input type=hidden name="E_LOCATION_2" value="">\n');
        document.writeln('<input type=hidden name="TRIP_TYPE" value="O" >\n');
        document.writeln('<input type=hidden name="B_ANY_TIME_1" value="true">\n');
        document.writeln('<input type=hidden name="B_ANY_TIME_2" value="true">\n');
        document.writeln('<input type=hidden name="N_YOUTH" value="0">\n');
        document.writeln('<input type=hidden name="N_INFANT" value="0">\n');
        document.writeln('<input type=hidden name="N_STUDENT" value="0">\n');
        document.writeln('<input type=hidden name="N_SENIOR" value="0">\n');
        document.writeln('<input type=hidden name="DIRECT_NON_STOP" value="false">\n');

	document.writeln('<input type=hidden name="depDate" value="">');
	document.writeln('<input type=hidden name="retDate" value="">');
	document.writeln('<input type=hidden name="depCity" value="">');
	document.writeln('<input type=hidden name="arrCity" value="">');
	document.writeln('<input type=hidden name="paxAdt" value="">');
	document.writeln('<input type=hidden name="paxChd" value="">');

}

function DS(action, attrs, target) {
	form = document.RumboLinkForm;
    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 = "_top";
        }
        form.submit();
    }
}

function getRumboURL(type,target) {
	if (type=='vuelos') return eval(DS('http://www.rumbo.es/public/jsp/vuelos/busqueda_vuelos.jsp', null,target));
	else if (type=='vuelosnew') return eval(DS('http://www.rumbo.es/viajes/vuelos/buscador.do', null,target));
	else if (type=='coches') return eval(DS('http://www.rumbo.es/public/jsp/coches/rb000avi.jsp', null,target));
	else if (type=='hoteles') return eval(DS('http://www.rumbo.es/public/jsp/hoteles/rb001htl.jsp', null,target));
	else if (type=='bus') return eval(DS('http://www.rumbo.es/public/jsp/sb/rb00inimov.jsp', null,target));
	else if (type=='vacaciones') return eval(DS('http://www.rumbo.es/public/jsp/vacaciones/rb000pkn.jsp', null,target));
	else if (type=='playas') return eval(DS('http://www.rumbo.es/public/jsp/playas/rb000pla.jsp', null,target));
	else if (type=='ofertas') return eval(DS('http://www.rumbo.es/public/jsp/ofertas/rb000ofe.jsp', null,target));
	else if (type=='home') return eval(DS('http://www.rumbo.es/public/viajes/viajes.jsp', null,target));
	else if (type=='masvuelos') return eval(DS('http://www.rumbo.es/public/vuelos/sb008col.jsp', {tipo_oferta:'flight'},target));
	else if (type=='rural') return eval(DS('http://www.rumbo.es/public/jsp/hoteles/rb00busrur.jsp', null,target));
	else if (type=='masofertas') return eval(DS('http://www.rumbo.es/public/sb/sb001col.jsp', null,target));
	else return;
}

/**
*	FECHAS
**/

function crear_fechaI() {
       document.write('<input type="hidden" name="fechaI" value="">');
       var all_month = new Array('Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic');
       var all_days_week = new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	     var fecha_hoy=new Date();
			 var dia_hoy=fecha_hoy.getDate();
		 	 var month=fecha_hoy.getMonth ();
       var year=fecha_hoy.getFullYear ();
       var num_days = month_days(year,month);
		 	 var year=fecha_hoy.getFullYear ();
       var year_ini = year;
		   var date_today = fecha_hoy.getDay();
       var name_day = all_days_week[date_today];
		   var name_month = all_month[month];
		   // Para que muestre en el option : Ene 04 (por ejemplo)
		   	var year_corto=year.toString().substring(2,4);
		 
       document.write('<SELECT NAME="fe_dia" onChange="act_dia_semana_fe_mesanyo(document.RUMBO_AIR.fe_mesanyo.selectedIndex,document.RUMBO_AIR.fe_dia.selectedIndex,'+dia_hoy+');">');	   
		 				for (i = dia_hoy; i <= num_days; i++){
        				var j = (i < 10) ? "0"+i : i; 
         				document.write('<OPTION VALUE='+j+'>'+i+'</OPTION>');
         }

		 		document.write('</SELECT>&nbsp;');
        document.write('<SELECT NAME="fe_mesanyo"  onChange="actualizar_dias_fe_mesanyo(document.RUMBO_AIR.fe_mesanyo.selectedIndex,'+month+','+dia_hoy+'); act_dia_semana_fe_mesanyo(document.RUMBO_AIR.fe_mesanyo.selectedIndex,document.RUMBO_AIR.fe_dia.selectedIndex,'+dia_hoy+');">');	   
        document.write('<OPTION VALUE='+val_month(year,month)+' SELECTED>'+name_month+' '+year_corto+'</OPTION>');
         var i = month + 1;
         if (month == 0){
              j = 11;
         } else{ 
            j = month - 1;
         }
         for (k=1; k < 11; k++){
           			if (i == 12){
            				i = 0;
            				year = year + 1;
           			}          			
           			year_corto=year.toString().substring(2,4);
	 			 				name_month = all_month[i];
         				document.write(' <OPTION VALUE='+val_month(year,i)+'>'+name_month+' '+year_corto+'</OPTION>');
         				i++;
          }
		 		document.write('</SELECT>');
}

function crear_fechaI_mini() {
       document.write('<input type="hidden" name="fechaI" value="">');
       var all_month = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
       var all_days_week = new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	var fecha_hoy=new Date();
	var dia_hoy=fecha_hoy.getDate();
	 var month=fecha_hoy.getMonth ();
       var year=fecha_hoy.getFullYear ();
       var num_days = month_days(year,month);
		 	 var year=fecha_hoy.getFullYear ();
       var year_ini = year;
		   var date_today = fecha_hoy.getDay();
       var name_day = all_days_week[date_today];
		   var name_month = all_month[month];
		   // Para que muestre en el option : Ene 04 (por ejemplo)
		   	var year_corto=year.toString().substring(2,4);
		 
       document.write('<SELECT NAME="fe_dia" onChange="act_dia_semana_fe_mesanyo(document.RUMBO_AIR.fe_mesanyo.selectedIndex,document.RUMBO_AIR.fe_dia.selectedIndex,'+dia_hoy+');">');	   
		 				for (i = dia_hoy; i <= num_days; i++){
        				var j = (i < 10) ? "0"+i : i; 
         				document.write('<OPTION VALUE='+j+'>'+i+'</OPTION>');
         }

		 		document.write('</SELECT>');
        document.write('<SELECT NAME="fe_mesanyo"  onChange="actualizar_dias_fe_mesanyo(document.RUMBO_AIR.fe_mesanyo.selectedIndex,'+month+','+dia_hoy+'); act_dia_semana_fe_mesanyo(document.RUMBO_AIR.fe_mesanyo.selectedIndex,document.RUMBO_AIR.fe_dia.selectedIndex,'+dia_hoy+');">');	   
        document.write('<OPTION VALUE='+val_month(year,month)+' SELECTED>'+name_month+'/'+year_corto+'</OPTION>');
         var i = month + 1;
         if (month == 0){
              j = 11;
         } else{ 
            j = month - 1;
         }
         for (k=1; k < 11; k++){
           			if (i == 12){
            				i = 0;
            				year = year + 1;
           			}          			
           			year_corto=year.toString().substring(2,4);
	 			 				name_month = all_month[i];
         				document.write(' <OPTION VALUE='+val_month(year,i)+'>'+name_month+'/'+year_corto+'</OPTION>');
         				i++;
          }
		 		document.write('</SELECT>');
}

function crear_fechaV() {
       document.write('<input type="hidden" name="fechaV" value="">');
       var all_month = new Array('Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic');
       var all_days_week = new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	     var fecha_hoy=new Date();
			 var dia_hoy=fecha_hoy.getDate();
			 var month=fecha_hoy.getMonth ();
       var year=fecha_hoy.getFullYear ();
       var num_days = month_days(year,month);
			 var year=fecha_hoy.getFullYear ();
       var year_ini = year;
		   var date_today = fecha_hoy.getDay();
       var name_day = all_days_week[date_today];
			 var name_month = all_month[month];
			  // Para que muestre en el option : Ene 04 (por ejemplo)
		   			var year_corto=year.toString().substring(2,4);      
		 
       document.write('<SELECT NAME="fs_dia"  onChange="act_dia_semana_fs_mesanyo(document.RUMBO_AIR.fs_mesanyo.selectedIndex,document.RUMBO_AIR.fs_dia.selectedIndex,'+dia_hoy+');">');	   
		 		for (i = dia_hoy; i <= num_days; i++){
        			var j = (i < 10) ? "0"+i : i; 
         			document.write('<OPTION VALUE='+j+'>'+i+'</OPTION>');
        }

		 	 document.write('</SELECT>&nbsp;');
       document.write('<SELECT NAME="fs_mesanyo"  onChange="actualizar_dias_fs_mesanyo(document.RUMBO_AIR.fs_mesanyo.selectedIndex,'+month+','+dia_hoy+'); act_dia_semana_fs_mesanyo(document.RUMBO_AIR.fs_mesanyo.selectedIndex,document.RUMBO_AIR.fs_dia.selectedIndex,'+dia_hoy+');">');	   
       document.write('<OPTION VALUE='+val_month(year,month)+' SELECTED>'+name_month+' '+year_corto+'</OPTION>');
       var i = month + 1;
       if (month == 0){
           j = 11;
       }else{ 
           j = month - 1;
       }
       for (k=1; k < 11; k++){
           if (i == 12){
            		i = 0;
            		year = year + 1;
           }
           year_corto=year.toString().substring(2,4); 
         	 name_month = all_month[i];
           document.write(' <OPTION VALUE='+val_month(year,i)+'>'+name_month+' '+year_corto+'</OPTION>');
           i++;
       }
		 		document.write('</SELECT>');
}

function crear_fechaV_mini() {
       document.write('<input type="hidden" name="fechaV" value="">');
       var all_month = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
       var all_days_week = new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado");
	     var fecha_hoy=new Date();
			 var dia_hoy=fecha_hoy.getDate();
			 var month=fecha_hoy.getMonth ();
       var year=fecha_hoy.getFullYear ();
       var num_days = month_days(year,month);
			 var year=fecha_hoy.getFullYear ();
       var year_ini = year;
		   var date_today = fecha_hoy.getDay();
       var name_day = all_days_week[date_today];
			 var name_month = all_month[month];
			  // Para que muestre en el option : Ene 04 (por ejemplo)
		   			var year_corto=year.toString().substring(2,4);      
		 
       document.write('<SELECT NAME="fs_dia"  onChange="act_dia_semana_fs_mesanyo(document.RUMBO_AIR.fs_mesanyo.selectedIndex,document.RUMBO_AIR.fs_dia.selectedIndex,'+dia_hoy+');">');	   
		 		for (i = dia_hoy; i <= num_days; i++){
        			var j = (i < 10) ? "0"+i : i; 
         			document.write('<OPTION VALUE='+j+'>'+i+'</OPTION>');
        }

		 	 document.write('</SELECT>');
       document.write('<SELECT NAME="fs_mesanyo"  onChange="actualizar_dias_fs_mesanyo(document.RUMBO_AIR.fs_mesanyo.selectedIndex,'+month+','+dia_hoy+'); act_dia_semana_fs_mesanyo(document.RUMBO_AIR.fs_mesanyo.selectedIndex,document.RUMBO_AIR.fs_dia.selectedIndex,'+dia_hoy+');">');	   
       document.write('<OPTION VALUE='+val_month(year,month)+' SELECTED>'+name_month+'/'+year_corto+'</OPTION>');
       var i = month + 1;
       if (month == 0){
           j = 11;
       }else{ 
           j = month - 1;
       }
       for (k=1; k < 11; k++){
           if (i == 12){
            		i = 0;
            		year = year + 1;
           }
           year_corto=year.toString().substring(2,4); 
         	 name_month = all_month[i];
           document.write(' <OPTION VALUE='+val_month(year,i)+'>'+name_month+'/'+year_corto+'</OPTION>');
           i++;
       }
		 		document.write('</SELECT>');
}

function month_days(year, month){
  		var next_month = new Date();
  		next_month.setFullYear(year,month + 1,0);
  		return (next_month.getDate());
}

function val_month(year, month){
  var val_year = year.toString();
	month++;
  var val_month = month.toString();
  
  if (month < 10){
     val_month = "0" + val_month;
  }

  month--;

  return val_year+val_month;
}

function act_dia_semana_fe_mesanyo(mes_seleccion,dia_seleccion,hoy_mas3) { 
    var names_days_week = new Array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado'); 
    var month_form = mes_seleccion;  
    var date_selec = document.RUMBO_AIR.fe_mesanyo.options[month_form].value;  
    var day_form = dia_seleccion;  
    var day_selec = document.RUMBO_AIR.fe_dia.options[day_form].value;  
    var year_selec = date_selec.substr(0,4);  
    var month_selec = date_selec.substr(4,2)*1; 
    var next_month = new Date(); 
    if (month_selec == 0) {  
       var month_setFullYear = month_selec;  
    }  
    if (month_selec <= 12) {  
       var month_setFullYear = month_selec - 1;  
    }  
    next_month.setFullYear(year_selec, month_setFullYear , day_selec);  
    var day_week = next_month.getDay();  
} 

function actualizar_dias_fe_mesanyo(formulario,actual_month,hoy_mas3) { 
    var month_form = formulario;  
    var date_selec = document.RUMBO_AIR.fe_mesanyo.options[month_form].value;  
    var year_selec = date_selec.substr(0,4);  
    var month_selec = date_selec.substr(4,2)*1; 
    var next_month = new Date(); 
    next_month.setFullYear(year_selec, month_selec, 0);  
    var days_selec = next_month.getDate();  
    if ((month_selec - 1) != actual_month){  
       incremento = 0; 
    } 
    else{ 
       incremento = hoy_mas3 - 1;  
       days_selec = days_selec - hoy_mas3 + 1;  
    } 
    document.RUMBO_AIR.fe_dia.length = days_selec;  
    var opt = "";  
    for (i=0; i<days_selec; i++)  { 
       var val_inc = i+incremento+1;   
       var val_option = (val_inc < 10) ? '0' + val_inc : val_inc; 
       var optx = opt.concat('option',i);  
       eval('optx = new Option(i+incremento+1,val_option)');  
       eval('document.RUMBO_AIR.fe_dia.options[i] = optx');  
    } 
    document.RUMBO_AIR.fe_dia.selectedIndex = '0'
  } 

function act_dia_semana_fs_mesanyo(mes_seleccion,dia_seleccion,hoy_mas3) { 
    var names_days_week = new Array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado'); 
    var month_form = mes_seleccion;  
    var date_selec = document.RUMBO_AIR.fs_mesanyo.options[month_form].value;  
    var day_form = dia_seleccion;  
    var day_selec = document.RUMBO_AIR.fs_dia.options[day_form].value;  
    var year_selec = date_selec.substr(0,4);  
    var month_selec = date_selec.substr(4,2)*1; 
    var next_month = new Date(); 
    if (month_selec == 0){  
       var month_setFullYear = month_selec;  
    }  
    if (month_selec <= 12) {  
       var month_setFullYear = month_selec - 1;  
    }  
    next_month.setFullYear(year_selec, month_setFullYear , day_selec);  
    var day_week = next_month.getDay();  
}

function actualizar_dias_fs_mesanyo(formulario,actual_month,hoy_mas3) { 
    var month_form = formulario;  
    var date_selec = document.RUMBO_AIR.fs_mesanyo.options[month_form].value;  
    var year_selec = date_selec.substr(0,4);  
    var month_selec = date_selec.substr(4,2)*1; 
    var next_month = new Date(); 
    next_month.setFullYear(year_selec, month_selec, 0);  
    var days_selec = next_month.getDate();  
    if ((month_selec - 1) != actual_month) {  
       incremento = 0; 
    } 
    else {  
       incremento = hoy_mas3 - 1;  
       days_selec = days_selec - hoy_mas3 + 1;  
    } 
    document.RUMBO_AIR.fs_dia.length = days_selec;  
    var opt = "";  
    for (i=0; i<days_selec; i++)  { 
       var val_inc = i+incremento+1;   
       var val_option = (val_inc < 10) ? '0' + val_inc : val_inc; 
       var optx = opt.concat('option',i);  
       eval('optx = new Option(i+incremento+1,val_option)');  
       eval('document.RUMBO_AIR.fs_dia.options[i] = optx');  
    } 
    document.RUMBO_AIR.fs_dia.selectedIndex = '0'
} 

/**
** FIN FECHAS
**/

