function pInt( a ) {
	
	var b = parseInt(a);
	return ( isNaN(b) ? 0 : b );
	
}

var promoDest = {
	'elitDest': {
		GVA: ['FLR'],
		LUG: ['FLR']
	}
};


var promoDest = {
	'happyDest': {
		GVA: ['FLR','NCE','FCO','LUG','VCE'],
		LUG: ['FCO','GVA'],
		FCO: ['LUG','GVA','RMI'],
		FLR: ['GVA'],
		NCE: ['GVA'],
		LUG: ['FCO','GVA'],
		RMI: ['FCO'],
		VCE: ['GVA']
	}
};

var flightFinder = {
	
	cities: city_array,
	destinations: {},
	cityNames: {},
	selectGo: {},
	selectBack:{},
	select2Go: {},
	select2Back:{},
	messages: {
		fr: {
			nobody: 'Aucun passager sélectionné',
			nocity: 'Veuillez choisir vos villes de départ et/ou d\'arrivée',
			nodate: 'Veuillez choisir vos dates de départ ou de retour',
			accept: 'Merci d\'accepter les conditions de vente',
			bip: 'Vous allez être rediriger vers la page jeune',
			family: 'Envie d\'une escapade en famille\nAvec Darwin Airline les enfants ne paient que les taxes. ',
			group: 'Vous avez sélectionné plus de 9 passagers vous allez être redirigé vers la page demande de groupe',
			required: 'Merci de remplir tous les champs obligatoires'
		},
		de: {
			nobody: 'No passenger has been selected',
			nocity: 'Please select your city of departure and of arrival',
			nodate: 'Please select your departure or return dates',
			accept: 'Thank you for accepting sale\'s conditions',
			bip: 'Vous allez être rediriger vers la page jeune',
			family: 'Want to get away with the family\nBook with Darwin Airline and pay only the taxes for children',
			group: 'You have selected more than 9 passengers you will be redirected to the group request page',
			required: 'Please fill all the compulsory fields'
		},
		it: {
			nobody: 'Nessun passeggero e stato selezionato',
			nocity: 'Vi chiediamo di selezionare la vostra città di partenza e di arrivo',
			nodate: 'Vogliate scegliere le vostre date di partenza o di ritorno',
			accept: 'Grazie per accettare le condizioni di vendita',
			bip: 'Vous allez être rediriger vers la page jeune',
			family: 'Hai voglia di evasione per te e la tua famiglia\nCon Darwin Airline i bambini pagano solo le tasse',
			group: 'Avete selezionato piu di 9 passeggeri verrete indirizzati verso la pagina di richiesta gruppi',
			required: 'Vi chiediamo di riempire tutti i campi obbligatori'
		},
		en: {
			nobody: 'No passenger has been selected',
			nocity: 'Please select your city of departure and of arrival',
			nodate: 'Please select your departure or return dates',
			accept: 'Vous devez accepter les conditions de ventes',
			bip: 'Vous allez être rediriger vers la page jeune',
			family: 'Want to get away with the family\nBook with Darwin Airline and pay only the taxes for children',
			group: 'You have selected more than 9 passengers you will be redirected to the group request page',
			required: 'Please fill all the compulsory fields'
		}
	},
	lang: '',
	
	sabreParse: function () {
		
		for ( var i = 0; i < this.cities.length; i++ )
			this.destinations[this.cities[i]] = dest_array[i].split(',').sort();
		
	},
	
	city18n: function () {
		
		var cityNames = {};
		
		if ( document.location.pathname.match(/^\/fr\//) ) {
			
			this.lang = 'fr';
			cityNames = {
				0:' Choisissez une ville',
				'BIQ':'Biarritz',
				'CAG':'Cagliari',
				'CRV':'Crotone',
				'FLR':'Florence',
				'GVA':'Gen&egrave;ve',
				'LUG':'Lugano',
				'LUX':'Luxembourg',
				'PNL':'Pantelleria',
				'RMI':'Rimini',
				'FCO':'Rome Fiumicino',
				'VLC':'Valence (esp)',
				'IBZ':'Ibiza',
				'OLB':'Olbia',
				'LTT':'St-Tropez',
				'VCE':'Venise',
				'NCE':'Nice',
				'GOA':'Gènes',
				'ZRH':'Zurich'

			};
					
		} else if ( document.location.pathname.match(/^\/it\//) ) {
			
			this.lang = 'it';
			cityNames = {
				0:' Scegliete una città',
	            'BIQ':'Biarritz',
				'CAG':'Cagliari',
				'CRV':'Crotone',
				'FLR':'Firenze',
				'GVA':'Ginevra',
				'LUG':'Lugano',
				'NCE':'Nizza',
				'LUX':'Lussemburgo',
				'PNL':'Pantelleria',
				'FCO':'Roma Fiumicino',
				'VCE':'Venezia',
				'VLC':'Valencia',
				'OLB':'Olbia',
				'LTT':'St-Tropez',
				'IBZ':'Ibiza',
				'RMI':'Rimini',
				'GOA':'Genoa',
				'ZRH':'Zurigo'
			};
			
		} else if ( document.location.pathname.match(/^\/de\//) ) {
			
			this.lang = 'de';
			cityNames = {
				0:' Choose a city',
				'BIQ':'Biarritz',
				'BOD':'Bordeaux',
				'OTP':'Bukarest',
				'FLR':'Florenz',
				'GVA':'Genf',
				'LUG':'Lugano',
				'IBZ':'Ibiza',
				'NAP':'Neapel',
				'NCE':'Nizza',
				'FCO':'Roma Fiumicino',
				'TLS':'Toulouse',
				'VCE':'Venedig',
				'ZRH':'Zurich'
			};
			
		} else { // English Language 
			
			this.lang = 'en';
			cityNames = {
				0:' Choose a city',
				'BIQ':'Biarritz',
				'CAG':'Cagliari',
				'CRV':'Crotone',
				'FLR':'Florence',
				'GVA':'Geneva',
				'LUG':'Lugano',
				'LUX':'Luxembourg',
				'PNL':'Pantelleria',
				'FCO':'Rome Fiumicino',
				'NCE':'Nice',
				'IBZ':'Ibiza',
				'OLB':'Olbia',
				'VCE':'Venice',
				'VLC':'Valencia',
				'LTT':'St-Tropez',
				'RMI':'Rimini',
				'GOA':'Genoa',
				'ZRH':'Zurich'
			};
			
		}
		
		this.cityNames = cityNames;
		
	},
	
	
	
	happyCities: function (elem) {
		
		var a = this.cityNames;
		var option;
		elem.innerHTML = '';
		var opts = {};
		var cities = [];
		
		
		for ( var i in a ) {
			
			if ( i == 0 || this.destinations[i] ) {
				option = document.createElement('option');
				option.value = i;
				option.innerHTML = this.cityNames[i] + ( i == 0 ? '' : ' (' + i + ')' );
				
				opts[this.cityNames[i]] = option;
				cities[cities.length] = this.cityNames[i];
			
			}
		
		}
		
		cities = cities.sort();
		for ( var j = 0; j < cities.length; j++ ) {
			
			elem.appendChild(opts[cities[j]]);
			
		}
		
	},
	
		
	popCities: function (elem) {
		
		var a = this.cityNames;
		var option;
		var opts = {};
		var cities = [];
		elem.innerHTML = '';
		
		
		for ( var i in a ) {
			
			option = document.createElement('option');
			option.value = i;
			option.innerHTML = this.cityNames[i] + ( i == 0 ? '' : ' (' + i + ')' );
			
			opts[this.cityNames[i]] = option;
			cities[cities.length] = this.cityNames[i];
			
		}
		
		cities = cities.sort();
		for ( var j = 0; j < cities.length; j++ ) {
			
			elem.appendChild(opts[cities[j]]);
			
		}
		
		
		
	},
	
	updateDest: function (elem, val, match) {
		
		var a = this.destinations[val];
		var option;
		var opts = {};
		var cities = [];
		elem.innerHTML = '';
		if ( !a ) return;
		
		option = document.createElement('option');
		option.value = '0';
		option.innerHTML = this.cityNames[0] ;
		elem.appendChild(option);
		
		for ( var i = 0; i < a.length; i++ ) {
			
			option = document.createElement('option');
			option.value = a[i];
			option.innerHTML = this.cityNames[a[i]] + ( a[i] == 'default' ? '' : ' (' + a[i] + ')' );
			if ( match == a[i] )
				$(option).attr('selected', 'selected');
			opts[this.cityNames[a[i]]] = option;
			cities[cities.length] = this.cityNames[a[i]];
			
		}
		
		cities = cities.sort();
		for ( var j = 0; j < cities.length; j++ ) {
			
			elem.appendChild(opts[cities[j]]);
			
		}
		
		
	},
	
	
	young: function (event) {
		
		if ( $(document.body).hasClass('happy') )
			return false;
		
		if (
			pInt($('#flightfinder select[name="numAdults"]').val()) == 0 &&
			pInt($('#flightfinder select[name="ADT2"]').val()) > 0 &&
			pInt($('#flightfinder select[name="numChildren"]').val()) == 0 &&
			pInt($('#flightfinder select[name="numInfants"]').val()) == 0 &&
			$('#returnTravel').attr('checked') &&
			!$(document.body).hasClass('bip')
		) {
			
			this.storeForm(document.getElementById('flightfinder'));
			document.location = '/' + this.lang + '/bip.html';
			return true;
			
		}
		
	},
	
	
	family: function (event) {
		
		if ( $(document.body).hasClass('happy') )
			return false;
		
		if (
			pInt($('#flightfinder select.adults').val()) > 0 &&
			pInt($('#flightfinder select.adults').val()) < 3 &&
			pInt($('#flightfinder select[name="ADT2"]').val()) == 0 &&
			pInt($('#flightfinder select.children').val()) > 0 &&
			pInt($('#flightfinder select.children').val()) < 5 &&
			!$(document.body).hasClass('family') &&
			$('#returnTravel').attr('checked') &&
			confirm(this.messages[this.lang]['family'])
		) {
			
			this.storeForm(document.getElementById('flightfinder'));
			document.location = '/' + this.lang + '/family.html';
			return true;
			
		}
		
	},
	
	
	group: function (event) {
		
		if ( $(document.body).hasClass('happy') )
			return false;
		if ( 
			pInt($('#flightfinder select.adults').val()) +
			pInt($('#flightfinder select.youth').val()) +
			pInt($('#flightfinder select.children').val()) +
			pInt($('#flightfinder select.infants').val()) > 9 &&
			confirm(this.messages[this.lang]['group'])
		) {
			document.location = '/' + this.lang + '/group_booking.html';
			return true;
			
		}
	},
	
	
	nobody: function (event) {
		
		if ( 
			!(pInt($('#flightfinder select.adults').val()) > 0 ) &&
			!(pInt($('#flightfinder select.infants').val()) > 0 ) &&
			!(pInt($('#flightfinder select.youth').val()) > 0 ) &&
			!(pInt($('#flightfinder select.children').val()) > 0 ) 
		) {
			
			alert(this.messages[this.lang]['nobody']);
			return true;
			
		}
	},
	
	
	nodate: function (event) {
		
		if ( $('#flightfinder input[name="depDay"]').val() == '0' ||
			( $('#returnTravel').attr('checked') && $('#flightfinder input[name="retDay"]').val() == '0' )  ) {
			
			alert(this.messages[this.lang]['nodate']);
			return true;
			
		}
		
	},
	
	
	nocity: function (event) {
		
		if ( 
			( $('#flightfinder select.go.city').val() == 0 ) || ( $('#flightfinder select.go.city').val() == 0 ) ||
			!$('#flightfinder select.back.city').val() || $('#flightfinder select.back.city').val() == 0
		) {
			
			alert(this.messages[this.lang]['nocity']);
			event.preventDefault();
			return true;
			
		}
		
	},
	
	acceptCheck: function (event) {
		
		if ( $(document.body).hasClass('family') || $(document.body).hasClass('bip') )
			if ( !$('#acceptance').attr('checked') ) {
				alert(this.messages[this.lang]['accept'])
				event.preventDefault();
				return true;
			}
		
	},
	
	
	storeForm: function (form) {
		
		var tags = form.getElementsByTagName('*');
		
		for ( var i = 0; i < tags.length; i++ ) {
			
			if ( $(tags[i]).hasClass('pipe') )
				Cookie.set(tags[i].name, $(tags[i]).val());
			/*
			else if ( tags[i].name == 'origin' )
				Cookie.set(tags[i].name, $(tags[i]).val());
			
			else if ( tags[i].name == 'destination' )
				Cookie.set(tags[i].name, $(tags[i]).val());
			*/
		}
		
	},
	
	setDest: function (start, end) {
		
		$('#flightfinder').addClass('highlight');
		$(this.selectGo).val(start);
		this.updateDest(this.selectBack, this.selectGo.value, end);
		
		setTimeout(function () {
			$('#flightfinder').removeClass('highlight');
		}, 400);
	},
	
	init: function () {
		
		/**/
		
		if ( !document.getElementById('flightfinder') )
			return;
		
		document.getElementById('flightfinder').reset();
		
		this.city18n();
		var sels = document.getElementById('flightfinder').getElementsByTagName('select');
		for ( var i = 0; i < sels.length; i++ ) {
			
			if ( $(sels[i]).hasClass('go city') )
				this.selectGo = sels[i];
			
			else if ( $(sels[i]).hasClass('back city') )
				this.selectBack = sels[i];
			
		}
		
		
		
		if ( $('#flightfinder').hasClass('happy') ) {
			
			this.destinations = promoDest.happyDest;
			
		} else if ( $('#flightfinder').hasClass('promo') ) {
			
			this.destinations = promoDest[$('#flightfinder').attr('name')];
			
		} else {
			
			this.sabreParse();
			
		}
		
		this.happyCities(this.selectGo);
		
		
		$(this.selectGo).change(function () {
			flightFinder.updateDest(flightFinder.selectBack, this.value);
		});
				
		
		
		
		/*******************/
		/* Abo From */
		
		/*******************/
		
if ( document.getElementById('abo_form') ) {
			
			
			
			
			
			$('#abo_form').submit(function (event) {
				
				var sels = document.getElementById('abo_form').getElementsByTagName('*');
				for ( var i = 0; i < sels.length; i++ ) {
					
					if ( $(sels[i]).hasClass('required') && !$(sels[i]).val() ) {
						
						
						error = true;
						$(sels[i]).addClass('error');
						$(sels[i]).focus(function () {
							
							$(this).removeClass('error');
							
						});
						
					}
					
				}
				
				if ( error ) {
					
					event.preventDefault();
					alert(flightFinder.messages[flightFinder.lang]['required']);
					error = false;
					
				}
				
			});
			
		}
		
		
		
		/*******************/
		/* Group Finder */
		
		/*******************/
		

		if ( document.getElementById('groupflight') ) {
			
			var sels = document.getElementById('groupflight').getElementsByTagName('select');
			for ( var i = 0; i < sels.length; i++ ) {
				
				if ( $(sels[i]).hasClass('go city') )
					this.select2Go = sels[i];
				
				else if ( $(sels[i]).hasClass('back city') )
					this.select2Back = sels[i];
				
			}
			
			this.popCities(this.select2Go);
			
			$(this.select2Go).change(function () {
				flightFinder.updateDest(flightFinder.select2Back, this.value);
			});
			
			$('#groupflight').submit(function (event) {
				
				var sels = document.getElementById('groupflight').getElementsByTagName('*');
				for ( var i = 0; i < sels.length; i++ ) {
					
					if ( $(sels[i]).hasClass('required') && !$(sels[i]).val() ) {
						
						
						error = true;
						$(sels[i]).addClass('error');
						$(sels[i]).focus(function () {
							
							$(this).removeClass('error');
							
						});
						
					}
					
				}
				
				if ( error ) {
					
					event.preventDefault();
					alert(flightFinder.messages[flightFinder.lang]['required']);
					error = false;
					
				}
				
			});
			
		}
		
		
		if ( $('#flightfinder').hasClass('happy') )
			BabooDatePicker.init(new Date($('#startOffer').val()), new Date($('#endOffer').val()) );
		
		else BabooDatePicker.init();
		
		var today = new Date();
		var formatted = today.getFullYear() + '-' + ( today.getMonth() + 1 ) + '-' + today.getDate();
		
		var dt = $("#flightfinder input[name='departure_date']").datepicker('getDate');
		var du = $("#flightfinder input[name='return_date']").datepicker('getDate');
		
		$('#flightfinder input[name="departureDate"]').val(formatted);
		$('#flightfinder input[name="returnDate"]').val(formatted);
		
		$('#flightfinder input[name="depDay"]').val(dt.getDate());
		$('#flightfinder input[name="depMonth"]').val(BabooDatePicker.months.en[dt.getMonth()].toUpperCase());
		$('#flightfinder input[name="retDay"]').val(du.getDate());
		$('#flightfinder input[name="retMonth"]').val(BabooDatePicker.months.en[du.getMonth()].toUpperCase());
		
		
		
		$('#flightfinder').submit(function (event) {
			
			if (
				flightFinder.nocity(event) ||
				flightFinder.nobody(event) ||
				flightFinder.nodate(event) ||
				flightFinder.acceptCheck(event) ||
				flightFinder.young(event) ||
				flightFinder.family(event) ||
				flightFinder.group(event)
			) {
				event.preventDefault();
				return false;
			}
			
			
			if ( !$(document.body).hasClass('family') && !$(document.body).hasClass('bip') ) {
				$('#flightfinder select[name="numAdults"]').val(
					pInt($('#flightfinder select[name="ADT2"]').val()) +
					pInt($('#flightfinder select[name="numAdults"]').val())
				);
				$('#flightfinder select[name="ADT2"]').val(0);
			}
			
			function trav () {
				
				if ( $('#flightfinder').hasClass('bip') || $('#flightfinder').hasClass('family') )
					return true;
				
				return $('#flightfinder input.direction').attr('checked');
				
			}
			
			$.ajax({
				'async': false,
				'type': 'post',
				'url': '/en/stats.php', 
				'data': {
					'origin': $('#flightfinder select.go.city').val(),
					'destination': $('#flightfinder select.back.city').val(),
					'depDate': $("#flightfinder input.go.datepicker").val(),
					'retDate': $("#flightfinder input.back.datepicker").val(),
					'travel': trav(),
					'passengers': pInt($('#flightfinder select.adults').val()) +
								pInt($('#flightfinder select.children').val()) +
								pInt($('#flightfinder select.infants').val())
			}});
					
										
					
		var depart =$('#flightfinder input[name="departureDate"]').val();
			
		var elem = depart.split('-'); 
		annee = elem[0]; 
		mois = elem[1]; 
		jour = elem[2]; 
		
		 var cmp_date = annee+mois+jour
		 		 if (jour < 10) cmp_date = annee + mois + "0" + jour;

				 
				 
	if ($('#flightfinder select[name="origin"]').val() == 'GVA' && $('#flightfinder select[name="destination"]').val() == 'LTT' && cmp_date <=2012602
	) 
 {	
				
	alert('The St-Tropez destination is available only from the 3th June\n\nLa destination de St-Tropez est disponible seulement \340 partir du 3 juin\n\nLa destinazione di St-Tropez \350 disponibile solo a partire dal 3 Giugno\n','INFORMATION'); 	
			return false;
			}	
			
			if ($('#flightfinder select[name="origin"]').val() == 'LUG' && $('#flightfinder select[name="destination"]').val() == 'PNL' && cmp_date <=2012615
	) 
 {	
				
	alert('The Pantelleria destination is available only from the 16th June\n\nLa destination de Pantelleria est disponible seulement \340 partir du 16 juin\n\nLa destinazione di Pantelleria \350 disponibile solo a partire dal 16 Giugno\n','INFORMATION'); 	
			return false;
			}	


if ($('#flightfinder select[name="origin"]').val() == 'GVA' && $('#flightfinder select[name="destination"]').val() == 'BIQ' && cmp_date <=2012607
		) 
 {	
				
	alert('The Biarritz destination is available only from the 8th June\n\nLa destination de Biarritz est disponible seulement \340 partir du 8 juin\n\nLa destinazione di Biarritz \350 disponibile solo a partire dal 8 Giugno\n','INFORMATION'); 	
			return false;
			}				
		
			if ($('#flightfinder select[name="origin"]').val() == 'GVA' && $('#flightfinder select[name="destination"]').val() == 'VLC' && cmp_date <=2012330
		) 
 {	
				
	alert('The Valencia destination is available only from the 31st March\n\nLa destination de Valence (esp) est disponible seulement \340 partir du 31 mars\n\nLa destinazione di Valencia \350 disponibile solo a partire dal 31 Marzo\n','INFORMATION'); 	
			return false;
			}	
			
			if ($('#flightfinder select[name="origin"]').val() == 'GVA' && $('#flightfinder select[name="destination"]').val() == 'IBZ' && cmp_date <=2012602
		) 
 {	
				
	alert('The Ibiza destination is available only from the 3th June\n\nLa destination de Ibiza est disponible seulement \340 partir du 3 juin\n\nLa destinazione di Ibiza \350 disponibile solo a partire dal 3 Giugno\n','INFORMATION'); 	
			return false;
			}	
			
			if ($('#flightfinder select[name="origin"]').val() == 'LUG' && $('#flightfinder select[name="destination"]').val() == 'CRV' && cmp_date <=2012728
		) 
 {	
				
	alert('The Crotone destination is available only from the 29th July\n\nLa destination de Crotone est disponible seulement \340 partir du 29 juillet\n\nLa destinazione di Crotone \350 disponibile solo a partire dal 29 luglio\n','INFORMATION'); 	
			return false;
			}	
			
			if ($('#flightfinder select[name="origin"]').val() == 'LUG' && $('#flightfinder select[name="destination"]').val() == 'CAG' && cmp_date <=2012431
		) 
 {	
				
	alert('The Cagliari destination is available only from the 1 st June\n\nLa destination Cagliari  est disponible seulement \340 partir du 1er juin\n\nLa destinazione di Cagliari \350 disponibile solo a partire dal 1 Giugno\n','INFORMATION'); 	
			return false;
			}	
			if ($('#flightfinder select[name="origin"]').val() == 'LUG' && $('#flightfinder select[name="destination"]').val() == 'OLB' && cmp_date <=2012431
		) 
 {	
				
	alert('The Olbia destination is available only from the 1st June\n\nLa destination de Olbia est disponible seulement \340 partir du 1er juin\n\nLa destinazione di Olbia \350 disponibile solo a partire dal 1 Giugno\n','INFORMATION'); 	
			return false;
			}	
			
			
			if ($('#flightfinder select[name="origin"]').val() == 'GVA' && $('#flightfinder select[name="destination"]').val() == 'GOA' && cmp_date <=2012129
		) {			
			alert('The Genoa destination is available only from the 30th January\n\nLa destination de Génes est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Genoa \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
			
			if ($('#flightfinder select[name="origin"]').val() == 'GVA' && $('#flightfinder select[name="destination"]').val() == 'LUX' && cmp_date <=2012129
		) {			
			alert('The Luxembourg destination is available only from the 30th January\n\nLa destination de Luxembourg est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Lussemburgo \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
				
			if ($('#flightfinder select[name="origin"]').val() == 'LUG' && $('#flightfinder select[name="destination"]').val() == 'LUX' && cmp_date <=2012129
		) {			
			alert('The Luxembourg destination is available only from the 30th January\n\nLa destination de Luxembourg est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Lussemburgo \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
					
			if ($('#flightfinder select[name="origin"]').val() == 'LUX' && $('#flightfinder select[name="destination"]').val() == 'GVA' && cmp_date <=2012129
		) {			
			alert('The Luxembourg destination is available only from the 30th January\n\nLa destination de Luxembourg est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Lussemburgo \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
			
			if ($('#flightfinder select[name="origin"]').val() == 'LUX' && $('#flightfinder select[name="destination"]').val() == 'LUG' && cmp_date <=2012129
		) {			
			alert('The Luxembourg destination is available only from the 30th January\n\nLa destination de Luxembourg est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Lussemburgo \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
									
			if ($('#flightfinder select[name="origin"]').val() == 'ZRH' && $('#flightfinder select[name="destination"]').val() == 'GOA' && cmp_date <=2012129
		) {			
			alert('The Genoa destination is available only from the 30th January\n\nLa destination de Génes est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Genoa \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
			
			if ($('#flightfinder select[name="origin"]').val() == 'GOA' && $('#flightfinder select[name="destination"]').val() == 'GVA' && cmp_date <=2012129
		) {			
			alert('The Genoa destination is available only from the 30th January\n\nLa destination de Génes est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Genoa \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;
			}
			
			if ($('#flightfinder select[name="origin"]').val() == 'GOA' && $('#flightfinder select[name="destination"]').val() == 'ZRH' && cmp_date <=2012129
		) {			
			alert('The Zurich destination is available only from the 30th January\n\nLa destination de Zurich est disponible seulement \340 partir du 30 Janvier\n\nLa destinazione di Zurigo \350 disponibile solo a partire dal 30 Gennaio\n','INFORMATION'); 
			return false;


			}
		
/*
if ($('#flightfinder input[name="promoCode"]').length && $('#flightfinder input[name="promoCode"]').val().length ) {			
			confirm('In case of problem, please contact our call center +41 (0) 848 177 177 to acess to your promo code\n\nEn cas de probl\350mes, veuillez contacter notre call center +41 (0) 848 177 177 pour acc\351der \340 votre promo code\n\nIn caso di problemi, siete pregati di contattare il nostro call center +41 (0) 848 177 177 per accedere al vostro promo code'); 			
			}*/
			
										
if ( /*	( $('#flightfinder input[name="promoCode"]').length && $('#flightfinder input[name="promoCode"]').val().length ) || 
$('#flightfinder input[name="promoCode"]').val() == 'SIH09' ||*/
$('#flightfinder select[name="origin"]').val() == 'GVA' &&
$('#flightfinder select[name="destination"]').val() == 'RMI' ||
$('#flightfinder select[name="origin"]').val() == 'RMI' &&
$('#flightfinder select[name="destination"]').val() == 'GVA' ||
$('#flightfinder select[name="origin"]').val() == 'LUG' &&
$('#flightfinder select[name="destination"]').val() == 'FLR' ||
$('#flightfinder select[name="origin"]').val() == 'FLR' &&
$('#flightfinder select[name="destination"]').val() == 'LUG' ||
$('#flightfinder select[name="origin"]').val() == 'LUG' &&
$('#flightfinder select[name="destination"]').val() == 'VCE' ||
$('#flightfinder select[name="origin"]').val() == 'VCE' &&
$('#flightfinder select[name="destination"]').val() == 'LUG' ||
$('#flightfinder select[name="origin"]').val() == 'NCE' &&
$('#flightfinder select[name="destination"]').val() == 'FCO' ||
$('#flightfinder select[name="origin"]').val() == 'FCO' &&
$('#flightfinder select[name="destination"]').val() == 'NCE' ||
$('#flightfinder select[name="origin"]').val() == 'LUG' &&
$('#flightfinder select[name="destination"]').val() == 'OLB' ||
$('#flightfinder select[name="origin"]').val() == 'OLB' &&
$('#flightfinder select[name="destination"]').val() == 'LUG' ||
$('#flightfinder select[name="origin"]').val() == 'LUG' &&
$('#flightfinder select[name="destination"]').val() == 'CAG' ||
$('#flightfinder select[name="origin"]').val() == 'CAG' &&
$('#flightfinder select[name="destination"]').val() == 'LUG' ||
$('#flightfinder select[name="origin"]').val() == 'LUG' &&
$('#flightfinder select[name="destination"]').val() == 'CRV' ||
$('#flightfinder select[name="origin"]').val() == 'CRV' &&
$('#flightfinder select[name="destination"]').val() == 'LUG' ||

$('#flightfinder select[name="origin"]').val() == 'LUG' &&
$('#flightfinder select[name="destination"]').val() == 'PNL' ||
$('#flightfinder select[name="origin"]').val() == 'PNL' &&
$('#flightfinder select[name="destination"]').val() == 'LUG' ||



( $('#flightfinder input[name="corpId"]').length && $('#flightfinder input[name="corpId"]').val().length ) || ( $.browser.msie && $.browser.version == "6.0" ) ) {				
				
				document.getElementById('flightfinder').action = 'https://cat.sabresonicweb.com/meridia';
				
				$('#flightfinder').append('<input type="hidden" name="action" value="airRequest" />');
				$('#flightfinder input[name="promoCode"]').attr('name', 'corpID');
				$('#flightfinder select[name="origin"]').attr('name', 'departCity');
				$('#flightfinder select[name="destination"]').attr('name', 'returnCity');
				$('#flightfinder input[name="journeySpan"]').attr('name', 'direction');
				$('#flightfinder input[value=RT]').attr('value', 'returntravel');
				$('#flightfinder input[value=OW]').attr('value', 'onewaytravel');
				$('#flightfinder select[name="numAdults"]').attr('name', 'ADT');
				$('#flightfinder select[name="numChildren"]').attr('name', 'CHD');
				$('#flightfinder select[name="numInfants"]').attr('name', 'INF');
			
			}			
		});
		
		
		/* PIPE */
		
		if ( $(document.body).hasClass('bip') || $(document.body).hasClass('family') ) {
			
			var tags = document.getElementById('flightfinder').getElementsByTagName('*');
			for ( var i = 0; i < tags.length; i++ ) {
				
				
				if ( tags[i].name == 'departCity' ) {
					
					if ( !Cookie.get('origin') || Cookie.get('origin') == 'null' )
						$(tags[i]).val('0');
					
					else $(tags[i]).val(Cookie.get('origin'));
					
					this.updateDest(this.selectBack, this.selectGo.value);
					Cookie.remove('origin');
					
				} else if ( tags[i].name == 'returnCity' ) {
					
					$(tags[i]).val(Cookie.get('destination'));
					Cookie.remove('destination');
					
				} else if ( $(tags[i]).hasClass('pipe') && Cookie.get(tags[i].id) && Cookie.get(tags[i].name) != 'null' ) {
					
					$(tags[i]).val(Cookie.get(tags[i].id));
					Cookie.remove(tags[i].id);
					
				} else if ( $(tags[i]).hasClass('pipe') && Cookie.get(tags[i].name) && Cookie.get(tags[i].name) != 'null' ) {
					
					$(tags[i]).val(Cookie.get(tags[i].name));
					Cookie.remove(tags[i].name);					
				}
				
			}
			
					} else {
			
			/**/
			
			$('#flightfinder input[name="journeySpan"]').change(function () {
				
				if ( $(this).val() == 'OW' ) {
					
					$('#reto').css({display: 'none'});
					$('#flightfinder input[name="returnDate"]').attr('name', 'rD');
					
				} else {
					
					$('#flightfinder input[name="rD"]').attr('name', 'returnDate');
					$('#reto').css({display: 'block'});
					
				}
			});
			
			/**/
		}
		
		/**/
	}
	
};
