

function resAndPlta2NotTogether(){
		if(document.getElementById('promotional_code').value!=''){
			if(document.getElementById('cFamNum')){
				document.getElementById('cFamNum').checked=false;
				document.getElementById('cFamNum').disabled="disabled";
			}
		}
		else{
			if(document.getElementById('cFamNum')){
				document.getElementById('cFamNum').disabled="";
			}		
		}	
		if(document.getElementById('promotional_code')){
			if(document.getElementById('cFamNum').checked==true){
				document.getElementById('promotional_code').value='';
				document.getElementById('promotional_code').disabled="disabled";
			}
			else{
				document.getElementById('promotional_code').disabled="";			
			}	
		}
}
	
function captureSearchText(searchText)
{

searchText.missingDepartCity = "\nSelecciona la ciudad de salida.\n";
searchText.missingArriveCity = "\nSelecciona tu destino.\n";
searchText.popup_max_passenger_amount_1 = "You are allowed a maximum of ";
searchText.popup_max_passenger_amount_2 = " passengers\nper booking online. If your party is larger\nthan this, please call our reservation center.";
searchText.popup_missing_passenger_amount = "You must enter at least one passenger.";	
searchText.popup_too_many_infants = "If you wish to book a greater number of\nInfants than Adults, please contact our\nreservation center for possible arrangements.";
searchText.popup_illogical_open_jaw = "The selected outbound and return city pairs\nare not logical. You should either return to the \nsame city you fly out from, or return from the\nsame city you fly into.\n";
searchText.popup_pre_flight_date_1 = "Seleccione fechas posteriores \nal ";
searchText.popup_pre_flight_date_2 = ". \n\nPulse OK para modificar su selección.";
searchText.popup_post_live_flight_date_1 = "Seleccione fechas anteriores \nal ";
searchText.popup_post_live_flight_date_2 = ". \n\nPulse OK para modificar su selección.";searchText.popup_initial_flight_date = "";
searchText.popup_final_flight_date = "";searchText.popup_flight_or_orig_dest	= "Please either enter in a flight number or\nselect cities of origin and/or destination.";
searchText.popup_invalid_city_pair = "Your origin and destination cities\nare the same. Please change one or\nthe other.";
searchText.months = new Array();
searchText.months[0] = "Enero";
searchText.months[1] = "Febrero";
searchText.months[2] = "Marzo";
searchText.months[3] = "Abril";
searchText.months[4] = "Mayo";
searchText.months[5] = "Junio";
searchText.months[6] = "Julio";
searchText.months[7] = "Agosto";
searchText.months[8] = "Septiembre";
searchText.months[9] = "Octubre";
searchText.months[10] = "Noviembre";
searchText.months[11] = "Diciembre";
searchText.sameDayWarning	 = "\nLa fecha de regreso es\nla misma que la fecha de salida.\n\n¿este viaje tan corto es deliberado?\n";
searchText.destination = "Destino";

}
function captureSearchPrefs(searchPrefs)
{
searchPrefs.OFFER_OPEN_JAW_ROUTES = 'false';
searchPrefs.DISPLAY_AIRPORT_CITY_CODES = 'true';
searchPrefs.MAX_PASSENGERS_ALLOWED = '25';
searchPrefs.paxTypes = [];
searchPrefs.initial_date_used = '';
searchPrefs.final_date_used	= '';
searchPrefs.allow_todays_date = 'true';	
searchPrefs.paxTypes.push("ADULT");
searchPrefs.paxTypes.push("CHILD");
}

function buildAirports()
{
	var apts = new Array();
	var dests;
	/*
	dests = new Array('CDG');
	apts[0] = new airport( false, "ALC", "Alicante", dests );
	dests = new Array('BCN','AGP','SVQ','VLC');
	apts[1] = new airport( false, "AMS", "Amsterdam", dests );
	dests = new Array('BCN');
	apts[2] = new airport( false, "ATH", "Atenas", dests );
	dests = new Array('AMS','ATH','BRU','GRX','XRY','LIS','MAD','AGP','MXP','NCE','CDG','FCO','SCQ','SVQ','VCE');
	apts[3] = new airport( false, "BCN", "Barcelona", dests );
	dests = new Array('AGP','SVQ');
	apts[4] = new airport( false, "BIO", "Bilbao", dests );
	dests = new Array('BCN','SVQ','VLC');
	apts[5] = new airport( false, "BRU", "Bruselas", dests );
	dests = new Array('MAD','SVQ');
	apts[6] = new airport( false, "LPA", "Gran Canaria", dests );
	dests = new Array('BCN');
	apts[7] = new airport( false, "GRX", "Granada", dests );
	dests = new Array('BCN');
	apts[8] = new airport( false, "XRY", "Jerez / Cádiz", dests );
	dests = new Array('BCN','MAD');
	apts[9] = new airport( false, "LIS", "Lisboa", dests );
	dests = new Array('BCN','LPA','LIS','MXP','NAP','CDG','FCO','TFN','VCE');
	apts[10] = new airport( false, "MAD", "Madrid", dests );
	dests = new Array('AMS','BCN','BIO','CDG','FCO','SCQ');
	apts[11] = new airport( false, "AGP", "Málaga", dests );
	dests = new Array('BCN','MAD');
	apts[12] = new airport( false, "MXP", "Milán", dests );
	dests = new Array('MAD');
	apts[13] = new airport( false, "NAP", "Nápoles", dests );
	dests = new Array('BCN');
	apts[14] = new airport( false, "NCE", "Niza", dests );
	dests = new Array('ALC','BCN','MAD','AGP','FCO','SCQ');
	apts[15] = new airport( false, "CDG", "París", dests );
	dests = new Array('BCN','MAD','AGP','CDG','SVQ');
	apts[16] = new airport( false, "FCO", "Roma", dests );
	dests = new Array('BCN','AGP','CDG');
	apts[17] = new airport( false, "SCQ", "Santiago", dests );
	dests = new Array('AMS','BCN','BIO','BRU','LPA','FCO','TFN','VLC','VCE');
	apts[18] = new airport( false, "SVQ", "Sevilla", dests );
	dests = new Array('MAD','SVQ');
	apts[19] = new airport( false, "TFN", "Tenerife", dests );
	dests = new Array('AMS','BRU','SVQ');
	apts[20] = new airport( false, "VLC", "Valencia", dests );
	dests = new Array('BCN','MAD','SVQ');
	apts[21] = new airport( false, "VCE", "Venecia", dests );

	dests = new Array('BCN','BIO');
	apts[22] = new airport( false, "PMI", "Palma de Mallorca", dests );
	*/
	
	dests = new Array("BCN","LON","SVQ");

apts[0] = new airport(false, "LCG", "A Coruña", dests);

dests = new Array("BCN","IBZ","PAR","FCO","MAD","MXP","PMI","PSA","SCQ","VCE","VGO");

apts[1] = new airport(false, "ALC", "Alicante", dests);

dests = new Array("BCN","AGP","SVQ","VLC","FCO","LIS","MAD","MXP","PMI","PSA","SCQ","VCE","VGO");

apts[2] = new airport(false, "AMS", "Amsterdam", dests);

dests = new Array("BCN","BUD","DBV","FCO","IBZ","PAR","PMI","PRG","PSA","RAK","SVQ","VCE","VRN");

apts[3] = new airport(false, "OVD", "Asturias", dests);

dests = new Array("BCN","AGP","BIO","CMN","DME","LIS","LPA","MAD","PAR","SVQ","TCI","VGO","WAW");

apts[4] = new airport(false, "ATH", "Atenas", dests);

dests = new Array("LCG","ALC","AMS","OVD","ATH","BIO","BRU","OTP","BUD","CMN","DBV","LPA","GRX","IBZ","XRY","LIS","MAD","MLA","RAK","MAH","MXP","DME","AGP","NCE","NAP","PMO","PMI","PAR","PSA","PRG","FCO","LED","SCQ","SVQ","TCI","WAW","VCE","VRN","VIE","VGO");

apts[5] = new airport(false, "BCN", "Barcelona", dests);

dests = new Array("BCN","IBZ","LON","MAH","AGP","PMI","SVQ","ATH","BUD","CMN","DBV","FCO","GRX","LPA","MLA","MXP","NAP","OTP","PAR","PMO","PRG","PSA","RAK","TCI","VCE","VIE","VRN","WAW","XRY");

apts[6] = new airport(false, "BIO", "Bilbao", dests);

dests = new Array("BCN","SVQ","VLC","AGP","FCO","LIS","MAD","MXP","PMI","PSA","VCE","VGO");

apts[7] = new airport(false, "BRU", "Bruselas", dests);

dests = new Array("BCN","VLC","AGP","BIO","DME","MAD","SVQ");

apts[8] = new airport(false, "OTP", "Bucarest", dests);

dests = new Array("BCN","AGP","BIO","DME","MAD","OVD","PAR","SVQ");

apts[9] = new airport(false, "BUD", "Budapest", dests);

dests = new Array("BCN","ATH","BIO","MAD");

apts[10] = new airport(false, "CMN", "Casablanca", dests);

dests = new Array("BCN","AGP","BIO","DME","MAD","OVD","PAR","SVQ");

apts[11] = new airport(false, "DBV", "Dubrovnik", dests);

dests = new Array("BCN","MAD","AGP","SVQ","ATH","BIO","DME","FCO","IBZ","LIS","NAP","PMI");

apts[12] = new airport(false, "LPA", "Gran Canaria", dests);

dests = new Array("BCN","BIO","DME","FCO","IBZ","LIS","MAD","MXP","PAR","PMI","PSA","VCE","VGO");

apts[13] = new airport(false, "GRX", "Granada", dests);

dests = new Array("ALC","BCN","BIO","MAD","MXP","PAR","FCO","SVQ","VLC","AGP","DME","GRX","LPA","OVD","RAK","SCQ","VGO");

apts[14] = new airport(false, "IBZ", "Ibiza", dests);

dests = new Array("BCN","BIO","FCO");

apts[15] = new airport(false, "XRY", "Jeréz / Cádiz", dests);

dests = new Array("BCN","MAD","AMS","ATH","BRU","FCO","GRX","LPA","PAR","PMI","PSA","RAK","SVQ");

apts[16] = new airport(false, "LIS", "Lisboa", dests);

dests = new Array("LCG","BIO","SVQ","VGO");

apts[17] = new airport(false, "LON", "Londres", dests);

dests = new Array("BCN","LPA","IBZ","LIS","MLA","MAH","NAP","PAR","FCO","TCI","VCE","AGP","ALC","AMS","ATH","BRU","BUD","CMN","DBV","DME","GRX","MXP","OTP","PMI","PMO","PRG","PSA","RAK","SVQ","VIE","VRN","WAW");

apts[18] = new airport(false, "MAD", "Madrid", dests);

dests = new Array("BCN","MAD","VLC","AGP","BIO","SVQ","VCE");

apts[19] = new airport(false, "MLA", "Malta (Valleta)", dests);

dests = new Array("BCN","BIO","DME","IBZ","LIS","MAD","MXP","OVD","PAR","PMI","SCQ","VCE");

apts[20] = new airport(false, "RAK", "Marrakech", dests);

dests = new Array("BCN","BIO","MAD","PAR","SVQ","VGO");

apts[21] = new airport(false, "MAH", "Menorca", dests);

dests = new Array("BCN","IBZ","VLC","AGP","ALC","AMS","BIO","BRU","DME","GRX","MAD","PAR","RAK","SVQ","VGO");

apts[22] = new airport(false, "MXP", "Milán", dests);

dests = new Array("BCN","ATH","BUD","DBV","FCO","GRX","IBZ","LPA","MAD","MXP","NAP","OTP","PMI","PMO","PRG","PSA","RAK","SVQ","TCI","VCE","VGO","VRN");

apts[23] = new airport(false, "DME", "Moscú (Domodedovo)", dests);

dests = new Array("AMS","BCN","BIO","LPA","PAR","FCO","SCQ","ATH","BRU","BUD","DBV","IBZ","MAD","MLA","MXP","NAP","OTP","PMI","PMO","PRG","PSA","VCE","VGO","VIE","VRN","WAW");

apts[24] = new airport(false, "AGP", "Málaga", dests);

dests = new Array("BCN");

apts[25] = new airport(false, "NCE", "Niza", dests);

dests = new Array("BCN","MAD","AGP","BIO","DME","LPA","SVQ");

apts[26] = new airport(false, "NAP", "Nápoles", dests);

dests = new Array("BCN","AGP","BIO","DME","MAD","SVQ");

apts[27] = new airport(false, "PMO", "Palermo", dests);

dests = new Array("BCN","BIO","AGP","ALC","AMS","BRU","DME","GRX","LIS","LPA","MAD","OVD","PAR","RAK","SCQ","SVQ","TCI","VGO","WAW");

apts[28] = new airport(false, "PMI", "Palma de Mallorca", dests);

dests = new Array("ALC","BCN","IBZ","MAD","AGP","FCO","SCQ","SVQ","VLC","ATH","BIO","BUD","DBV","GRX","LIS","MAH","MXP","OVD","PMI","PRG","PSA","RAK","VCE","VGO","VRN");

apts[29] = new airport(false, "PAR", "París", dests);

dests = new Array("BCN","AGP","ALC","AMS","BIO","BRU","DME","GRX","LIS","MAD","OVD","PAR","SVQ");

apts[30] = new airport(false, "PSA", "Pisa (Toscana)", dests);

dests = new Array("BCN","AGP","BIO","DME","MAD","OVD","PAR","SVQ");

apts[31] = new airport(false, "PRG", "Praga", dests);

dests = new Array("BCN","IBZ","MAD","AGP","PAR","SVQ","VLC","ALC","AMS","BIO","BRU","DME","GRX","LIS","LPA","OVD","SCQ","VGO","XRY");

apts[32] = new airport(false, "FCO", "Roma", dests);

dests = new Array("BCN");

apts[33] = new airport(false, "LED", "San Petersburgo", dests);

dests = new Array("BCN","AGP","PAR","ALC","AMS","FCO","IBZ","PMI","RAK","SVQ","VCE");

apts[34] = new airport(false, "SCQ", "Santiago de Compostela", dests);

dests = new Array("LCG","AMS","BCN","BIO","BRU","LPA","IBZ","LON","PAR","FCO","TCI","VLC","VCE","ATH","BUD","DBV","DME","LIS","MAD","MAH","MLA","MXP","NAP","OTP","OVD","PMI","PMO","PRG","PSA","SCQ","VGO","VIE","VRN","WAW");

apts[35] = new airport(false, "SVQ", "Sevilla", dests);

dests = new Array("BCN","MAD","SVQ","ATH","BIO","DME","PMI");

apts[36] = new airport(false, "TCI", "Tenerife", dests);

dests = new Array("AMS","BRU","OTP","IBZ","MLA","MXP","PAR","FCO","SVQ");

apts[37] = new airport(false, "VLC", "Valencia", dests);

dests = new Array("BCN","AGP","ATH","BIO","MAD","PMI","SVQ");

apts[38] = new airport(false, "WAW", "Varsovia", dests);

dests = new Array("BCN","MAD","SVQ","AGP","ALC","AMS","BIO","BRU","DME","GRX","MLA","OVD","PAR","RAK","SCQ");

apts[39] = new airport(false, "VCE", "Venecia", dests);

dests = new Array("BCN","AGP","BIO","DME","MAD","OVD","PAR","SVQ");

apts[40] = new airport(false, "VRN", "Verona", dests);

dests = new Array("BCN","AGP","BIO","MAD","SVQ");

apts[41] = new airport(false, "VIE", "Viena", dests);

dests = new Array("BCN","LON","AGP","ALC","AMS","ATH","BRU","DME","FCO","GRX","IBZ","MAH","MXP","PAR","PMI","SVQ");

apts[42] = new airport(false, "VGO", "Vigo", dests);

	
	return apts;
}


function buildAirports_submode()
{
	var apts_submode	= new Array();
	var dests;

	return apts_submode;
}

function buildAirportsResidents()
{
	var apts_resident	= new Array();
	var dests;
 dests = new Array( 'IBZ'); apts_resident[0] = new airport( false, "ALC", "Alicante", dests );
 dests = new Array( 'IBZ','XRY','AGP','MAH','PMI','SVQ'); apts_resident[1] = new airport( false, "BCN", "Barcelona", dests );
 dests = new Array( 'IBZ','AGP','SVQ'); apts_resident[2] = new airport( false, "BIO", "Bilbao", dests );
 dests = new Array( 'ALC','BCN','BIO','MAD','SVQ','VLC'); apts_resident[3] = new airport( false, "IBZ", "Ibiza", dests );
 dests = new Array( 'BCN'); apts_resident[4] = new airport( false, "XRY", "Jerez / Cádiz", dests );
 dests = new Array( 'MAD','SVQ'); apts_resident[5] = new airport( false, "LPA", "Gran Canaria", dests );
 dests = new Array( 'IBZ','LPA','MAH','TFN'); apts_resident[6] = new airport( false, "MAD", "Madrid", dests );
 dests = new Array( 'BCN','BIO','SCQ'); apts_resident[7] = new airport( false, "AGP", "Málaga", dests );
 dests = new Array( 'BCN','MAD'); apts_resident[8] = new airport( false, "MAH", "Menorca", dests );
 dests = new Array( 'BCN'); apts_resident[9] = new airport( false, "PMI", "Palma de Mallorca", dests );
 dests = new Array( 'AGP'); apts_resident[10] = new airport( false, "SCQ", "Santiago", dests );
 dests = new Array( 'BCN','BIO','IBZ','LPA','VLC'); apts_resident[11] = new airport( false, "SVQ", "Sevilla", dests );
 dests = new Array( 'MAD'); apts_resident[12] = new airport( false, "TFN", "Tenerife", dests );
 dests = new Array( 'IBZ','SVQ'); apts_resident[13] = new airport( false, "VLC", "Valencia", dests );

	return apts_resident;
}

function buildAirportsFamNum()
{
	var apts_resident	= new Array();
	var dests;
	dests = new Array( 'IBZ'); apts_resident[0] = new airport( false, "ALC", "Alicante", dests );
	dests = new Array( 'GRX','IBZ','XRY','MAD','AGP','MAH','PMI','SVQ','SCQ','VLC'); apts_resident[1] = new airport( false, "BCN", "Barcelona", dests );
	dests = new Array( 'IBZ','AGP','SVQ'); apts_resident[2] = new airport( false, "BIO", "Bilbao", dests );
	dests = new Array( 'BCN'); apts_resident[3] = new airport( false, "GRX", "Granada", dests );
	dests = new Array( 'ALC','BCN','BIO','MAD','SVQ','VLC'); apts_resident[4] = new airport( false, "IBZ", "Ibiza", dests );
	dests = new Array( 'BCN'); apts_resident[5] = new airport( false, "XRY", "Jerez / Cádiz", dests );
	dests = new Array( 'MAD','SVQ'); apts_resident[6] = new airport( false, "LPA", "Gran Canaria", dests );
	dests = new Array( 'BCN','IBZ','LPA','MAH','TFN'); apts_resident[7] = new airport( false, "MAD", "Madrid", dests );
	dests = new Array( 'BCN','BIO','SCQ'); apts_resident[8] = new airport( false, "AGP", "Málaga", dests );
	dests = new Array( 'BCN','MAD'); apts_resident[9] = new airport( false, "MAH", "Menorca", dests );
	dests = new Array( 'BCN'); apts_resident[10] = new airport( false, "PMI", "Palma de Mallorca", dests );
	dests = new Array( 'BCN','AGP'); apts_resident[11] = new airport( false, "SCQ", "Santiago", dests );
	dests = new Array( 'BCN','BIO','IBZ','LPA','VLC'); apts_resident[12] = new airport( false, "SVQ", "Sevilla", dests );
	dests = new Array( 'MAD'); apts_resident[13] = new airport( false, "TFN", "Tenerife", dests );
	dests = new Array( 'BCN','IBZ','SVQ'); apts_resident[14] = new airport( false, "VLC", "Valencia", dests );
	return apts_resident;
}

var fromOrig = '???';
function checkResidents( )
{
	if ( document.skylightsForm.isresi && ! document.skylightsForm.isresi.checked )
	{

		window.location = '/index.php?language=ES&mode=&sid=';

	}
	else
	{
		fromOrig = document.getElementById( "from1Select" ).options[ document.getElementById( "from1Select" ).selectedIndex ].value;
		document.getElementById( "from1Select" ).selectedIndex = 0;
		document.getElementById( "to1Select" ).selectedIndex = 0;
		onLoadAtaGlance();
		resetDest(1);
		fromOrig = '';
	}
}

function onDescuentos()
{
	var x = document.getElementById("frdisc");
	var index = x.selectedIndex;
	var option = x.options[index].value;
	var mode_act = "" != "" ? "" : "xxx";
	var reload = (mode_act == 'RESIDENT' || mode_act == 'FN1' || mode_act == 'FN2' || mode_act == 'RFN1' || mode_act == 'RFN2');
	var mode = "";
	if ( option == "" )
	{
		if( reload )
		{
		window.location = '/index.php?language=ES&mode=&sid=';
		}
		else
		{
			fromOrig = document.getElementById( "from1Select" ).options[ document.getElementById( "from1Select" ).selectedIndex ].value;
			document.getElementById( "from1Select" ).selectedIndex = 0;
			document.getElementById( "to1Select" ).selectedIndex = 0;
			onLoadAtaGlance();
			resetDest(1);
			fromOrig = '';
		}
	}
	else if( option == "res" || option == "famres1" || option == "famres2" || option == "fam1" || option == "fam2" )
	{
		fromOrig = document.getElementById( "from1Select" ).options[ document.getElementById( "from1Select" ).selectedIndex ].value;
		document.getElementById( "from1Select" ).selectedIndex = 0;
		document.getElementById( "to1Select" ).selectedIndex = 0;
		onLoadAtaGlance();
		resetDest(1);
		fromOrig = '';
	}
}

function captureDateText(dateText)
{

dateText.departDatePast	 = "\nThe date you selected has already passed.\n\nClick OK to reset your date selection.\n";
dateText.datesNotSameDate = "\nThe dates are not the same.\n";
dateText.datesNotFutureTime	= "\nThe time or date selected maybe the same or overlaps in the past. Please reselect the date or time.\n";				
dateText.datesOverlap1	= "Por favor, asegúrate de que la ";
dateText.datesOverlap2 = "\nno es anterior a la  ";
dateText.datesOverlap3	= "\n\nPulsa OK para reiniciar la  ";
dateText.datesOverlapDepart = "fecha de salida. ";
dateText.datesOverlapReturn	= "fecha de regreso ";		
dateText.datesOverlapDepartCar = "";
dateText.datesOverlapReturnCar = "";
dateText.datesOverlapDepartHotel	= "";
dateText.datesOverlapReturnHotel	= "";
dateText.datesOverlapDepartAct = "";
dateText.datesOverlapReturnAct = "";
dateText.months = new Array();
dateText.months[0]	= "Enero";
dateText.months[1]	= "Febrero";
dateText.months[2]	= "Marzo";
dateText.months[3]	= "Abril";
dateText.months[4]	= "Mayo";
dateText.months[5]	= "Junio";
dateText.months[6]	= "Julio";
dateText.months[7]	= "Agosto";
dateText.months[8]	= "Septiembre";
dateText.months[9]	= "Octubre";
dateText.months[10] = "Noviembre";
dateText.months[11] = "Diciembre";
dateText.sameDayWarning = "La fecha de regreso es\nla misma que la fecha de salida.\n\n¿este viaje tan corto es deliberado?";
dateText.invaliddepartDay1 = "\nLa fecha de salida no es válida.\n";
dateText.invaliddepartDay2 = "\nLa fecha de regreso no es válida.\n";
dateText.invalidcheckinDay1 = "\nYour checkin date is invalid.\n";
dateText.invalidcheckoutDay1 = "\nYour checkout date is invalid.\n";
dateText.invalidcarPickupDay	= "\nYour pick-up date is invalid.\n";
dateText.invalidcarDropoffDay = "\nYour drop-off date is invalid.\n";
dateText.invalidactivityStartDay1 = "\nYour activity start date is invalid.\n";
dateText.invalidactivityEndDay1 = "\nYour activity end date is invalid.\n";
dateText.invalidMonthHasOnly = " sólo tiene ";
dateText.invalidMonthHasOnlyDays = " días.\n";
}


function validMaxMinDates()
{
	var doc = document.skylightsForm;
	var origen = doc.from1Select.value;
	var destino = doc.to1Select.value 
	var ruta = origen + destino;
	var out = fecha_minima_vuelo[ruta];
	var tmp_ahora = new Date();
	var fecha_ahora = Date.UTC(tmp_ahora.getYear(), tmp_ahora.getMonth(), tmp_ahora.getDate());
	oDay = doc.departDay1.options[doc.departDay1.selectedIndex].value;
	oMonth = doc.departMonth1.options[doc.departMonth1.selectedIndex].value.substring(4,6);
	oYear = doc.departMonth1.options[doc.departMonth1.selectedIndex].value.substring(0,4);
	var tmp_ida = new Date(oYear, oMonth-1, oDay);
	var fecha_ida = Date.UTC(tmp_ida.getYear(), tmp_ida.getMonth(), tmp_ida.getDate());
	if (doc.roundTripRadio.checked) {
		rDay = doc.departDay2.options[doc.departDay2.selectedIndex].value;
		rMonth = doc.departMonth2.options[doc.departMonth2.selectedIndex].value.substring(4,6);
		rYear = doc.departMonth2.options[doc.departMonth2.selectedIndex].value.substring(0,4);
		var tmp_vuelta = new Date(rYear, rMonth-1, rDay);
		var fecha_vuelta = Date.UTC(tmp_vuelta.getYear(), tmp_vuelta.getMonth(), tmp_vuelta.getDate());
	}
	if (out != undefined) { 
		var tmp_min = new Date(out[2], out[1] - 1, out[0]);
		var fecha_min = Date.UTC(tmp_min.getYear(), tmp_min.getMonth(), tmp_min.getDate());
		if ("ES" == "EU") {
			mensaje = origen + " - " + destino + "  no opera hasta el  Por favor, selecciona otras fechas.";
		}
		else {
			mensaje = "La ruta " + origen + " - " + destino + "  no opera hasta el " + out[0] + "/" + out[1] + "/" + out[2] + ". Por favor, selecciona otras fechas.";
		}
		if (fecha_ida < fecha_min) {
			alert (mensaje);
			return false;
		}
	}	
	out = fecha_maxima_vuelo[ruta];
	if (out != undefined) { 
		var tmp_fin = new Date(out[2], out[1] - 1, out[0]);
		var fecha_fin = Date.UTC(tmp_fin.getYear(), tmp_fin.getMonth(), tmp_fin.getDate());
		var date_vuelta = rYear + rMonth + rDay;
		var test = out[2] + out[1] + out[0];
		if ( ( out[3]== '1')&&( test < date_vuelta) ) {
			mensaje = "Esta ruta ya no está disponible para estas fechas.";
			alert(mensaje);
			return false;
		}
		if ("ES" == "EU") {
				mensaje = origen + " - " + destino + "La ruta " + out[2] + "-" + out[1] + "-" + out[0] + " no opera más allá del ";
		}
		else {
			mensaje = "La ruta " + origen + " - " + destino + " no opera más allá del " + out[0] + "/" + out[1] + "/" + out[2] + " (temporada de invierno)";
		}
		if (ruta == "BCNMAD" || ruta == "MADBCN" || ruta == "BCNPMI" || ruta == "PMIBCN") {
			mensaje = "La reserva de billetes para esta ruta todavía no está disponible. Por favor, vuelve a intentarlo dentro de unos días.";
		}
		if (fecha_ida > fecha_fin || ( fecha_vuelta != undefined && fecha_vuelta > fecha_fin)) {
			mensaje = "La reserva de billetes para esta ruta todavía no está disponible. Por favor, vuelve a intentarlo dentro de unos días.";
			alert (mensaje);
			return false;
		}
	}
	return true;
}

		flash_versions = 20;
		var flash = new Object();
		flash.installed=false;
		flash.version='0.0';
		if (navigator.plugins && navigator.plugins.length) {
			for (x=0; x < navigator.plugins.length; x++) {
				if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
					flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
					flash.installed = true;
					break;
				}
			}
		}
		else if (window.ActiveXObject) {
			for (x = 2; x <= flash_versions; x++) {
				try {
					oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
					if(oFlash) {
						flash.installed = true;
						flash.version = x + '.0';
					}
				}
				catch(e) {}
			}
		}
		flash.ver = Array();
		for(i = 4; i <= flash_versions; i++) {
			eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
}			

cookieContainer = document;
ADS_COOKIE_NAME = "com.vueling.ads.seen";
var oDay;
var oMonth;
var oYear;
var rDay;
var rMonth;
var rYear;
var idiomaweb = 'ES';
var formweb = 'skylightsForm';

var mode_Pares = false;
var popup_february_leap_year = '';
var popup_february_leap_year = '';
var april = 'Abril';
var june = 'Junio';
var september = 'Septiembre';
var november = 'Noviembre';
var popup_sector_1_orig_missing = 'Selecciona la ciudad de salida.';
var popup_sector_1_dest_missing = 'Selecciona tu destino.';
var popup_sector_2_pair_incomplete = 'Your returning city pair is incomplete. Please\nchoose two cities or clear the selected one.';
var popup_illogical_open_jaw = 'The selected outbound and return city pairs\nare not logical. You should either return to the \nsame city you fly out from, or return from the\nsame city you fly into.\n';
var sector1_o = '';
var sector1_d = '';
var sector2_o = '';
var sector2_d = '';
var swap_icon_ok = true;
var calendarWindow = null;
var sector_2_month_index = 1;
var sector_2_day_index = 1;
var sector_2_range_index = 0;
var sector_2_org_prev = -1;
var sector_2_des_prev = -1;
var sector_2_m_prev = 1;
var sector_2_d_prev = 1;
var sector_2_r_prev = sector_2_range_index;
var Dests = new Array ('ALC','AMS','ATH','BCN','BIO','BRU','LPA','GRX','IBZ','XRY','LIS','MAD','AGP','MLA','MAH','MXP','NAP','NCE','PMI','CDG','FCO','SCQ','SVQ','TFN','VLC','VCE',0);
var sALC = 'Alicante'; var sAMS = 'Amsterdam'; var sATH = 'Atenas'; var sBCN = 'Barcelona'; var sBIO = 'Bilbao'; var sBLQ = 'Bolonia'; var sBRU = 'Bruselas'; var sLPA = 'Gran Canaria'; var sGRX = 'Granada'; var sIBZ = 'Ibiza'; var sXRY = 'Jerez / Cádiz'; var sLIS = 'Lisboa'; var sMAD = 'Madrid'; var sAGP = 'Málaga'; var sMLA = 'Malta (Valleta)'; var sMAH = 'Menorca'; var sMXP = 'Milán'; var sNAP = 'Nápoles'; var sNCE = 'Niza'; var sPMI = 'Palma de Mallorca'; var sCDG = 'París'; var sPSA = 'Pisa / Toscana'; var sFCO = 'Roma'; var sSCQ = 'Santiago'; var sSVQ = 'Sevilla'; var sTFN = 'Tenerife'; var sVLC = 'Valencia'; var sVCE = 'Venecia'; var aALC = new Array('IBZ','CDG', 0);var aAMS = new Array('BCN','AGP','SVQ','VLC', 0);var aATH = new Array('BCN', 0);var aBCN = new Array('AMS','ATH','BRU','GRX','IBZ','XRY','LIS','MAD','AGP','MAH','MXP','NCE','PMI','CDG','FCO','SCQ','SVQ','VCE', 0);var aBIO = new Array('IBZ','AGP','SVQ', 0);var aBRU = new Array('BCN','SVQ','VLC', 0);var aLPA = new Array('MAD','SVQ', 0);var aGRX = new Array('BCN','CDG','FCO', 0);var aIBZ = new Array('ALC','BCN','BIO','MAD','MXP','CDG','SVQ','VLC', 0);var aXRY = new Array('BCN', 0);var aLIS = new Array('BCN','MAD', 0);var aMAD = new Array('BCN','LPA','IBZ','LIS','MLA','MAH','MXP','NAP','CDG','FCO','TFN','VCE', 0);var aAGP = new Array('AMS','BCN','BIO','CDG','FCO','SCQ', 0);var aMLA = new Array('MAD', 0);var aMAH = new Array('BCN','MAD', 0);var aMXP = new Array('BCN','IBZ','MAD','SVQ','VLC', 0);var aNAP = new Array('MAD', 0);var aNCE = new Array('BCN', 0);var aPMI = new Array('BCN', 0);var aCDG = new Array('ALC','BCN','GRX','IBZ','MAD','AGP','FCO','SCQ','VCE', 0);var aFCO = new Array('BCN','GRX','MAD','AGP','CDG','SVQ', 0);var aSCQ = new Array('BCN','AGP','CDG', 0);var aSVQ = new Array('AMS','BCN','BIO','BRU','LPA','IBZ','MXP','FCO','VLC','VCE', 0);var aTFN = new Array('MAD', 0);var aVLC = new Array('AMS','BRU','IBZ','MXP','SVQ', 0);var aVCE = new Array('BCN','MAD','CDG','SVQ', 0);function init()
{

	var origBox	= document.skylightsForm.sector1_o;
	var destBox	= document.skylightsForm.sector1_d;
	var origIndex	= origBox.selectedIndex;
	var destIndex	= destBox.selectedIndex;

	if ( document.dest1Form.dIndex.value != "zz" )
	{
		destIndex	= document.dest1Form.dIndex.value;
	}
	else
	{
		document.dest1Form.dIndex.value = destIndex;
	}
	change_sector_2_fields( '', true );

	if (document.skylightsForm.travel_type[1].checked)
	{
		swap_icon('calendar_2', 'frozen'); swap_icon_ok	= false;
	}
	 defaultStatus	= 'Reserva OnLine con Vueling';

	changeOrigDestList(origBox, destBox, 'Destino', true, 1, '', '' );

	var host_name = window.location.host;
	var form_action = document.skylightsForm.action;
	if (form_action.indexOf(host_name) == -1)
	{
		var regExp = new RegExp("://[^/]+/", "i");
		new_form_action = form_action.replace(regExp, "://" + host_name + "/");
		document.skylightsForm.action = new_form_action;
	}
}
function changeOrigDestList(origBox, destBox, labelDest, fromOnload, whichSector, labelOpenJaw, preferredDest)
{
	if (!document.images)
	{
		return;
	}
	var origIndex	= eval(origBox.selectedIndex);
	var destIndex;
	var initDest	= 0;
	if ( whichSector == 1 ) 
	{
		destIndex	= document.dest1Form.dIndex.value;
	}
	else
	{
		destIndex	= eval(destBox.selectedIndex);
		initDest	= document.dest2Form.dIndex.value;
	}
	var orig   	= origBox.options[ origIndex ].value;
	var dest  	= destBox.options[ destIndex ].value;
	if (orig != "XXX")
	{
		if( document.skylightsForm.isresi != null && document.skylightsForm.isresi.checked )
		{
			orig = 'resi_' + orig;
			orig						= eval(orig);
		}
		else
		{
			orig						= eval(orig);
		}
		destBox.length				= 1;
		var newDest					= new Option(labelDest);
		destBox.options[0]			= newDest;
		destBox.options[0].value	= "XXX";
		for (var i = 0; i < orig.length - 1; i++)
		{
			if ( orig[i] != "" )
			{
				destBox.length += 1;

					destBox.options[destBox.length - 1]
						= new Option( eval('s' + orig[i]) + " (" + orig[i] + ")" );
					destBox.options[destBox.length - 1].value = orig[i];

					if ( dest == destBox.options[destBox.length - 1].value )
					{
						initDest = destBox.length - 1
					}
			}
		}
		if (fromOnload == true)
		{
			origBox.selectedIndex = origIndex;
			destBox.selectedIndex = destIndex;
			if (whichSector == 1)
			{
				document.dest1Form.dIndex.value = destIndex;
			}
		}
		else
		{
				destBox.selectedIndex	= ( initDest > destBox.options.length - 1)
									? destBox.options.length - 1 : initDest;
			if (whichSector == 1)
			{
				document.dest1Form.dIndex.value = initDest;
			}
			else
			{
				document.dest2Form.dIndex.value = initDest;
			}
		}
	}
	else
	{
		refillDestList( destBox, labelDest, labelOpenJaw);
	}
}	
function refillDestList(destBox, labelDest, unusedOption)
{
	var destValue				= destBox.options[ destBox.selectedIndex ].value;
	destBox.length				= 1;
	destBox.options[0]			= new Option(labelDest);
	destBox.options[0].value		= "XXX";
	var i					= 1;
	var selIndex				= 0;
	if ( unusedOption )
	{
		destBox.length				+= 1;
		var newOption				= new Option( unusedOption );
		destBox.options[i]			= newOption;
		destBox.options[i].value	= "XXX";
		i++;
	}
	if( document.skylightsForm.isresi != null && document.skylightsForm.isresi.checked )
	{
		for(var j = 0; j < (DestsResi.length - 1); j++)
		{
			destBox.length += 1;

				var newOption = new Option(eval('s' + DestsResi[j]) + " (" + DestsResi[j] + ")");
			destBox.options[i + j]		= newOption;
			destBox.options[i + j].value	= DestsResi[j];
			if(destValue == DestsResi[j])
			{
				selIndex		= i + j;
			}
		}	
	}
	else
	{
		for(var j = 0; j < (Dests.length - 1); j++)
		{
			destBox.length += 1;

				var newOption = new Option(eval('s' + Dests[j]) + " (" + Dests[j] + ")");
			destBox.options[i + j]		= newOption;
			destBox.options[i + j].value	= Dests[j];
			if(destValue == Dests[j])
			{
				selIndex		= i + j;
			}
		}
	}
	destBox.selectedIndex = selIndex;
}	
function setPassengerTypes()
{
	var paxTypes = "";


			var paxTypeSelect = document.skylightsForm.ADULT;
			var paxTypeADULTNum
				= paxTypeSelect.options[paxTypeSelect.selectedIndex].value;
			var paxTypeADULTCode	= "ADULT";
			paxTypes = paxTypes + paxTypeADULTNum
						+ paxTypeADULTCode;
			

			var paxTypeSelect = document.skylightsForm.CHILD;
			var paxTypeCHILDNum
				= paxTypeSelect.options[paxTypeSelect.selectedIndex].value;
			var paxTypeCHILDCode	= "CHILD";
			paxTypes = paxTypes + paxTypeCHILDNum
						+ paxTypeCHILDCode;
				document.skylightsForm.pT.value = paxTypes;
}	

function captureDates()
{
	oMonth	= document.skylightsForm.sector_1_m.options[document.skylightsForm.sector_1_m.selectedIndex].value.substring(0,2);
	oYear	= document.skylightsForm.sector_1_m.options[document.skylightsForm.sector_1_m.selectedIndex].value.substring(2,6);
	rMonth	= document.skylightsForm.sector_2_m.options[document.skylightsForm.sector_2_m.selectedIndex].value.substring(0,2);
	rYear	= document.skylightsForm.sector_2_m.options[document.skylightsForm.sector_2_m.selectedIndex].value.substring(2,6);

	oDay = document.skylightsForm.sector_1_d.options[document.skylightsForm.sector_1_d.selectedIndex].value;
	rDay	 = document.skylightsForm.sector_2_d.options[document.skylightsForm.sector_2_d.selectedIndex].value;

}
function change_sector_2_fields( whichDot, fromOnload )
{
	var roundtrip;
		if (whichDot == 0)
	{
		roundtrip = true;
	}
	else if ( !whichDot && document.skylightsForm.travel_type[0].checked == true )
	{
		roundtrip = true;
	}
	else
	{
		roundtrip = false;
	}
	if (roundtrip == true)
	{
		if (fromOnload != true)
		{


			var temp_m = document.skylightsForm.sector_1_m.selectedIndex + 1;
			var temp_d = document.skylightsForm.sector_1_d.selectedIndex + 1;
			if ( ( sector_2_month_index < temp_m ) ||
				 (( sector_2_month_index == temp_m) &&
				 ( sector_2_day_index < temp_d)))
			{
				document.skylightsForm.sector_2_m.selectedIndex = temp_m;
				document.skylightsForm.sector_2_d.selectedIndex = temp_d;
			}
			else
			{
				document.skylightsForm.sector_2_m.selectedIndex = sector_2_month_index;
				document.skylightsForm.sector_2_d.selectedIndex = sector_2_day_index;
			}
		}
		swap_icon_ok = true;
		if (document.images.calendar_2) {
			swap_icon('calendar_2', 'cold');
		}
	}
	else
	{
				sector_2_month_index = document.skylightsForm.sector_2_m.selectedIndex;
		if (sector_2_month_index == 0)
		{
			sector_2_month_index = 1;
		}
		sector_2_day_index  = document.skylightsForm.sector_2_d.selectedIndex;
		if (sector_2_day_index == 0)
		{
			sector_2_day_index = 1;
		}
		document.skylightsForm.sector_2_m.selectedIndex = 0;
		document.skylightsForm.sector_2_d.selectedIndex = 0;
		if (document.images.calendar_2) {
			swap_icon('calendar_2', 'frozen');
		}
		swap_icon_ok = false;
	}
}
function correctDay(dayToSelect,mkt,monthText)
{
	var i		= 27;
	var okay 	= true;
	if (mkt == 1)
	{
		while (eval(document.skylightsForm.sector_1_d.options[i].value) != dayToSelect)
		{
			i++;
		}
		alert("\n" + monthText + "" + dayToSelect + "")
		document.skylightsForm.sector_1_d.options.selectedIndex = i
		okay = false;
		captureDates();
	}
	else if (mkt == 2)
	{
		while (eval(document.skylightsForm.sector_2_d.options[i].value) != dayToSelect)
		{
			i++;
		}
		alert("\n" + monthText + "" + dayToSelect + "")
		document.skylightsForm.sector_2_d.options.selectedIndex = i;
		captureDates();
		okay = false;
	}
	return okay;
}
function finalDate()
{
	var okay = true;
		if(typeof oMonth == 'undefined' || typeof rMonth == 'undefined' || typeof oDay == 'undefined' || typeof rDay == 'undefined') {
			var oDay = document.skylightsForm.departDay1.value;
			var rDay = document.skylightsForm.departDay2.value;
			var oMonth = document.skylightsForm.departMonth1.value;
			var rMonth = document.skylightsForm.departMonth2.value;
		}
	
		var oMonthYear= "" + oYear + oMonth;
		if ( okay == true && oDay == 23 && oMonthYear == 200807 )
		{			alert("\nBecause today\'s date has been selected, only \nflights that leave today at least 2 horas00 minutos\nfrom the current time will be shown on the next page.\n");
		}
		return okay;
}
function checkDate()
{
	var okay = true;
	var oMonthYear= '' + oYear + oMonth;
	var rMonthYear= '' + rYear + rMonth;

	if ( ! checkCalendarDate("1",oDay,oMonth,oYear) )
	{
		okay = false;
	}
	if ( ! checkCalendarDate("2",rDay,rMonth,rYear) )
	{
		okay = false;
	}	if ( oDay < 23 && oMonthYear <= 200807 )
	{
		alert("\nThe date you selected has already passed.\n\nClick OK to reset your date selection.\n");
		document.skylightsForm.sector_1_d.options.selectedIndex = 22;
		captureDates();
		okay = false;
	}
		if ( ( oDay > 28 && oMonthYear >= 200903 ) || ( rDay > 28 && rMonthYear >= 200903 ) )
		{
			alert("Seleccione fechas anteriores \nal Sab, 28 Mar 09. \n\nPulse OK para modificar su selección.\n");
			if ( oDay > 28 && oMonthYear >= 200903 )
			{
				document.skylightsForm.sector_1_d.options.selectedIndex = (27);
			}
			if ( rDay > 28 && rMonthYear >= 200903 )
			{
				document.skylightsForm.sector_2_d.options.selectedIndex = (27);
			}
			captureDates();
			okay = false;
		}
		if ( ( rDay < oDay && rMonthYear <= oMonthYear ) || rMonthYear < oMonthYear )
	{
		if ( rDay != 0 && rMonth != 0 )
		{
			alert("\n\n")
			document.skylightsForm.sector_2_d.options.selectedIndex = eval(document.skylightsForm.sector_1_d.options.selectedIndex) + 1;
			document.skylightsForm.sector_2_m.options.selectedIndex = eval(document.skylightsForm.sector_1_m.options.selectedIndex) + 1;
			captureDates();
			okay = false;
		}
	}
	else if ( ( sector2_o == 'XXX' || sector2_d == 'XXX' )
		&& ( rMonth != 0 || rDay != 0 ) )
	{
		alert("\nYou have entered a round trip return date, but you have\nnot entered a complete city pair for the return flight.\nPlease choose both cities.\n");
		okay = false;
	}
	return okay;
}	
function checkPassenger()
{
var totalPax = 0;
var adults = 0;
		var paxTypeSelect = document.skylightsForm.ADULT;
		totalPax += paxTypeSelect.options[paxTypeSelect.selectedIndex].value;adults = paxTypeSelect.options[paxTypeSelect.selectedIndex].value
	
		var paxTypeSelect = document.skylightsForm.CHILD;
		totalPax += paxTypeSelect.options[paxTypeSelect.selectedIndex].value;
	if ( totalPax <= 0 )
{
	alert("\nYou must enter at least one passenger.\n");
	return false;
}
var infants  = 0;
var childs = 0;
var infant_select = document.skylightsForm.INFANT;
var child_select = document.skylightsForm.CHILD;
if ( child_select.selectedIndex )
{
	childs = child_select.options[child_select.selectedIndex].value;
}
if ( infant_select )
{
	infants = infant_select.options[infant_select.selectedIndex].value;
}
adults = parseInt(adults);
infants = parseInt(infants);
childs = parseInt(childs);
infants=infants+childs;
if ( (adults  / infants) < 1 )
{
	alert("\nIf you wish to book a greater number of\nInfants than Adults, please contact our\nreservation center for possible arrangements.\n");
	return false;
}
return true;
}	function open_calendar(sector)
	{
		if ( document.skylightsForm.travel_type[0].checked || sector == 1 )
		{
			if ( window.calendarWindow && ! calendarWindow.closed )
			{
				calendarWindow.focus();
			}
			else
			{
				var form_action = document.skylightsForm.action;
				var action_array = form_action.split("?");
				var the_form_action = "";
				if (action_array.length > 0)
					the_form_action = action_array[0];
				calendarWindow 	= window.open(the_form_action + "?module=SB&page=CALENDAR&language=ES&mode=&sid=&form_name=skylightsForm","calendar","width=,height=,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,resizable=0");
				document.calForm.month_selected.value
					= document.skylightsForm['sector_' + sector + '_m'].selectedIndex - sector + 1;
				document.calForm.sector.value 	= sector;
			}
		}
	}
if (document.images)
{
		var calendar_1_icon_cold		= new Image();
		calendar_1_icon_cold.src 	= '';
		var calendar_1_icon_warm		= new Image();
		calendar_1_icon_warm.src	= '';
		var calendar_1_icon_hot			= new Image();
		calendar_1_icon_hot.src		= '';
		var calendar_1_icon_frozen		= new Image();
		calendar_1_icon_frozen.src	= '';
		var calendar_2_icon_cold		= new Image();
		calendar_2_icon_cold.src 	= '';
		var calendar_2_icon_warm		= new Image();
		calendar_2_icon_warm.src	= '';
		var calendar_2_icon_hot			= new Image();
		calendar_2_icon_hot.src		= '';
		var calendar_2_icon_frozen		= new Image();
		calendar_2_icon_frozen.src	= '';
}
function changeResidentsAirports()
{
	
	var selectedOrig = document.skylightsForm.sector1_o.options[document.skylightsForm.sector1_o.selectedIndex].value;
	var selectedDest = document.skylightsForm.sector1_d.options[document.skylightsForm.sector1_d.selectedIndex].value;
	
	refillDestList( document.skylightsForm.sector1_o, 'Origen', 0);
	refillDestList( document.skylightsForm.sector1_d, 'Destino', 0);
	
	for( var i = 0; i < document.skylightsForm.sector1_o.options.length; i++ )
		if( document.skylightsForm.sector1_o.options[i].value != 'XXX' )
			document.skylightsForm.sector1_o.options[i].value = 'a' + document.skylightsForm.sector1_o.options[i].value;
	
	var selectedO = 0;
	document.skylightsForm.sector1_o.selectedIndex = 0;
	for( var i = 0; i < document.skylightsForm.sector1_o.options.length; i++ )
		if( document.skylightsForm.sector1_o.options[i].value == selectedOrig )
		{
			document.skylightsForm.sector1_o.selectedIndex = i;
			selectedO;
		}
	
	changeOrigDestList(document.skylightsForm.sector1_o, document.skylightsForm.sector1_d, 'Destino', false, 1);
	
	document.skylightsForm.sector1_d.selectedIndex = 0;
	if( !selectedO )
	{
		for( var i = 0; i < document.skylightsForm.sector1_d.options.length; i++ )
			if( document.skylightsForm.sector1_d.options[i].value == selectedDest )
				document.skylightsForm.sector1_d.selectedIndex = i;
	}
}
 function reconcile_dates()
 {
	var m1y_ix = document.SBform.sector_1_m.selectedIndex + 1;
	if  ( document.SBform.sector_2_m.selectedIndex != 0 )
	{
		if ( m1y_ix > document.SBform.sector_2_m.selectedIndex )
		{
			document.SBform.sector_2_m.selectedIndex = m1y_ix;
		}
	 }
 }
function checkSBdata()
{
var tmp_ahora = new Date();
var fecha_ahora = Date.UTC(tmp_ahora.getYear(), tmp_ahora.getMonth(), 1);
var tmp_ida = new Date(oYear, oMonth - 1, oDay);
var fecha_ida = Date.UTC(tmp_ida.getYear(), tmp_ida.getMonth(), tmp_ida.getDate());
if (rYear!=0) {
	var tmp_vuelta = new Date(rYear, rMonth - 1, rDay);
	var fecha_vuelta = Date.UTC(tmp_vuelta.getYear(), tmp_vuelta.getMonth(), tmp_vuelta.getDate());
}

var oMonthYear	= '' + oYear + oMonth;
var rMonthYear	= '' + rYear + rMonth;
var oLeapYear	= ( oYear % 4 == 0 && ( oYear % 100 != 0 || oYear % 400 == 0 ) ) ? true : false;
var rLeapYear	= ( rYear % 4 == 0 && ( rYear % 100 != 0 || rYear % 400 == 0 ) ) ? true : false;
if ( ( oMonth == 2 && oDay > 29 && oLeapYear ) || ( oMonth == 2 && oDay > 28 && !oLeapYear ) || ( oMonth == 4 && oDay > 30 ) || ( oMonth == 6 && oDay > 30 ) || ( oMonth == 9 && oDay > 30 ) || ( oMonth == 11 && oDay > 30 ) || ( rMonth == 2 && rDay > 29 && rLeapYear ) || ( rMonth == 2 && rDay > 28 && !rLeapYear ) || ( rMonth == 4 && rDay > 30 ) || ( rMonth == 6 && rDay > 30 ) || ( rMonth == 9 && rDay > 30 ) || ( rMonth == 11 && rDay > 30 )


	|| ( oDay < 23 && oMonthYear <= 200807 )

 
	|| ( ( oDay > 28) && (oMonthYear >= 200903 )
	|| ( rDay > 28) && (rMonthYear >= 200903 ) )

	|| ( ( ( rDay < oDay && rMonthYear <= oMonthYear ) || rMonthYear < oMonthYear ) && ( rDay != 0 && rMonth != 0 ) ) || ( ( rMonth != 0 && rDay == 0 ) || ( rMonth == 0 && rDay != 0 ) ) )
{
	alert ("\nLas fechas que has escogido para los vuelos no son\nválidas o no están disponibles. Escoge\nuna fecha de partida y/o regreso distinta.\n");
	return false;
}
if ("JSTEMPLATE" != "FAREFINDER") { 
	if (fecha_ida < fecha_ahora || (fecha_vuelta!=undefined && fecha_vuelta < fecha_ahora)) {
		alert ("\nLas fechas que has escogido para los vuelos no son\nválidas o no están disponibles. Escoge\nuna fecha de partida y/o regreso distinta.\n");
		return false;
	}
}


var totalPax	= 0;
var adults	= 0;


var paxTypeSelect = document.skylightsForm.ADULT;
totalPax += paxTypeSelect.options[paxTypeSelect.selectedIndex].value * 1;
		adults = paxTypeSelect.options[paxTypeSelect.selectedIndex].value;
	

var paxTypeSelect = document.skylightsForm.CHILD;
totalPax += paxTypeSelect.options[paxTypeSelect.selectedIndex].value * 1;
		
	var infants = 0;
var childs = 0;
var infant_select = document.skylightsForm.INFANT;
var child_select = document.skylightsForm.CHILD;
if ( child_select.selectedIndex )
{
	childs = child_select.options[child_select.selectedIndex].value;
}
if ( infant_select.selectedIndex )
{
	infants = infant_select.options[infant_select.selectedIndex].value;
}
if (totalPax <= 0 || totalPax > 25)
{
	alert("\nHas introducido un número de pasajeros que no es válido.\n Sólo se te permite un máximo de  25 pasajeros por reserva.\n Si deseas reservar un número superior al indicado, utiliza el formulario para reservas de grupo\n");
	return false;
}
adults = parseInt(adults);
infants = parseInt(infants);
childs = parseInt(childs);
if (adults < infants )
{
	alert("\nHas introducido un número de pasajeros que no es válido.\n Si quieres reservar un número mayor de bebés que de adultos,\n ponte en contacto con nuestra Central de Reservas Vueling en el 902 33 39 33.\n");
	return false;
}

if ("JSTEMPLATE" != "FAREFINDER") {
	var ruta = sector1_o + sector1_d;
	var out = fecha_minima_vuelo[ruta];
	if (out != undefined) { 

		var doc = document.SBform;
		var origen = doc.sector1_o[doc.sector1_o.selectedIndex].text.replace(/\(.*\)/, "");
		var destino = doc.sector1_d[doc.sector1_d.selectedIndex].text.replace(/\(.*\)/, "");
		var tmp_fin = new Date(out[2], out[1] - 1, out[0]);
		var fecha_fin = Date.UTC(tmp_fin.getYear(), tmp_fin.getMonth(), tmp_fin.getDate());
		if ("ES" == "EU") {
			mensaje = origen + " - " + destino + "  no opera hasta el  Por favor, selecciona otras fechas.";
		}
		else {
			mensaje = "La ruta " + origen + " - " + destino + "  no opera hasta el " + out[0] + "/" + out[1] + "/" + out[2] + ". Por favor, selecciona otras fechas.";
		}
		if (fecha_vuelta!=undefined) {
			if (fecha_ida < fecha_fin || fecha_vuelta < fecha_fin) {
				alert (mensaje);
				return false;
			}
		}
		else {
			if (fecha_ida < fecha_fin) {
				alert (mensaje);
				return false;
			}
		}
	}
	
	var ruta = sector1_o + sector1_d;
	var out = fecha_maxima_vuelo[ruta];
	
	if (out != undefined) { 
		
		var doc = document.SBform;
		var origen = doc.sector1_o[doc.sector1_o.selectedIndex].text.replace(/\(.*\)/, "");
		var destino = doc.sector1_d[doc.sector1_d.selectedIndex].text.replace(/\(.*\)/, "");
		var tmp_fin = new Date(out[2], out[1] - 1, out[0]);
		var fecha_fin = Date.UTC(tmp_fin.getYear(), tmp_fin.getMonth(), tmp_fin.getDate());
		var mensaje = "";
		if ("ES" == "EU") {
			mensaje = origen + " - " + destino + "La ruta " + out[2] + "-" + out[1] + "-" + out[0] + " no opera más allá del ";
		}
		else {
			mensaje = "La ruta " + origen + " - " + destino + " no opera más allá del " + out[0] + "/" + out[1] + "/" + out[2] + " (temporada de invierno)";
		}
		if (ruta == "BCNMAD" || ruta == "MADBCN" || ruta == "BCNPMI" || ruta == "PMIBCN") {
			mensaje = "La reserva de billetes para esta ruta todavía no está disponible. Por favor, vuelve a intentarlo dentro de unos días.";
		}
		if (fecha_ida > fecha_fin || (fecha_vuelta!=undefined && fecha_vuelta > fecha_fin)) {
			mensaje = "La reserva de billetes para esta ruta todavía no está disponible. Por favor, vuelve a intentarlo dentro de unos días.";
			alert (mensaje);
			return false;
		}
	}
}
return true;
}

// XMS SelectCities
function selectCitiesXJS(market)
{
	var index;
	var offer_open_jaw_routes = "false";
	if (market == 1 || offer_open_jaw_routes == "true") {
		if (market == 1) {
			index = document.forms.skylightsForm.from1;

		} else {
			index = document.forms.skylightsForm.from2;
			
		}
index.options[1] = new Option("Alicante (ALC)","ALC");index.options[2] = new Option("Amsterdam (AMS)","AMS");index.options[3] = new Option("Atenas (ATH)","ATH");index.options[4] = new Option("Barcelona (BCN)","BCN");index.options[5] = new Option("Bilbao (BIO)","BIO");index.options[6] = new Option("Bruselas (BRU)","BRU");index.options[7] = new Option("Gran Canaria (LPA)","LPA");index.options[8] = new Option("Granada (GRX)","GRX");index.options[9] = new Option("Ibiza (IBZ)","IBZ");index.options[10] = new Option("Jerez / Cádiz (XRY)","XRY");index.options[11] = new Option("Lisboa (LIS)","LIS");index.options[12] = new Option("Madrid (MAD)","MAD");index.options[13] = new Option("Málaga (AGP)","AGP");index.options[14] = new Option("Malta (Valleta) (MLA)","MLA");index.options[15] = new Option("Menorca (MAH)","MAH");index.options[16] = new Option("Milán (MXP)","MXP");index.options[17] = new Option("Nápoles (NAP)","NAP");index.options[18] = new Option("Niza (NCE)","NCE");index.options[19] = new Option("Palma de Mallorca (PMI)","PMI");index.options[20] = new Option("París (CDG)","CDG");index.options[21] = new Option("Roma (FCO)","FCO");index.options[22] = new Option("Santiago (SCQ)","SCQ");index.options[23] = new Option("Sevilla (SVQ)","SVQ");index.options[24] = new Option("Tenerife (TFN)","TFN");index.options[25] = new Option("Valencia (VLC)","VLC");index.options[26] = new Option("Venecia (VCE)","VCE");
		if (market == 1) {
			index = document.forms.skylightsForm.to1;
		} else {
			index = document.forms.skylightsForm.to2;
		}
index.options[1] = new Option("Alicante (ALC)","ALC");index.options[2] = new Option("Amsterdam (AMS)","AMS");index.options[3] = new Option("Atenas (ATH)","ATH");index.options[4] = new Option("Barcelona (BCN)","BCN");index.options[5] = new Option("Bilbao (BIO)","BIO");index.options[6] = new Option("Bruselas (BRU)","BRU");index.options[7] = new Option("Gran Canaria (LPA)","LPA");index.options[8] = new Option("Granada (GRX)","GRX");index.options[9] = new Option("Ibiza (IBZ)","IBZ");index.options[10] = new Option("Jerez / Cádiz (XRY)","XRY");index.options[11] = new Option("Lisboa (LIS)","LIS");index.options[12] = new Option("Madrid (MAD)","MAD");index.options[13] = new Option("Málaga (AGP)","AGP");index.options[14] = new Option("Malta (Valleta) (MLA)","MLA");index.options[15] = new Option("Menorca (MAH)","MAH");index.options[16] = new Option("Milán (MXP)","MXP");index.options[17] = new Option("Nápoles (NAP)","NAP");index.options[18] = new Option("Niza (NCE)","NCE");index.options[19] = new Option("Palma de Mallorca (PMI)","PMI");index.options[20] = new Option("París (CDG)","CDG");index.options[21] = new Option("Roma (FCO)","FCO");index.options[22] = new Option("Santiago (SCQ)","SCQ");index.options[23] = new Option("Sevilla (SVQ)","SVQ");index.options[24] = new Option("Tenerife (TFN)","TFN");index.options[25] = new Option("Valencia (VLC)","VLC");index.options[26] = new Option("Venecia (VCE)","VCE");
	}
	
}
function selectPaxXJS()
{

	var index;
index = document.forms.skylightsForm.ADULT;
		index.options[0] = new Option("1 Adulto","1");index.options[1] = new Option("2 Adultos","2");index.options[2] = new Option("3 Adultos","3");index.options[3] = new Option("4 Adultos","4");index.options[4] = new Option("5 Adultos","5");index.options[5] = new Option("6 Adultos","6");index.options[6] = new Option("7 Adultos","7");index.options[7] = new Option("8 Adultos","8");index.options[8] = new Option("9 Adultos","9");index.options[9] = new Option("10 Adultos","10");index.options[10] = new Option("11 Adultos","11");index.options[11] = new Option("12 Adultos","12");index.options[12] = new Option("13 Adultos","13");index.options[13] = new Option("14 Adultos","14");index.options[14] = new Option("15 Adultos","15");index.options[15] = new Option("16 Adultos","16");index.options[16] = new Option("17 Adultos","17");index.options[17] = new Option("18 Adultos","18");index.options[18] = new Option("19 Adultos","19");index.options[19] = new Option("20 Adultos","20");index.options[20] = new Option("21 Adultos","21");index.options[21] = new Option("22 Adultos","22");index.options[22] = new Option("23 Adultos","23");index.options[23] = new Option("24 Adultos","24");index.options[24] = new Option("25 Adultos","25");index.options[25] = new Option("> 25 Adultos","+25");index = document.forms.skylightsForm.CHILD;
		index.options[0] = new Option("0 Niños","0");index.options[1] = new Option("1 Niño","1");index.options[2] = new Option("2 Niños","2");index.options[3] = new Option("3 Niños","3");index.options[4] = new Option("4 Niños","4");index.options[5] = new Option("5 Niños","5");index.options[6] = new Option("6 Niños","6");index.options[7] = new Option("7 Niños","7");index.options[8] = new Option("8 Niños","8");index.options[9] = new Option("9 Niños","9");index.options[10] = new Option("10 Niños","10");index.options[11] = new Option("11 Niños","11");index.options[12] = new Option("12 Niños","12");index = document.forms.skylightsForm.INFANT;
		index.options[0] = new Option("0 Bebés","0");index.options[1] = new Option("1 Bebé","1");index.options[2] = new Option("2 Bebés","2");index.options[3] = new Option("3 Bebés","3");index.options[4] = new Option("4 Bebés","4");index.options[5] = new Option("5 Bebés","5");index.options[6] = new Option("6 Bebés","6");index.options[7] = new Option("7 Bebés","7");index.options[8] = new Option("8 Bebés","8");index.options[9] = new Option("9 Bebés","9");index.options[10] = new Option("10 Bebés","10");index.options[11] = new Option("11 Bebés","11");index.options[12] = new Option("12 Bebés","12");index.options[13] = new Option("13 Bebés","13");index.options[14] = new Option("14 Bebés","14");index.options[15] = new Option("15 Bebés","15");index.options[16] = new Option("16 Bebés","16");index.options[17] = new Option("17 Bebés","17");index.options[18] = new Option("18 Bebés","18");index.options[19] = new Option("19 Bebés","19");index.options[20] = new Option("20 Bebés","20");index.options[21] = new Option("21 Bebés","21");index.options[22] = new Option("22 Bebés","22");index.options[23] = new Option("23 Bebés","23");index.options[24] = new Option("24 Bebés","24");index.options[25] = new Option("25 Bebés","25");

}
function selectDatesXJS(market)
{

	var index1;
	var index2;
	if (market == 1) {
		index1 = document.forms.skylightsForm.departDay1;
		index2 = document.forms.skylightsForm.departMonth1;

	} else {
		index1 = document.forms.skylightsForm.departDay2;
		index2 = document.forms.skylightsForm.departMonth2;

	}
index1.options[1] = new Option("01","01");index1.options[2] = new Option("02","02");index1.options[3] = new Option("03","03");index1.options[4] = new Option("04","04");index1.options[5] = new Option("05","05");index1.options[6] = new Option("06","06");index1.options[7] = new Option("07","07");index1.options[8] = new Option("08","08");index1.options[9] = new Option("09","09");index1.options[10] = new Option("10","10");index1.options[11] = new Option("11","11");index1.options[12] = new Option("12","12");index1.options[13] = new Option("13","13");index1.options[14] = new Option("14","14");index1.options[15] = new Option("15","15");index1.options[16] = new Option("16","16");index1.options[17] = new Option("17","17");index1.options[18] = new Option("18","18");index1.options[19] = new Option("19","19");index1.options[20] = new Option("20","20");index1.options[21] = new Option("21","21");index1.options[22] = new Option("22","22");index1.options[23] = new Option("23","23");index1.options[24] = new Option("24","24");index1.options[25] = new Option("25","25");index1.options[26] = new Option("26","26");index1.options[27] = new Option("27","27");index1.options[28] = new Option("28","28");index1.options[29] = new Option("29","29");index1.options[30] = new Option("30","30");index1.options[31] = new Option("31","31");



	var currentDate = new Date();
	currentDate.setDate("01");
	var i;
	
	var month_selected_xjs;month_selected_xjs = currentDate.getFullYear + currentDate.getMonth();
	
	for(i = 0; i < 12; i++) {
		index2.options[i] = new Option(dateText.months[currentDate.getMonth()] + " " + currentDate.getFullYear(), currentDate.getFullYear() + "" + addZero(currentDate.getMonth() + 1));
		currentDate.setMonth(parseInt(currentDate.getMonth()) + 1);
	}


/*
index2.options[0] = new Option("Jul 2008","200807");
index2.options[1] = new Option("Ago 2008","200808");
index2.options[2] = new Option("Sep 2008","200809");
index2.options[3] = new Option("Oct 2008","200810");
index2.options[4] = new Option("Nov 2008","200811");
index2.options[5] = new Option("Dic 2008","200812");
index2.options[6] = new Option("Ene 2009","200901");
index2.options[7] = new Option("Feb 2009","200902");
index2.options[8] = new Option("Mar 2009","200903");	*/
	index1.value = day_xjs;
	index2.value = month_xjs;
	
	
	
	index1.selectedIndex = day_xjs;
	var i;
	var selectMonth;
	
	if(month_xjs.length == 5) {
		selectMonth = month_xjs.substring(0, 4) + "0" + month_xjs.substring(4, 5);
	} else {
		selectMonth = month_xjs;
	}
	
	for(i = 0; i < index2.options.length; i++) {
		if(index2.options[i].value == selectMonth) {
			index2.selectedIndex = i;
			return;
		}
	}
	
	index2.selectedIndex = 0;
}


	function addZero(number) {
		var zeroNumber;
		
		if(number < 10) {
			zeroNumber = "0" + number;	
		} else {
			zeroNumber = number;
		}
		//alert(number + "      " +zeroNumber);
		
		return zeroNumber;
	}


function fillSelectSearchXJS()
{

	selectCitiesXJS(1);
	selectCitiesXJS(2);
	getcookie_city();
	resetDest(1);
	resetDest(2);


	selectDatesXJS(1);
	selectDatesXJS(2);


	selectPaxXJS();

}

function fillSelectSearchXJShorarios(h_ori,h_dest)
{	//alert("h_ori"+h_ori);
	//alert("h_dest"+h_dest);

	selectCitiesXJS(1);
	selectCitiesXJS(2);
	//getcookie_city();
	if (h_ori!=""){
	document.getElementById("from1Select").value=h_ori;
	}
	resetDest(1);
	if (h_dest!=""){
	document.getElementById("to1Select").value=h_dest;
	}
	resetDest(2);
	


	selectDatesXJS(1);
	selectDatesXJS(2);


	selectPaxXJS();

}


function getcookie_city() {
	city=document.cookie.split('origen_ant=');
	if(city.length>1){
		ciudad=city[1].split("*!*");
		if(ciudad.length>0){
			if(ciudad[0].length>0){
				for (var i = 0; i < document.getElementById("from1Select").options.length; i++) {
					if(document.getElementById("from1Select").options[ i ].value==ciudad[0]) { 
						document.getElementById("from1Select").selectedIndex=i;
					}
				}
			}
		}
	}
}
//jsx

<!--
//////////////////////////////////////////////////////////////////////////////
//    Copyright(c) 2000 - 2006 Navitaire Inc.  All rights reserved.         //
//                                                                          //
//    This source code is protected by copyright law and international      //
//    treaties.  Unauthorized reproduction, distribution or alteration      //
//    of this source code, or any portion of it, may result in severe       //
//    civil and criminal penalties and will be prosecuted to the maximum    //
//    extent possible under the law.                                        //
//                                                                          //
//  Skylights 9.2a                                       www.navitaire.com  //
//////////////////////////////////////////////////////////////////////////////
-->
