/**********************************************************
** (C) Copyright CNI
** DESCRIPTION : Javacript Regroupant les fonctions 
** principales
**********************************************************/

//--- FONCTION PUB
sas_tmstp=Math.round(Math.random()*10000000000);sas_masterflag=1;
function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
	if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else {sas_master='S';};
	document.write('<SCR'+'IPT SRC="http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');
}
//---

//--- FONCTION QUI PERMET DE REMPLACER DU TEXTE EN JAVASCRIPT
function str_replace(searchWord,replaceWord,chaine) {
	
	var recommence = 1;
	
	while (recommence==1) {
		if(chaine.search(searchWord)==-1) {
			recommence=0;
		} else {
			chaine = chaine.replace(searchWord,replaceWord);
		}
	}
	return chaine;
}
//---

//--- FONCTION QUI PERMET DE TRAITER LES CHAINES
String.prototype.toUcFirst = function () {
   var firstLetter = this.substr(0,1).toUpperCase()
   return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}
String.prototype.toUcWords = function(){
     return this.toLowerCase().replace(/\w+/g,function(s){
          return s.charAt(0).toUpperCase() + s.substr(1);
     })
}
//---

//--- FONCTION QUI PERMET DE REMPLACER DU TEXTE EN JAVASCRIPT
function AffichDiv(nomDiv) {
	
	if(document.getElementById(nomDiv).style.display=='none'){
		document.getElementById(nomDiv).style.display='';
	}else{
		document.getElementById(nomDiv).style.display='none';
	}
}
//---

//--- FONCTION QUI PERMET DE REMPLACER DU TEXTE EN JAVASCRIPT
function VerifBlackListe() {
	
	var compagnie = document.getElementById('TextBlackListe').value;
	
	if(compagnie.length > 1){
		AppelAjaxLNoire('/ajax/LNoire.php?compagnie='+compagnie);
	}else{
		alert('Merci de remplir le champ !');
	}
}
//---


//--- FONCTION D'APPEL D'UNE PAGE EN AJAX QUI CHARGE LE MOTEUR
function AppelAjaxLNoire(url){
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourLNoire(http_request); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourLNoire(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			alert(http_request.responseText);
		}
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LES AUTRES PROMOS EN PAGE D'ACCUEIL
function AffichListePromos(liste) {
	
	if(document.getElementById('ListePromos_'+liste).style.display=='none'){
		document.getElementById('ListePromos_'+liste).style.display='';
		document.getElementById('BoutonPlus'+liste).innerHTML='<a href="javascript:AffichListePromos('+liste+');"><b>- de promos</b></a>';
	}else{
		document.getElementById('ListePromos_'+liste).style.display='none';
		document.getElementById('BoutonPlus'+liste).innerHTML='<a href="javascript:AffichListePromos('+liste+');"><b>+ de promos</b></a>';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LES MAPS DE LOCALISATION DE VILLE
function AffichLocaliseVille(id) {
	
	if(document.getElementById('contenant_mapLoc_'+id).style.display=='none'){
		for(i=0; i<3; i++){
			if(i!=id){
				document.getElementById('contenant_mapLoc_'+i).style.display='none';
			}
		}
		document.getElementById('contenant_mapLoc_'+id).style.display='';
	}else{
		document.getElementById('contenant_mapLoc_'+id).style.display='none';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LA MAP DE LOCALISATION DU PAYS
function AffichLocalisePays(id) {
	
	if(document.getElementById('contenant_mapLoc_0').style.display=='none'){
		document.getElementById('contenant_mapLoc_0').style.display='';
	}else{
		document.getElementById('contenant_mapLoc_0').style.display='none';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LES TOP 5
function AffichTop5(id) {
	if(id == 0){
		if(document.getElementById('Top5Dest_2').style.display=='none'){
			document.getElementById('Top5Dest_2').style.display='';
			document.getElementById('BoutonPlusDestination').innerHTML='<span class="texteGrisFonce_12"><a href="javascript:AffichTop5(0);" title="Moins de villes de destination"><img src="/img/site/moins.png" class="abs" alt="Plus" width="16" height="16" border="0" /> <b>Moins de villes de destination</b></a></span>';
		}else{
			document.getElementById('Top5Dest_2').style.display='none';
			document.getElementById('BoutonPlusDestination').innerHTML='<span class="texteGrisFonce_12"><a href="javascript:AffichTop5(0);" title="Autres villes de destination"><img src="/img/site/plus.png" class="abs" alt="Plus" width="16" height="16" border="0" /> <b>Autres villes de destination</b></a></span>';
		}
	}else if(id == 1){
		if(document.getElementById('Top5Depart_2').style.display=='none'){
			document.getElementById('Top5Depart_2').style.display='';
			document.getElementById('BoutonPlusDepart').innerHTML='<span class="texteGrisFonce_12"><a href="javascript:AffichTop5(1);" title="Moins de villes de départ"><img src="/img/site/moins.png" class="abs" alt="Plus" width="16" height="16" border="0" /> <b>Moins de villes de départ</b></a></span>';
		}else{
			document.getElementById('Top5Depart_2').style.display='none';
			document.getElementById('BoutonPlusDepart').innerHTML='<span class="texteGrisFonce_12"><a href="javascript:AffichTop5(1);" title="Autres villes de départ"><img src="/img/site/plus.png" class="abs" alt="Plus" width="16" height="16" border="0" /> <b>Autres villes de départ</b></a></span>';
		}
	}
}
//---



//--- FONCTION QUI PERMET D'AFFICHER LES GRAPHIQUES D'EVOLUTION  DES VILLE
function AffichGraphVille(id, nb) {
	
	if(document.getElementById('ListeEvolutions_'+id).style.display=='none'){
		for(i=0; i<nb; i++){
			if(i!=id){
				document.getElementById('ListeEvolutions_'+i).style.display='none';
				document.getElementById('ListeEvolution_'+i).className='ListeOff';
			}
		}
		document.getElementById('ListeEvolution_'+id).className='ListeOn';
		document.getElementById('ListeEvolutions_'+id).style.display='';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LES GRAPHIQUES D'EVOLUTION  DES COMPAGNIES
function AffichGraphComp(id, nb) {
	
	if(document.getElementById('ListeEvolutions_'+id).style.display=='none'){
		for(i=0; i<nb; i++){
			if(i!=id){
				document.getElementById('ListeEvolutions_'+i).style.display='none';
				document.getElementById('ListeEvolution_'+i).className='ListeOff_2';
			}
		}
		document.getElementById('ListeEvolution_'+id).className='ListeOn_2';
		document.getElementById('ListeEvolutions_'+id).style.display='';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LA LISTE DES COMPAGNIES PAGES APRES PAGES
function AffichListeComp(id, page, nbPage) {
	
	for(i=1; i<=nbPage; i++){
		if(i==page){
			document.getElementById('liste_page_vol_'+id+'_'+i).style.display='';
		}else{
			document.getElementById('liste_page_vol_'+id+'_'+i).style.display='none';
		}
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LA LISTE DES PROMOS PAGES APRES PAGES
function AffichListePagePromos(page, nbPage) {
	
	for(i=1; i<=nbPage; i++){
		if(i==page){
			document.getElementById('liste_page_promo_'+i).style.display='';
			document.getElementById('page_'+i).className ='PageOn';
			document.getElementById('page_'+i+'_2').className ='PageOn';
		}else{
			document.getElementById('liste_page_promo_'+i).style.display='none';
			document.getElementById('page_'+i).className ='';
			document.getElementById('page_'+i+'_2').className ='';
		}
	}
	if (page==1){
		document.getElementById('page_prec').style.display ='none';
		document.getElementById('page_prec').href='javascript:AffichListePagePromos(0, '+nbPage+');';
		document.getElementById('page_prec_2').style.display ='none';
		document.getElementById('page_prec_2').href='javascript:AffichListePagePromos(0, '+nbPage+');';
	} else {
		document.getElementById('page_prec').style.display ='inline';
		document.getElementById('page_prec').href='javascript:AffichListePagePromos('+(page-1)+', '+nbPage+');';
		document.getElementById('page_prec_2').style.display ='inline';
		document.getElementById('page_prec_2').href='javascript:AffichListePagePromos('+(page-1)+', '+nbPage+');';
	}
	if (page==nbPage){
		document.getElementById('page_suiv').style.display ='none';
		document.getElementById('page_suiv').href='javascript:AffichListePagePromos('+nbPage+', '+nbPage+');';
		document.getElementById('page_suiv_2').style.display ='none';
		document.getElementById('page_suiv_2').href='javascript:AffichListePagePromos('+nbPage+', '+nbPage+');';
	} else {
		document.getElementById('page_suiv').style.display ='inline';
		document.getElementById('page_suiv').href='javascript:AffichListePagePromos('+(page+1)+', '+nbPage+');';
		document.getElementById('page_suiv_2').style.display ='inline';
		document.getElementById('page_suiv_2').href='javascript:AffichListePagePromos('+(page+1)+', '+nbPage+');';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LA LISTE DES VOLS DIRECT PAGES APRES PAGES
function AffichListeDirect(page, nbPage) {
	
	for(i=1; i<=nbPage; i++){
		if(i==page){
			document.getElementById('liste_page_vol_direct_'+i).style.display='';
		}else{
			document.getElementById('liste_page_vol_direct_'+i).style.display='none';
		}
	}
	
	//Reecriture de la liste des pages
	ListePageVolsDirect = '';
	if(page > 1){
		ListePageVolsDirect = '<a href="javascript:AffichListeDirect('+(page-1)+', '+nbPage+');"><b>Précédente</b></a> ';
	}
	if(page > 7){
		start = page - 7;
		if((page+7)<nbPage){
			end = page + 7;
		}else{
			end= nbPage;	
		}
	}else{
		i = 1;
		start = 1;
		if(nbPage > 15){
			end = 15;
		}else{
			end = nbPage;
		}
	}
	for (i = start; i <= end; i++) {
		if(i==page){
			ListePageVolsDirect = ListePageVolsDirect+'<a href="javascript:AffichListeDirect('+i+', '+nbPage+');" class="PageOn"><b>'+i+'</b></a> ';
		}else{
			ListePageVolsDirect = ListePageVolsDirect+'<a href="javascript:AffichListeDirect('+i+', '+nbPage+');" ><b>'+i+'</b></a> ';
		}
	}
	if(page < nbPage){
		ListePageVolsDirect = ListePageVolsDirect+'<a href="javascript:AffichListeDirect('+(page+1)+', '+nbPage+');"><b>Suivante</b></a>';
	}
		
	document.getElementById('ListePageVolDirect').innerHTML=ListePageVolsDirect;
}
function AffichListeDirectComp(idcomp, page, nbPage) {
	
	for(i=1; i<=nbPage; i++){
		if(i==page){
			document.getElementById('liste_page_vol_direct_'+idcomp+'_'+i).style.display='';
			document.getElementById('page_'+idcomp+'_'+i).className ='PageOn';
		}else{
			document.getElementById('liste_page_vol_direct_'+idcomp+'_'+i).style.display='none';
			document.getElementById('page_'+idcomp+'_'+i).className ='';
		}
	}
	if (page==1){
		document.getElementById('page_prec_'+idcomp+'').style.display ='none';
		document.getElementById('page_prec_'+idcomp+'').href='javascript:AffichListeDirectComp('+idcomp+', 0, '+nbPage+');';
	} else {
		document.getElementById('page_prec_'+idcomp+'').style.display ='inline';
		document.getElementById('page_prec_'+idcomp+'').href='javascript:AffichListeDirectComp('+idcomp+', '+(page-1)+', '+nbPage+');';
	}
	if (page==nbPage){
		document.getElementById('page_suiv_'+idcomp+'').style.display ='none';
		document.getElementById('page_suiv_'+idcomp+'').href='javascript:AffichListeDirectComp('+idcomp+', '+nbPage+', '+nbPage+');';
	} else {
		document.getElementById('page_suiv_'+idcomp+'').style.display ='inline';
		document.getElementById('page_suiv_'+idcomp+'').href='javascript:AffichListeDirectComp('+idcomp+', '+(page+1)+', '+nbPage+');';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LA LISTE DES VOLS DIRECT PAGES APRES PAGES
function AffichListeHisto(page, nbPage) {
	
	for(i=1; i<=nbPage; i++){
		if(i==page){
			document.getElementById('liste_page_vol_histo_'+i).style.display='';
			document.getElementById('page_histo_'+i).className ='PageOn';
		}else{
			document.getElementById('liste_page_vol_histo_'+i).style.display='none';
			document.getElementById('page_histo_'+i).className ='';
		}
	}
	if (page==1){
		document.getElementById('page_prec_histo').style.display ='none';
		document.getElementById('page_prec_histo').href='javascript:AffichListeHisto(0, '+nbPage+');';
	} else {
		document.getElementById('page_prec_histo').style.display ='inline';
		document.getElementById('page_prec_histo').href='javascript:AffichListeHisto('+(page-1)+', '+nbPage+');';
	}
	if (page==nbPage){
		document.getElementById('page_suiv_histo').style.display ='none';
		document.getElementById('page_suiv_histo').href='javascript:AffichListeHisto('+nbPage+', '+nbPage+');';
	} else {
		document.getElementById('page_suiv_histo').style.display ='inline';
		document.getElementById('page_suiv_histo').href='javascript:AffichListeHisto('+(page+1)+', '+nbPage+');';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LES VOLS COMPAGNIES
function AffichListeVols(id, liste) {
	
	if(document.getElementById('ListeCompVols_'+id+'_'+liste).style.display=='none'){
		document.getElementById('ListeCompVols_'+id+'_'+liste).style.display='';
		document.getElementById('BoutonPlus_'+id+'_'+liste).innerHTML='<a href="javascript:AffichListeVols('+id+', '+liste+');"><img src="/img/site/moins.png" class="abs" alt="Moins" width="16" height="16" border="0" /> <b>Moins de vols pour cette compagnie</b></a>';
	}else{
		document.getElementById('ListeCompVols_'+id+'_'+liste).style.display='none';
		document.getElementById('BoutonPlus_'+id+'_'+liste).innerHTML='<a href="javascript:AffichListeVols('+id+', '+liste+');"><img src="/img/site/plus.png" class="abs" alt="Plus" width="16" height="16" border="0" />  <b>Plus de vols pour cette compagnie</b></a>';
	}
}
//---

//--- FONCTION QUI PERMET D'AFFICHER LA LISTE DES VOLS POURL LES COMPAGNIES DANS LA LISTE COMP
function AffichListeVolsComp(nbComp, id) {
	
	for(i=0; i<nbComp; i++){
		
		if(i==id && document.getElementById('listeComp_'+i).style.display=='none'){
			document.getElementById('listeComp_'+i).style.display='';
		}else{
			document.getElementById('listeComp_'+i).style.display='none';
		}
	}
}
//---

//--- FONCTION QUI PERMET DE CHANGER ONGLET VOLS COMPAGNIES
function ChangeListeComp(id) {
	
	for(i=0; i<3; i++){
		if(i==id){
			document.getElementById('ListeComp_'+i).style.display='';
			document.getElementById('FlecheComp_'+i).src='/img/site/FlecheBas.png';
		}else{
			document.getElementById('ListeComp_'+i).style.display='none';
			document.getElementById('FlecheComp_'+i).src='/img/site/FlecheDroite.png';
		}
	}
}
//---

//--- FONCTION QUI PERMET DE CHANGER LES GRAPHIQUES PAGE VOL VILLE
function ChangeGraph(id) {
	
	if(id == 1){
		document.getElementById('GraphPluie').style.display='';
		document.getElementById('GraphTemp').style.display='none';
	}else{
		document.getElementById('GraphPluie').style.display='none';
		document.getElementById('GraphTemp').style.display='';
	}
}
//---

//--- FONCTION D'APPEL D'UNE PAGE EN AJAX QUI CHARGE LA METEO
function AppelAjaxMeteo(url, champ){
	
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourMeteo(http_request, champ); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourMeteo(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(champ).innerHTML = http_request.responseText;
		}
	}
}
//---

//--- FONCTION QUI PERMET DE CHANGER LA LISTE DES AEROPORTS PAR RAPPORT AU PAYS
function UpdateLiAero(id, lettre) {
	
	var url = '/ajax/UpdateLiAero.php?id='+id+'&lettre='+lettre;
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourLiAero(http_request, "liste_aeroports"); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourLiAero(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(champ).innerHTML = http_request.responseText;
		}
	}
}
//---

//--- FONCTION QUI PERMET DE CHANGER LA LISTE DES AEROPORTS PAR RAPPORT AU PAYS
function updateListeDirect(idliste, valeur, idVille, page) {
		
	if(idliste == 0){
		valeur1 = valeur;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
	}
	if(idliste == 1){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = valeur;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
	}
	if(idliste == 2){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = valeur;
	}
	
	var url = '/ajax/updateListeDirect.php?valeur1='+valeur1+'&valeur2='+valeur2+'&valeur3='+valeur3+'&id_ville_master='+idVille+'&page='+page;
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourDirect(http_request, "listeVolsDirect"); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourDirect(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(champ).innerHTML = http_request.responseText;
		}
	}
}
function updateListeDirectDepart(idliste, valeur, idVille, page) {
		
	if(idliste == 0){
		valeur1 = valeur;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
	}
	if(idliste == 1){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = valeur;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
	}
	if(idliste == 2){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = valeur;
	}
	
	var url = '/ajax/updateListeDirectDepart.php?valeur1='+valeur1+'&valeur2='+valeur2+'&valeur3='+valeur3+'&id_ville_master='+idVille+'&page='+page;
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourDirectDepart(http_request, "listeVolsDirect"); };
	http_request.open('GET', url, true);
	//window.open(url);
	http_request.send(null);
}
function gestionRetourDirectDepart(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(champ).innerHTML = http_request.responseText;
		}
	}
}
function updateListeDirectPays(idliste, valeur, idPays, page) {
		
	if(idliste == 0){
		valeur1 = valeur;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
		valeur4 = document.getElementById('ListeAeroArr').options[document.getElementById('ListeAeroArr').options.selectedIndex].value;
	}
	if(idliste == 1){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = valeur;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
		valeur4 = document.getElementById('ListeAeroArr').options[document.getElementById('ListeAeroArr').options.selectedIndex].value;
	}
	if(idliste == 2){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = valeur;
		valeur4 = document.getElementById('ListeAeroArr').options[document.getElementById('ListeAeroArr').options.selectedIndex].value;
	}
	if(idliste == 3){
		valeur1 = document.getElementById('ListeAeroDep').options[document.getElementById('ListeAeroDep').options.selectedIndex].value;
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
		valeur4 = valeur;
	}
	
	var url = '/ajax/updateListeDirectPays.php?valeur1='+valeur1+'&valeur2='+valeur2+'&valeur3='+valeur3+'&valeur4='+valeur4+'&id_pays_master='+idPays+'&page='+page;
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourDirectPays(http_request, "listeVolsDirect"); };
	http_request.open('GET', url, true);
	//window.open(url);
	http_request.send(null);
}
function gestionRetourDirectPays(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			//document.getElementById(champ).innerHTML = http_request.responseText;
			sp=http_request.responseText.split('###');
			
			document.getElementById(champ).innerHTML = sp[0];
			
			document.getElementById('DivListeAeroDep').innerHTML = sp[1];
			document.getElementById('DivListeAeroArr').innerHTML = sp[2];
			document.getElementById('DivListeCompVol').innerHTML = sp[3];
			document.getElementById('DivListeJours').innerHTML = sp[4];
			

		}
	}
}
function updateListeDirectVilleVille(idliste, valeur, idVille1, idVille2) {
		
	if(idliste == 1){
		valeur2 = valeur;
		valeur3 = document.getElementById('ListeJours').options[document.getElementById('ListeJours').options.selectedIndex].value;
	}
	if(idliste == 2){
		valeur2 = document.getElementById('ListeCompVol').options[document.getElementById('ListeCompVol').options.selectedIndex].value;
		valeur3 = valeur;
	}
	
	var url = '/ajax/updateListeDirectVilleVille.php?valeur2='+valeur2+'&valeur3='+valeur3+'&id_ville_master1='+idVille1+'&id_ville_master2='+idVille2;
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourDirectVilleVille(http_request, "listeVolsDirect"); };
	http_request.open('GET', url, true);
	//window.open(url);
	http_request.send(null);
}
function gestionRetourDirectVilleVille(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(champ).innerHTML = http_request.responseText;
		}
	}
}

//---

//--- FONCTION DE VERIFICATION DES CHAMPS DE CONTACT
function ValidContact() {
	
	var form = document.getElementById('contact');
	
	if(form.adresse.value.length > 1 && form.name.value.length > 1 && form.email.value.length > 1 && form.sujet.value.length > 1 && form.FormTexteContact.value.length > 1){
		form.submit();
	} else {
		alert("Tous les champs sont obligatoires !");	
	}
}
//---

//--- FONCTION QUI PERMET DE CHANGER LA LISTE DES PROMOTIONS
function UpdateLiPromos(val1, val2, val3, val4) {
	
	document.getElementById("ListePromos").innerHTML = '<center><img id="LoaderPromos" src="/img/site/loaderBigOrange.gif" alt="loader" border="0" width="32" height="32" /></center>';
	
	var url = '/ajax/UpdateLiPromos.php?val1='+val1+'&val2='+val2+'&val3='+val3+'&val4='+val4;
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourLiPromos(http_request, "ListePromos"); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourLiPromos(http_request, champ) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(champ).innerHTML = http_request.responseText;
		}
	}
}
//---

//--- FONCTION POUR RECHARGER LA LISTE DES AEROPORTS
function ReloadListeAero(url){
	
	document.getElementById('load_liste_aeroports').style.display='';
	document.getElementById('liste_aeroports').innerHTML = '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />';
	
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourListeAero(http_request); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourListeAero(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			
			sp=http_request.responseText.split('###');
			sp2=sp[1].split(',');
			sp3=sp[2].split(',');
			sp4=sp[3].split(',');
			var listeLatt2 = new Array();
			var listeLong2 = new Array();
			var listeId = new Array();
			for(i=0; i<sp2.length;i++){
				listeLatt2[i] = str_replace('"', '', sp2[i]);
				listeLong2[i] = str_replace('"', '', sp3[i]);
				listeId[i]    = str_replace('"', '', sp4[i]);
			}
			document.getElementById('liste_aeroports').innerHTML = sp[0];
			document.getElementById('load_liste_aeroports').style.display='none';
			LocaliseAero(listeLatt2, listeLong2, listeId);
		}
	}
}
//---


//--- FONCTION QUI PERMET D'UPDATER LA LISTE DES VOLS DIRECTS POUR UNE COMPAGNIE
function updtListeVolComp(iataComp, PaysDep, PaysArr, IataDep, IataArr, Page){
	
	var url='/ajax/updtListeVolComp.php?code_iata_compagnie='+iataComp+'&idPaysDep='+PaysDep+'&idPaysArr='+PaysArr+'&IataDep='+IataDep+'&IataArr='+IataArr+'&Page='+Page;
	
	var http_request = false;
	if (window.XMLHttpRequest) { //POUR MOZILLA
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // POUR INTERNET EXPLORER
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { gestionRetourUpdtVolComp(http_request); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
function gestionRetourUpdtVolComp(http_request) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			
			sp=http_request.responseText.split('###');
			
			document.getElementById('listeVolsDirectCompagnies').innerHTML = sp[0];
			
			document.getElementById('DivListePaysDep').innerHTML = sp[1];
			document.getElementById('DivListePaysArr').innerHTML = sp[2];
			document.getElementById('DivListeAeroDep').innerHTML = sp[3];
			document.getElementById('DivListeAeroArr').innerHTML = sp[4];
			
			sp2=sp[5].split(',');
			var listeCouple = new Array();
			if(sp2.length>0){
				for(i=0; i<sp2.length;i++){
					listeCouple[i] = str_replace('"', '', sp2[i]);
				}
			}else{
				listeCouple[0] = str_replace('"', '', sp[5]);
			}
			LocaliseComp(listeCouple);
		}
	}
}
//---