var infobulle = false;
function GetId(id) {
	return document.getElementById(id)
}

function pop_form(the_form) {
   my_form = eval(the_form);
   var popup = window.open("", "popup", "height=100,width=200,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'");
   my_form.target = "popup";
   setTimeout(function() {popup.close() },2000);
   my_form.submit();
}

function move(e) {
	if (infobulle) {
		if (navigator.appName != "Microsoft Internet Explorer") {
			GetId("divInfoBulle").style.left = e.pageX + 0 + "px";
			GetId("divInfoBulle").style.top = e.pageY + 20 + "px"
		} else {
			if (document.documentElement.clientWidth > 0) {
				GetId("divInfoBulle").style.left = 0 + event.x + document.documentElement.scrollLeft + "px";
				version=0
				if (navigator.appVersion.indexOf("MSIE")!=-1){
				temp=navigator.appVersion.split("MSIE")
				version=parseFloat(temp[1])
				}				
				/*if (version>=8.0)			
					GetId("divInfoBulle").style.top = 20 + event.y + "px";
				else
					*/GetId("divInfoBulle").style.top = 20 + event.y + document.documentElement.scrollTop + "px";
			} else {
				GetId("divInfoBulle").style.left = 0 + event.x + document.body.scrollLeft + "px";
				GetId("divInfoBulle").style.top = 20 + event.y + document.body.scrollTop + "px"
			}
		}
	}
}
function montre(contenu, titre) {
	if (infobulle == false) {
		GetId("divInfoBulle").style.visibility = "visible";
		GetId("divInfoBulle").innerHTML = "<div class='titreInfoBulle'>" + titre + "</div>";
		GetId("divInfoBulle").innerHTML += "<div class='contenuInfoBulle'>" + contenu + "</div>";
		infobulle = true
	}
}
function cache() {
	if (infobulle == true) {
		GetId("divInfoBulle").style.visibility = "hidden";
		infobulle = false
	}
}
document.onmousemove = move;
function enleveAccents(chaine) {
	temp = chaine.replace(/[àâä]/gi, "a");
	temp = temp.replace(/[éèêë]/gi, "e");
	temp = temp.replace(/[îï]/gi, "i");
	temp = temp.replace(/[ôö]/gi, "o");
	temp = temp.replace(/[ùûü]/gi, "u");
	temp = temp.replace(/[ç]/gi, "c");
	return temp
}
function selectionRegion(idRegion) {
	$('affRegion').style.display = 'none';
	$('chargementAjaxDept').style.display = 'block';
	imgCache(idRegion);
	$('type_etablissement').disabled = true;
	$('choixVillebis').disabled = true;
	$('boutonRechercheAccueil').disabled = true;
	var requete = new Ajax.Updater('affRegion', 'pages/accueil/affRegionAJAX.php', {
		parameters: 'region=' + idRegion + ''
	});
	$('divInfoBulle').innerHTML = '<div style=\"background-color:#FFFF00;\"> Choisissez un département </div>';
	$('choixDepartement').value = '';
	var reg = new Ajax.Updater('divTemp', 'pages/accueil/regionAJAX.php', {
		parameters: 'region=' + idRegion,
		onComplete: function() {
			$('choixRegion').value = $('divTemp').innerHTML;
			$('chemin').innerHTML = '<a href="/">Accueil</a> > ' + $('choixRegion').value;
			$('affRegion').style.display = 'block';
			$('chargementAjaxDept').style.display = 'none'
		}
	})
}
function selectionDept(idDepartement) {
	$('divInfoBulle').innerHTML = '<div style=\"background-color:#FFFF00;\"> Choisissez un type d\'hébergement </div>';
	$('type_etablissement').disabled = false;
	$('type_etablissement').options.selectedIndex = 0;
	$('choixVillebis').disabled = true;
	$('boutonRechercheAccueil').style.display = 'none';
	$('boutonRechercheAccueil2').style.display = 'none';
	var dept = new Ajax.Updater('divTemp', 'pages/accueil/departementAJAX.php', {
		parameters: 'departement=' + idDepartement,
		onComplete: function() {
			$('divIdDepartement').innerHTML = idDepartement;
			$('choixDepartement').value = $('divTemp').innerHTML;
			$('chemin').innerHTML = '<a href="/">Accueil</a> > <a href="region-' + enleveAccents(($('choixRegion').value).toLowerCase()) + '.html">' + $('choixRegion').value + '</a> > ' + $('choixDepartement').value
		}
	})
}
function imgCache(idRegion) {
	imgDefaut = new Image();
	imgDefaut.src = 'images/cartesDepartements/defaut.gif';
	switch (idRegion) {
	case 11:
		{
			img75 = new Image();
			img75.src = 'images/cartesDepartements/75.gif';
			img77 = new Image();
			img77.src = 'images/cartesDepartements/77.gif';
			img78 = new Image();
			img78.src = 'images/cartesDepartements/78.gif';
			img91 = new Image();
			img91.src = 'images/cartesDepartements/91.gif';
			img92 = new Image();
			img92.src = 'images/cartesDepartements/92.gif';
			img93 = new Image();
			img93.src = 'images/cartesDepartements/93.gif';
			img94 = new Image();
			img94.src = 'images/cartesDepartements/94.gif';
			img95 = new Image();
			img95.src = 'images/cartesDepartements/95.gif';
			break
		}
	case 21:
		{
			img08 = new Image();
			img08.src = 'images/cartesDepartements/08.gif';
			img10 = new Image();
			img10.src = 'images/cartesDepartements/10.gif';
			img51 = new Image();
			img51.src = 'images/cartesDepartements/51.gif';
			img52 = new Image();
			img52.src = 'images/cartesDepartements/52.gif';
			break
		}
	case 22:
		{
			img02 = new Image();
			img02.src = 'images/cartesDepartements/02.gif';
			img60 = new Image();
			img60.src = 'images/cartesDepartements/60.gif';
			img80 = new Image();
			img80.src = 'images/cartesDepartements/80.gif';
			break
		}
	case 23:
		{
			img27 = new Image();
			img27.src = 'images/cartesDepartements/27.gif';
			img76 = new Image();
			img76.src = 'images/cartesDepartements/76.gif';
			break
		}
	case 24:
		{
			img18 = new Image();
			img18.src = 'images/cartesDepartements/18.gif';
			img28 = new Image();
			img28.src = 'images/cartesDepartements/28.gif';
			img36 = new Image();
			img36.src = 'images/cartesDepartements/36.gif';
			img37 = new Image();
			img37.src = 'images/cartesDepartements/37.gif';
			img41 = new Image();
			img41.src = 'images/cartesDepartements/41.gif';
			img45 = new Image();
			img45.src = 'images/cartesDepartements/45.gif';
			break
		}
	case 25:
		{
			img50 = new Image();
			img50.src = 'images/cartesDepartements/50.gif';
			img14 = new Image();
			img14.src = 'images/cartesDepartements/14.gif';
			img61 = new Image();
			img61.src = 'images/cartesDepartements/61.gif';
			break
		}
	case 26:
		{
			img21 = new Image();
			img21.src = 'images/cartesDepartements/21.gif';
			img58 = new Image();
			img58.src = 'images/cartesDepartements/58.gif';
			img71 = new Image();
			img71.src = 'images/cartesDepartements/71.gif';
			img89 = new Image();
			img89.src = 'images/cartesDepartements/89.gif';
			break
		}
	case 31:
		{
			img59 = new Image();
			img59.src = 'images/cartesDepartements/59.gif';
			img62 = new Image();
			img62.src = 'images/cartesDepartements/62.gif';
			break
		}
	case 41:
		{
			img54 = new Image();
			img54.src = 'images/cartesDepartements/54.gif';
			img55 = new Image();
			img55.src = 'images/cartesDepartements/55.gif';
			img57 = new Image();
			img57.src = 'images/cartesDepartements/57.gif';
			img88 = new Image();
			img88.src = 'images/cartesDepartements/88.gif';
			break
		}
	case 42:
		{
			img67 = new Image();
			img67.src = 'images/cartesDepartements/67.gif';
			img68 = new Image();
			img68.src = 'images/cartesDepartements/68.gif';
			break
		}
	case 43:
		{
			img25 = new Image();
			img25.src = 'images/cartesDepartements/25.gif';
			img39 = new Image();
			img39.src = 'images/cartesDepartements/39.gif';
			img70 = new Image();
			img70.src = 'images/cartesDepartements/70.gif';
			img90 = new Image();
			img90.src = 'images/cartesDepartements/90.gif';
			break
		}
	case 52:
		{
			img44 = new Image();
			img44.src = 'images/cartesDepartements/44.gif';
			img49 = new Image();
			img49.src = 'images/cartesDepartements/49.gif';
			img53 = new Image();
			img53.src = 'images/cartesDepartements/53.gif';
			img72 = new Image();
			img72.src = 'images/cartesDepartements/72.gif';
			img85 = new Image();
			img85.src = 'images/cartesDepartements/85.gif';
			break
		}
	case 53:
		{
			img22 = new Image();
			img22.src = 'images/cartesDepartements/22.gif';
			img29 = new Image();
			img29.src = 'images/cartesDepartements/29.gif';
			img35 = new Image();
			img35.src = 'images/cartesDepartements/35.gif';
			img56 = new Image();
			img56.src = 'images/cartesDepartements/56.gif';
			break
		}
	case 54:
		{
			img16 = new Image();
			img16.src = 'images/cartesDepartements/16.gif';
			img17 = new Image();
			img17.src = 'images/cartesDepartements/17.gif';
			img79 = new Image();
			img79.src = 'images/cartesDepartements/79.gif';
			img86 = new Image();
			img86.src = 'images/cartesDepartements/86.gif';
			break
		}
	case 72:
		{
			img24 = new Image();
			img24.src = 'images/cartesDepartements/24.gif';
			img33 = new Image();
			img33.src = 'images/cartesDepartements/33.gif';
			img40 = new Image();
			img40.src = 'images/cartesDepartements/40.gif';
			img47 = new Image();
			img47.src = 'images/cartesDepartements/47.gif';
			img64 = new Image();
			img64.src = 'images/cartesDepartements/64.gif';
			break
		}
	case 73:
		{
			img09 = new Image();
			img09.src = 'images/cartesDepartements/09.gif';
			img12 = new Image();
			img12.src = 'images/cartesDepartements/12.gif';
			img31 = new Image();
			img31.src = 'images/cartesDepartements/31.gif';
			img32 = new Image();
			img32.src = 'images/cartesDepartements/32.gif';
			img46 = new Image();
			img46.src = 'images/cartesDepartements/46.gif';
			img65 = new Image();
			img65.src = 'images/cartesDepartements/65.gif';
			img81 = new Image();
			img81.src = 'images/cartesDepartements/81.gif';
			img82 = new Image();
			img82.src = 'images/cartesDepartements/82.gif';
			break
		}
	case 74:
		{
			img19 = new Image();
			img19.src = 'images/cartesDepartements/19.gif';
			img23 = new Image();
			img23.src = 'images/cartesDepartements/23.gif';
			img87 = new Image();
			img87.src = 'images/cartesDepartements/87.gif';
			break
		}
	case 82:
		{
			img01 = new Image();
			img01.src = 'images/cartesDepartements/01.gif';
			img07 = new Image();
			img07.src = 'images/cartesDepartements/07.gif';
			img26 = new Image();
			img26.src = 'images/cartesDepartements/26.gif';
			img38 = new Image();
			img38.src = 'images/cartesDepartements/38.gif';
			img42 = new Image();
			img42.src = 'images/cartesDepartements/42.gif';
			img69 = new Image();
			img69.src = 'images/cartesDepartements/69.gif';
			img73 = new Image();
			img73.src = 'images/cartesDepartements/73.gif';
			img74 = new Image();
			img74.src = 'images/cartesDepartements/74.gif';
			break
		}
	case 83:
		{
			img03 = new Image();
			img03.src = 'images/cartesDepartements/03.gif';
			img15 = new Image();
			img15.src = 'images/cartesDepartements/15.gif';
			img43 = new Image();
			img43.src = 'images/cartesDepartements/43.gif';
			img63 = new Image();
			img63.src = 'images/cartesDepartements/63.gif';
			break
		}
	case 91:
		{
			img11 = new Image();
			img11.src = 'images/cartesDepartements/11.gif';
			img30 = new Image();
			img30.src = 'images/cartesDepartements/30.gif';
			img34 = new Image();
			img34.src = 'images/cartesDepartements/34.gif';
			img48 = new Image();
			img48.src = 'images/cartesDepartements/48.gif';
			img66 = new Image();
			img66.src = 'images/cartesDepartements/66.gif';
			break
		}
	case 93:
		{
			img04 = new Image();
			img04.src = 'images/cartesDepartements/04.gif';
			img05 = new Image();
			img05.src = 'images/cartesDepartements/05.gif';
			img06 = new Image();
			img06.src = 'images/cartesDepartements/06.gif';
			img13 = new Image();
			img13.src = 'images/cartesDepartements/13.gif';
			img83 = new Image();
			img83.src = 'images/cartesDepartements/83.gif';
			img84 = new Image();
			img84.src = 'images/cartesDepartements/84.gif';
			break
		}
	case 94:
		{
			img2a = new Image();
			img2a.src = 'images/cartesDepartements/2a.gif';
			img2b = new Image();
			img2b.src = 'images/cartesDepartements/2b.gif';
			break
		}
	default:
		break
	}
}
function genererComboDepartement() {
	idRegion = $('regionSelect').options[$('regionSelect').selectedIndex].value;
	var ajax = new Ajax.Updater('divComboDepartement', 'pages/accueil/comboAccueilAJAX.php', {
		method: 'post',
		parameters: 'region=' + idRegion
	})
}
function genererComboVille() {
	$('divComboVillebis').style.display = 'none';
	$('chargementAjaxVillebis').style.display = 'block';
	$('boutonRechercheAccueil').disabled = false;
	$('boutonRechercheAccueil2').disabled = false;
	var id_departement = $('divIdDepartement').innerHTML;
	var type = $('type_etablissement').options[$('type_etablissement').selectedIndex].value;
	switch (type) {
	case 'Chambre d\'hôte':
		{
			var id_type = 1;
			$('boutonRechercheAccueil').style.display = 'block';
			break
		}
	case 'Camping':
		{
			var id_type = 2;
			$('boutonRechercheAccueil').style.display = 'block';
			break
		}
	case 'Hôtel':
		{
			var id_type = 3;
			$('boutonRechercheAccueil').style.display = 'block';
			break
		}
	case 'Location saisonnière':
		{
			var id_type = 4;
			$('boutonRechercheAccueil').style.display = 'block';
			break
		}
	case 'Gîte':
		{
			var id_type = 5;
			$('boutonRechercheAccueil').style.display = 'block';
			break
		}
	}
	/*var type2 = $('choixVillebis').options[$('choixVillebis').selectedIndex].value;
	if (type != 0 && type2 != 0) {
		$('boutonRechercheAccueil').style.display = 'block';
		$('boutonRechercheAccueil2').style.display = 'none'
	}*/
	var ville = new Ajax.Updater('divComboVillebis', 'pages/accueil/villeAJAX2.php', {
		method: 'post',
		parameters: 'dept=' + id_departement + '&type=' + id_type,
		onComplete: function() {
			if (type == 0) {
				$('choixVillebis').disabled = true;
				$('boutonRechercheAccueil').disabled = true;
				$('boutonRechercheAccueil').style.display = 'none';
				$('boutonRechercheAccueil2').style.display = 'none'
			} else {
				$('boutonRechercheAccueil').style.display = 'block';
				$('boutonRechercheAccueil2').style.display = 'none'
			}
			$('divComboVillebis').style.display = 'block';
			$('chargementAjaxVillebis').style.display = 'none'
		}
	})
}

function boutonville() {
	var type2 = $('choixVille').options[$('choixVille').selectedIndex].value;
	if (type2 != 0) {
		$('boutonRechercheAccueil').style.display = 'none';
		$('boutonRechercheAccueil2').style.display = 'block'
	} else {
		$('boutonRechercheAccueil').style.display = 'block';
		$('boutonRechercheAccueil2').style.display = 'none'
	}
}

function boutonvillebis() {
	var type2 = $('choixVillebis').options[$('choixVillebis').selectedIndex].value;
	if (type2 != 0) {
		$('boutonRechercheAccueil').style.display = 'none';
		$('boutonRechercheAccueil2').style.display = 'block'
	} else {
		$('boutonRechercheAccueil').style.display = 'block';
		$('boutonRechercheAccueil2').style.display = 'none'
	}
}

/*function boutonInverse() {
	var type3 = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	if (type3 != "null") {
		$('recherche').style.display = 'block';
		$('recherche2').style.display = 'none'
	} else {
		$('recherche').style.display = 'none';
		$('recherche2').style.display = 'none'
	}
}
function boutonInverse2() {
	var type4 = $('combo_ville').options[$('combo_ville').selectedIndex].value;
	if (type4 != "null") {
		$('recherche').style.display = 'none';
		$('recherche2').style.display = 'block'
	} else {
		$('recherche').style.display = 'block';
		$('recherche2').style.display = 'none'
	}
}*/
function controleRecherche() {
	if ($('choixRegion').value == '') {
		alert('Veuillez sélectionner une région.')
	} else if ($('choixDepartement').value == '') {
		alert('Veuillez sélectionner un département.')
	} else if ($('type_etablissement').options[$('type_etablissement').selectedIndex].value == 0) {
		alert('Veuillez sélectionner une catégorie d\'établissement.')
	} else if ($('choixVillebis').options[$('choixVillebis').selectedIndex].value == 0) {
		window.location = escape('resultatDept-region-' + enleveAccents(($('choixRegion').value).toLowerCase()) + '-departement-' + enleveAccents(($('choixDepartement').value).toLowerCase()) + '-type-' + enleveAccents(($('type_etablissement').options[$('type_etablissement').selectedIndex].value).toLowerCase()) + '.html')
	} else {
		window.location = escape('resultatVille-region-' + enleveAccents(($('choixRegion').value).toLowerCase()) + '-departement-' + enleveAccents(($('choixDepartement').value).toLowerCase()) + '-ville-' + enleveAccents(($('choixVillebis').options[$('choixVillebis').selectedIndex].value).toLowerCase()) + '-type-' + enleveAccents(($('type_etablissement').options[$('type_etablissement').selectedIndex].value).toLowerCase()) + '.html')
	}
}

function verifBlocText() {
	//alert ("Yop");
	if ($('combo_departement').options[$('combo_departement').selectedIndex].value == 'null')
	{
		alert('Veuillez choisir un département.');
		return false;
	}
	else if ($('combo_description').value == '')
	{
		alert('Veuillez remplir le champ de description.');
		return false;
	}
	else 
	{
		$('formBlocText').submit();
		return true;
	}
}

function verifBlocTextRegion() {
	if ($('combo_region').options[$('combo_region').selectedIndex].value == 'null')
	{
		alert('Veuillez choisir une région.');
		return false;
	}
	else if ($('combo_description_region').value == '')
	{
		alert('Veuillez remplir le champ de description.');
		return false;
	}
	else 
	{
		$('formBlocTextReg').submit();
		return true;
	}
}

function verifBlocTextType() {
	if ($('combo_type').options[$('combo_type').selectedIndex].value == 'null')
	{
		alert('Veuillez choisir un type d\'établissement.');
		return false;
	}
	else if ($('combo_description_type').value == '')
	{
		alert('Veuillez remplir le champ de description.');
		return false;
	}
	else 
	{
		$('formBlocTextType').submit();
		return true;
	}
}

function controleAuthentification() {
	if ($('login').value == '') {
		alert('Veuillez entrer votre identifiant.');
		$('login').focus();
		return false
	} else if ($('pass').value == '') {
		alert('Veuillez entrer votre mot de passe.');
		$('pass').focus();
		return false
	} else {
		$('connecter').value = 'Veuillez patienter ...';
		$('connecter').disabled = 'true';
		return true
	}
}
function controlePassOublie() {
	if ($('num_client').value == '') {
		alert('Veuillez renseigner votre numéro de client.');
		$('num_client').focus();
		return false
	} else if ($('email').value == '') {
		alert('Veuillez renseigner l\'adresse email saisie lors de votre inscription.');
		$('email').focus();
		return false
	} else {
		$('envoyer').value = 'Veuillez patienter ...';
		$('envoyer').disabled = 'true';
		return true
	}
}
function controleChangerPass() {
	var reg = new RegExp('^[a-zA-Z0-9]{3,}$');
	if ($('pass_old').value == '') {
		alert('Veuillez renseigner l\'ancien mot de passe.');
		$('pass_old').focus()
	} else if ($('pass_new').value == '') {
		alert('Veuillez renseigner le nouveau mot de passe.');
		$('pass_new').focus()
	} else if ($('pass_new_conf').value == '') {
		alert('Veuillez confirmer le nouveau mot de passe.');
		$('pass_new_conf').focus()
	} else if ($('pass_new_conf').value != $('pass_new').value) {
		alert('Le nouveau mot de passe et sa confirmation ne correspondent pas.');
		$('pass_new').value = '';
		$('pass_new_conf').value = '';
		$('pass_new').focus()
	} else if (!reg.exec($('pass_new').value)) {
		alert('Le nouveau mot de passe doit contenir au 3 caractères alphanumériques.');
		$('pass_new').value = '';
		$('pass_new_conf').value = '';
		$('pass_new').focus()
	} else {
		$('validerPass').value = 'Veuillez patienter ...';
		$('validerPass').disabled = 'true';
		$('formChangerPass').submit()
	}
}
function controleCompteRechHeberg() {
	if ((!$('radioCompteRecherche1').checked) && (!$('radioCompteRecherche2').checked) && (!$('radioCompteRecherche3').checked) && (!$('radioCompteRecherche4').checked) && (!$('radioCompteRecherche5').checked) && (!$('radioCompteRecherche6').checked) && (!$('radioCompteRecherche7').checked)) {
		alert('Veuillez sélectionner un type de recherche.');
		return false
	} else if (($('radioCompteRecherche1').checked) && ($('numClientRech').value == '')) {
		alert('Veuillez préciser un numéro de client.');
		$('numClientRech').focus();
		return false
	} else if (($('radioCompteRecherche2').checked) && ($('deptCompteRech').options[$('deptCompteRech').selectedIndex].value == '0')) {
		alert('Veuillez sélectionner un département.');
		$('deptCompteRech').focus();
		return false
	} else if (($('radioCompteRecherche2').checked) && ($('typeCompteRech').options[$('typeCompteRech').selectedIndex].value == '0')) {
		alert('Veuillez sélectionner un type d\'hébergement.');
		$('typeCompteRech').focus();
		return false
	} else if (($('radioCompteRecherche3').checked) && ($('libreRech').value == '')) {
		alert('Veuillez renseigner le champ de recherche.');
		$('libreRech').focus();
		return false
	} else if (($('radioCompteRecherche4').checked) && ($('idEtabRech').value == '')){
		alert('Veuillez renseigner un id d\'établissement.');
		$('idEtabRech').focus();
		return false
	} else if (($('radioCompteRecherche5').checked) && ($('mailRech').value == '')){
		alert('Veuillez renseigner un mail');
		$('mailRech').focus();
		return false
	} else if (($('radioCompteRecherche6').checked) && ($('cpRech').value == '')){
		alert('Veuillez renseigner un code postal');
		$('cpRech').focus();
		return false
	} else if (($('radioCompteRecherche7').checked) && ($('chaineRech').value == '')){
		alert('Veuillez renseigner une chaine');
		$('chaineRech').focus();
		return false
	} else {
		/*$('boutonRechHeberg').value = 'Veuillez patienter ...';
		$('boutonRechHeberg').disabled = 'true';*/
		return true
	}
}
function controleChangerBanniere() {
	if ((($('nom_banniere1').options[$('nom_banniere1').selectedIndex].value == '0') && $('url_banniere1').value != '') || (($('nom_banniere1').options[$('nom_banniere1').selectedIndex].value != '0') && $('url_banniere1').value == '')) {
		alert('L\'un des champs de la bannière n°1 n\'est pas renseigné.')
	} else if ((($('nom_banniere2').options[$('nom_banniere2').selectedIndex].value == '0') && $('url_banniere2').value != '') || (($('nom_banniere2').options[$('nom_banniere2').selectedIndex].value != '0') && $('url_banniere2').value == '')) {
		alert('L\'un des champs de la bannière n°2 n\'est pas renseigné.')
	} else if ((($('nom_banniere3').options[$('nom_banniere3').selectedIndex].value == '0') && $('url_banniere3').value != '') || (($('nom_banniere3').options[$('nom_banniere3').selectedIndex].value != '0') && $('url_banniere3').value == '')) {
		alert('L\'un des champs de la bannière n°3 n\'est pas renseigné.')
	} else if ((($('nom_banniere4').options[$('nom_banniere4').selectedIndex].value == '0') && $('url_banniere4').value != '') || (($('nom_banniere4').options[$('nom_banniere4').selectedIndex].value != '0') && $('url_banniere4').value == '')) {
		alert('L\'un des champs de la bannière n°4 n\'est pas renseigné.')
	} else if ((($('nom_banniere5').options[$('nom_banniere5').selectedIndex].value == '0') && $('url_banniere5').value != '') || (($('nom_banniere5').options[$('nom_banniere5').selectedIndex].value != '0') && $('url_banniere5').value == '')) {
		alert('L\'un des champs de la bannière n°5 n\'est pas renseigné.')
	} else {
		$('validerBanniere').value = 'Veuillez patienter ...';
		$('validerBanniere').disabled = 'true';
		$('formBanniere').submit()
	}
}
function trim(chaine) {
	return chaine.replace(/(^\s*)|(\s*$)/g, '')
}
function repereEspace(chaine) {
	var expression = /(^\s)|(\s)|(\s$)/g;
	return expression.test(chaine)
}

function controleFormulaireInscriptionGratuit() {
	if(trim($('enseigneInscription').value) == '') {
		alert('Veuillez préciser un nom d\'enseigne');
		$('enseigneInscription').focus()
	}
	else if ($('type_etablissementInscription').options[$('type_etablissementInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de votre établissement.');
		$('type_etablissementInscription').focus()
	}
	else if(trim($('adresseInscription').value) == '') {
		alert('Veuillez préciser une addresse');
		$('adresseInscription').focus()
	}
	else if (isNaN($('code_postalInscription').value) || (trim($('code_postalInscription').value)).length != 5) {
		alert('Le code postal doit être un nombre à 5 chiffres.');
		$('code_postalInscription').focus()
	}
	else if(trim($('villeInscription').value) == '') {
		alert('Veuillez préciser une ville');
		$('villeInscription').focus()
	}
	else {
		$('validerFormulaire').value = 'Veuillez patienter ...';
		$('validerFormulaire').disabled = 'true';
		$('formInscriptionGratuit').submit();
	}
}

function controleFormulaireInscriptionStudiofr() {
	if ($('type_contratInscription').options[$('type_contratInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de contrat.');
		$('type_contratInscription').focus()
	} else if (trim($('enseigneInscription').value) == '') {
		alert('Veuillez préciser l\'enseigne ou la raison sociale de l\'établissement.');
		$('enseigneInscription').focus()
	} else if ($('type_etablissementInscription').options[$('type_etablissementInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de votre établissement.');
		$('type_etablissementInscription').focus()
	} else if (trim($('nomInscription').value) == '') {
		alert('Veuillez préciser le nom du propriétaire.');
		$('nomInscription').focus()
	} else if (trim($('adresseInscription').value) == '') {
		alert('Veuillez préciser l\'adresse de l\'établissement.');
		$('adresseInscription').focus()
	} else if (trim($('code_postalInscription').value) == '') {
		alert('Veuillez préciser le code postal de l\'établissement.');
		$('code_postalInscription').focus()
	} else if (isNaN($('code_postalInscription').value) || (trim($('code_postalInscription').value)).length != 5) {
		alert('Le code postal doit être un nombre à 5 chiffres.');
		$('code_postalInscription').focus()
	} else if (trim($('villeInscription').value) == '') {
		alert('Veuillez préciser la ville de l\'établissement.');
		$('villeInscription').focus()
	} else {
		$('validerFormulaire').value = 'Veuillez patienter ...';
		$('validerFormulaire').disabled = 'true';
		$('formInscription').submit()
	}
}			

function controleFormulaireInscription() {
	if ($('type_contratInscription').options[$('type_contratInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de contrat.');
		$('type_contratInscription').focus()
	} else if (trim($('enseigneInscription').value) == '') {
		alert('Veuillez préciser l\'enseigne ou la raison sociale de l\'établissement.');
		$('enseigneInscription').focus()
	} else if ($('type_etablissementInscription').options[$('type_etablissementInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de votre établissement.');
		$('type_etablissementInscription').focus()
	} else if ($('civiliteInscription').options[$('civiliteInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser la civilité du propriétaire.');
		$('civiliteInscription').focus()
	} else if (trim($('nomInscription').value) == '') {
		alert('Veuillez préciser le nom du propriétaire.');
		$('nomInscription').focus()
	} else if (trim($('adresseInscription').value) == '') {
		alert('Veuillez préciser l\'adresse de l\'établissement.');
		$('adresseInscription').focus()
	} else if (trim($('code_postalInscription').value) == '') {
		alert('Veuillez préciser le code postal de l\'établissement.');
		$('code_postalInscription').focus()
	} else if (isNaN($('code_postalInscription').value) || (trim($('code_postalInscription').value)).length != 5) {
		alert('Le code postal doit être un nombre à 5 chiffres.');
		$('code_postalInscription').focus()
	} else if (trim($('villeInscription').value) == '') {
		alert('Veuillez préciser la ville de l\'établissement.');
		$('villeInscription').focus()
	} else if ((trim($('faxInscription').value) != '') && ((isNaN($('faxInscription').value)) || (trim($('faxInscription').value).length != 10))) {
		alert('Le numéro de fax doit être un nombre à 10 chiffres.');
		$('faxInscription').focus()
	} else if (trim($('emailInscription').value) == '') {
		alert('Veuillez préciser votre adresse email.');
		$('emailInscription').focus()
	} else if ($('altitude').value != '' && isNaN($('altitude').value)) {
		alert('L\'altitude renseignée doit être une valeur numérique.');
		$('altitude').focus()
	} else {
		$('validerFormulaire').value = 'Veuillez patienter ...';
		$('validerFormulaire').disabled = 'true';
		$('formInscription').submit()
	}
}

function controleFormulaireDuplication() {
	if (trim($('enseigneInscription').value) == '') {
		alert('Veuillez préciser l\'enseigne ou la raison sociale de l\'établissement.');
		$('enseigneInscription').focus()
	} else if ($('type_etablissementInscription').options[$('type_etablissementInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de votre établissement.');
		$('type_etablissementInscription').focus()
	} else if ($('civiliteInscription').options[$('civiliteInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser la civilité du propriétaire.');
		$('civiliteInscription').focus()
	} else if (trim($('nomInscription').value) == '') {
		alert('Veuillez préciser le nom du propriétaire.');
		$('nomInscription').focus()
	} else if (trim($('adresseInscription').value) == '') {
		alert('Veuillez préciser l\'adresse de l\'établissement.');
		$('adresseInscription').focus()
	} else if (trim($('code_postalInscription').value) == '') {
		alert('Veuillez préciser le code postal de l\'établissement.');
		$('code_postalInscription').focus()
	} else if (isNaN($('code_postalInscription').value) || (trim($('code_postalInscription').value)).length != 5) {
		alert('Le code postal doit être un nombre à 5 chiffres.');
		$('code_postalInscription').focus()
	} else if (trim($('villeInscription').value) == '') {
		alert('Veuillez préciser la ville de l\'établissement.');
		$('villeInscription').focus()
	} else if ((trim($('faxInscription').value) != '') && ((isNaN($('faxInscription').value)) || (trim($('faxInscription').value).length != 10))) {
		alert('Le numéro de fax doit être un nombre à 10 chiffres.');
		$('faxInscription').focus()
	} else if (trim($('emailInscription').value) == '') {
		alert('Veuillez préciser votre adresse email.');
		$('emailInscription').focus()
	} else if ($('altitude').value != '' && isNaN($('altitude').value)) {
		alert('L\'altitude renseignée doit être une valeur numérique.');
		$('altitude').focus()
	} else {
		$('validerFormulaire').value = 'Veuillez patienter ...';
		$('validerFormulaire').disabled = 'true';
		$('formInscription').submit()
	}
	
	/*var requete = new Ajax.Updater('affRegion', 'pages/accueil/affRegionAJAX.php', {
		parameters: 'region=' + idRegion + ''
	});*/
}

function controleFormulaireModificationClient() {
	
		$('validerFormulaire').value = 'Veuillez patienter ...';
		$('validerFormulaire').disabled = 'true';
		$('formInscription').submit()
	
}

function controleFormulaireGratuit() {
	if (trim($('enseigneInscription').value) == '') {
		alert('Veuillez préciser l\'enseigne ou la raison sociale de l\'établissement.');
		$('enseigneInscription').focus()
	} else if ($('type_etablissementInscription').options[$('type_etablissementInscription').selectedIndex].value == 0) {
		alert('Veuillez préciser le type de votre établissement.');
		$('type_etablissementInscription').focus()
	} else if (trim($('adresseInscription').value) == '') {
		alert('Veuillez préciser l\'adresse de l\'établissement.');
		$('adresseInscription').focus()
	} else if (trim($('code_postalInscription').value) == '') {
		alert('Veuillez préciser le code postal de l\'établissement.');
		$('code_postalInscription').focus()
	} else if (isNaN($('code_postalInscription').value) || (trim($('code_postalInscription').value)).length != 5) {
		alert('Le code postal doit être un nombre à 5 chiffres.');
		$('code_postalInscription').focus()
	} else if (trim($('villeInscription').value) == '') {
		alert('Veuillez préciser la ville de l\'établissement.');
		$('villeInscription').focus()
	} else {
		$('validerFormulaire').value = 'Veuillez patienter ...';
		$('validerFormulaire').disabled = 'true';
		$('formInscription').submit()
	}
}
function genererType() {
	var type5 = $('type_etab').options[$('type_etab').selectedIndex].value;
	if (type5 == '0') {
		$('detail_type').style.display = 'none';
		$('detail_type2').style.display = 'none';
		$('detail_type3').style.display = 'none';
		$('detail_classement').checked = false;
		$('aucun').checked = false
	}
	if (type5 == '1') {
		$('detail_type').style.display = 'block';
		$('detail_type2').style.display = 'none';
		$('detail_type3').style.display = 'none';
		$('detail_classement').checked = false;
		$('aucun').checked = false
	}
	if (type5 == '2') {
		$('detail_type').style.display = 'none';
		$('detail_type2').style.display = 'block';
		$('detail_classement').checked = true;
		$('detail_type3').style.display = 'none';
		$('aucun').checked = false
	}
	if (type5 == '3') {
		$('detail_type').style.display = 'none';
		$('detail_type2').style.display = 'none';
		$('detail_type3').style.display = 'block';
		$('detail_classement').checked = false;
		$('aucun').checked = true
	}
}
function genererTypes() {
	var typee6 = $('type_etab2').options[$('type_etab2').selectedIndex].value;	
	if (typee6 == '0') {
		$('detail_typee').style.display = 'none';
		$('detail_typee2').style.display = 'none';
		$('detail_typee3').style.display = 'none';
		$('detail_classement').checked = false
	}
	if (typee6 == '1') {
		$('detail_typee').style.display = 'block';
		$('detail_typee2').style.display = 'none';
		$('detail_typee3').style.display = 'none';
		$('detail_classement').checked = false
	}
	if (typee6 == '2') {
		$('detail_typee').style.display = 'none';
		$('detail_typee2').style.display = 'block';
		$('detail_classement').checked = true;
		$('detail_typee3').style.display = 'none'
	}
	if (typee6 == '3') {
		$('detail_typee').style.display = 'none';
		$('detail_typee2').style.display = 'none';
		$('detail_typee3').style.display = 'block';
		$('detail_classement').checked = false
	}
}

function genererTypesGite() {
	var typee6 = $('type_etab_gite').options[$('type_etab_gite').selectedIndex].value;	
	//alert(typee6);
	if (typee6 == '0') {
		$('detail_typee_gite').style.display = 'none';
		$('detail_typee2_gite').style.display = 'none';
		$('detail_typee3_gite').style.display = 'none';
		$('detail_classement_gite').checked = false
	}
	if (typee6 == '1') {
		$('detail_typee_gite').style.display = 'block';
		$('detail_typee2_gite').style.display = 'none';
		$('detail_typee3_gite').style.display = 'none';
		$('detail_classement_gite').checked = false
	}
	if (typee6 == '2') {
		$('detail_typee_gite').style.display = 'none';
		$('detail_typee2_gite').style.display = 'block';
		$('detail_classement_gite').checked = true;
		$('detail_typee3_gite').style.display = 'none'
	}
	if (typee6 == '3') {
		$('detail_typee_gite').style.display = 'none';
		$('detail_typee2_gite').style.display = 'none';
		$('detail_typee3_gite').style.display = 'block';
		$('detail_classement_gite').checked = false
	}
}


function afficherFormulaire() {
	var id_type_etablissement = $('type_etablissementInscription').options[$('type_etablissementInscription').selectedIndex].value;
	switch (id_type_etablissement) {
	case '1':
		{
			$('detail_chambre').style.display = "block";
			$('detail_camping').style.display = "none";
			$('detail_hotel').style.display = "none";
			$('detail_location').style.display = "none";
			$('detail_gite').style.display = "none";
			$('detail_label').style.display = "block";
			break
		}
	case '2':
		{
			$('detail_chambre').style.display = 'none';
			$('detail_camping').style.display = 'block';
			$('detail_hotel').style.display = 'none';
			$('detail_location').style.display = 'none';
			$('detail_gite').style.display = 'none';
			$('detail_label').style.display = "block";
			break
		}
	case '3':
		{
			$('detail_chambre').style.display = 'none';
			$('detail_camping').style.display = 'none';
			$('detail_hotel').style.display = 'block';
			$('detail_location').style.display = 'none';
			$('detail_gite').style.display = 'none';
			$('detail_label').style.display = "block";
			break
		}
	case '4':
		{
			$('detail_chambre').style.display = 'none';
			$('detail_camping').style.display = 'none';
			$('detail_hotel').style.display = 'none';
			$('detail_location').style.display = 'block';
			$('detail_gite').style.display = 'none';
			$('detail_label').style.display = "block";
			break
		}
	case '5':
		{
			$('detail_chambre').style.display = 'none';
			$('detail_camping').style.display = 'none';
			$('detail_hotel').style.display = 'none';
			$('detail_location').style.display = 'none';
			$('detail_gite').style.display = 'block';
			$('detail_label').style.display = "block";
			break
		}
	default:
		{
			$('detail_chambre').style.display = 'none';
			$('detail_camping').style.display = 'none';
			$('detail_hotel').style.display = 'none';
			$('detail_location').style.display = 'none';
			$('detail_gite').style.display = 'none';
			$('detail_label').style.display = 'none';
			break
		}
	}
}

function genererComboVilleBW(comboDept)
{
	
	var ville = new Ajax.Updater('divComboVilleBW', 'pages/rechercheMoteur/rechAvanceVilleAJAX-BW.php', {
		method: 'post',
		parameters: 'dept=' + comboDept,
		onComplete: function() {
			$('divComboVille').style.display = 'block';
			$('chargementAjaxVille').style.display = 'none'
		}
	})
}

function afficherFormulaire2() {
	var type_contratInscription = $('type_contratInscription').options[$('type_contratInscription').selectedIndex].value;
	if (type_contratInscription == 1 || type_contratInscription == 2) {
		$('detail_chambre_infos').style.display = "block";
		$('detail_camping_infos').style.display = "block";
		$('detail_hotel_infos').style.display = "block";
		$('detail_location_infos').style.display = "block";
		$('detail_gite_infos').style.display = "block";
		$('renseignement_inscription').style.display = "block";
		$('boutonValider').style.display = "block";
	}
			
}
function listeVille() {
	var code_postal = $('code_postalInscription').value;
	var ajax = new Ajax.Updater('divListeVille', '/pages/formulaire/listeVille.php', {
		method: 'post',
		parameters: 'code_postal=' + code_postal,
		onComplete: function() {
			if ($('divListeVille').innerHTML != '') {
				$('divListeVille').style.display = "block";
				$('divListeVille').style.visibility = "visible"
			}
		}
	})
}
function remplirChampVille(nomVille) {
	$('villeInscription').value = nomVille;
	$('divListeVille').style.display = "none";
	$('divListeVille').style.visibility = "hidden"
}
function pageListeVille(combo, region, departement, type, etoile, budget, chaine) {
	var ville = $(combo).options[$(combo).selectedIndex].value;
	var loc = '';
	// alert (order);
	if (ville != 0) {
		if (etoile != -1) 
			loc =  loc + '-nbetoile-' + etoile; 
		if (budget != -1)
			loc = loc + '-budget-' + budget;
		if (chaine != -1)
			loc = loc + '-chaine-' + chaine;
		window.location = 'resultatVille-region-' + region + '-departement-' + departement + '-ville-' + ville + '-type-' + type + loc + '.html'
	}
}
function pageListeVille1(combo, region, departement, type) {
	var ville = $(combo).options[$(combo).selectedIndex].value;
	window.location = 'resultatVille-region-' + region + '-departement-' + departement + '-ville-' + ville + '-type-' + type + '.html'
	
}
function controleTitrePhoto() {
	if (($('upload_1').value) && ($('titre_1').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°1.');
		$('titre_1').focus()
	} else if (($('upload_2').value) && ($('titre_2').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°2.');
		$('titre_2').focus()
	} else if (($('upload_3').value) && ($('titre_3').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°3.');
		$('titre_3').focus()
	} else if (($('upload_4').value) && ($('titre_4').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°4.');
		$('titre_4').focus()
	} else if (($('upload_5').value) && ($('titre_5').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°5.');
		$('titre_5').focus()
	} else if (($('upload_6').value) && ($('titre_6').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°6.');
		$('titre_6').focus()
		} else if (($('upload_7').value) && ($('titre_7').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°7.');
		$('titre_7').focus()
	} else if (($('upload_8').value) && ($('titre_8').value == '')) {
		alert('Veuillez indiquer un titre pour la photo n°8.');
		$('titre_8').focus()
	} else {
		$('valider').value = 'Veuillez patienter ...';
		$('valider').disabled = 'true';
		$('formAjoutPhoto').submit()
	}
}

function boiteDialogue(message, adresse) {
	if (confirm(message)) {
		window.location = adresse
	}
}
function recupererFacture(option) {
	if ($(option).options[$(option).selectedIndex].value != 0) {
		window.open($(option).options[$(option).selectedIndex].value, 'Facture')
	}
}
function genererComboVilleRechAvancee(comboDept, comboType, comboClassement) {
	var ville = new Ajax.Updater('divComboVille', 'pages/rechercheMoteur/rechAvanceVilleAJAX.php', {
		method: 'post',
		parameters: 'dept=' + comboDept + '&type=' + comboType + '&classement=' + comboClassement,
		onComplete: function() {
			$('divComboVille').style.display = 'block';
			$('chargementAjaxVille').style.display = 'none'
		}
	})
}

function remplir(dept, type) {
	// alert (type + ' < type | dept > ' + dept);
	var ajax = new Ajax.Updater('rowsDesc', '/pages/compte/admin/remplirAJAX.php', {
		method: 'post',
		parameters: 'dept=' + dept + '&type=' + type,
		onComplete: function() {
			$('rowsDesc').style.display = 'block';
		}
	})
	
}

function genererRegion(reg)
{
	var ajax = new Ajax.Updater('rowsReg', '/pages/compte/admin/regionAJAX.php', {
								method: 'post',
								parameters: 'reg=' + reg
								})
}

function genererTypeAJAX(type)
{
	var ajax = new Ajax.Updater('rowsType', '/pages/compte/admin/regionAJAX.php', {
								method: 'post',
								parameters: 'type=' + type
								})
}

function genererComboVilleText(comboDept, ville)
{
	
	var ville = new Ajax.Updater('divComboVille', 'pages/rechercheMoteur/rechAvanceVilleAJAXText.php', {
		method: 'post',
		parameters: 'dept=' + comboDept + '&ville=' + ville,
		onComplete: function() {
			$('divComboVille').style.display = 'block';
			$('chargementAjaxVille').style.display = 'none'
			if($('combo_ville').options[$('combo_ville').selectedIndex].value != 'null') 
			remplir($('combo_ville').options[$('combo_ville').selectedIndex].value, 'ville');
		}
	})
}

function genererComboVilleTop(comboDept)
{
	
	var ville = new Ajax.Updater('divComboVille', 'pages/rechercheMoteur/rechAvanceVilleAJAXTop.php', {
		method: 'post',
		parameters: 'dept=' + comboDept,
		onComplete: function() {
			$('divComboVille').style.display = 'block';
			$('chargementAjaxVille').style.display = 'none'
		}
	})
}
function genererComboChaineRechAvancee() 
{
	type = $("typeCompteRech").options[$("typeCompteRech").selectedIndex].value;
	dept = $("deptCompteRech").options[$("deptCompteRech").selectedIndex].value;
	ville = $("combo_ville").options[$("combo_ville").selectedIndex].value;
	
	// alert (type + ' ' + dept + ' ' + ville);
	
	var chaine = new Ajax.Updater('divComboChaine', 'pages/ajax/chaineAdmin.php', {
		method: 'post',
		parameters: 'dept=' + dept + '&type=' + type + '&ville=' + ville
	})
}

function genererComboVilleRechAvancee3(comboDept, comboType, comboChaine) {
	// alert ('dept=' + comboDept + '&type=' + comboType + '&classement=null&prix=null&chaine=' + comboChaine);
	var ville = new Ajax.Updater('divComboVille', 'pages/rechercheMoteur/rechAvanceVilleAJAX.php', {
		method: 'post',
		parameters: 'dept=' + comboDept + '&type=' + comboType + '&classement=null&prix=null&chaine=' + comboChaine
	})
}

function genererComboVilleRechAvancee2(comboDept, comboType, comboClassement) {
	var ville = new Ajax.Updater('divComboVille', 'pages/rechercheMoteur/rechAvanceVilleAJAX2.php', {
		method: 'post',
		parameters: 'dept=' + comboDept + '&type=' + comboType + '&classement=' + comboClassement
	})
}

function genererComboVilleRechAvancee1(comboDept, comboType, comboClassement, comboPrix, comboChaine) {
	var ville = new Ajax.Updater('divComboVille', 'pages/rechercheMoteur/rechAvanceVilleAJAX.php', {
		method: 'post',
		parameters: 'dept=' + comboDept + '&type=' + comboType + '&classement=' + comboClassement + '&prix=' + comboPrix + '&chaine=' + comboChaine,
		onComplete: function() {
			$('divComboVille').style.display = 'block';
			$('chargementAjaxVille').style.display = 'none'
		}
	})
	var chaine = new Ajax.Updater('divComboChaine', 'pages/rechercheMoteur/rechAvanceVilleAJAX.php', {
		method: 'post',
		parameters: 'dept=' + comboDept + '&type=' + comboType + '&classement=' + comboClassement + '&prix=' + comboPrix + '&chaine=' + comboChaine,
		onComplete: function() {
			$('divComboVille').style.display = 'block';
			$('chargementAjaxVille').style.display = 'none'
		}
	})
}

function genererComboPrix(comboClassement) {
	if(comboClassement != 2 && comboClassement != 'null')
	{
		$('formCritere').prix.disabled = false;
	}
	else
	{
		$('formCritere').prix.disabled = true;
	}
}

function genererComboChaine(comboClassement) {
	if(comboClassement != 4 && comboClassement != 'null')
	{
		$('formCritere').chaine.disabled = false;
	}
	else
	{
		$('formCritere').chaine.disabled = true;
	}
}

function controleCritere() {
	/*alert ($('combo_departement').options[$('combo_departement').selectedIndex].value);
	alert ($('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value);
	alert ($('combo_classement').options[$('combo_classement').selectedIndex].value);
	alert ($('combo_prix').options[$('combo_prix').selectedIndex].value);*/
	if($('combo_departement').options[$('combo_departement').selectedIndex].value == 'null' &&
		$('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value == 0 &&
		$('combo_classement').options[$('combo_classement').selectedIndex].value == 'null' &&
		$('combo_prix').options[$('combo_prix').selectedIndex].value == 'null')
	{
		alert ('Choissisez au moins un critère !')
		// $('combo_departement').focus();
	}
	else
	{
//		$('recherche2').value = 'Veuillez patienter ...';
//		$('recherche2').disabled = 'true';
		$('formCritere').submit()
	}
}

function stats_web(client) {
	var dept = new Ajax.Request('pages/rechercheHebergementListe/stats_webAJAX.php', {
		method: 'get',
		parameters: 'num_client=' + client
	})
}
function boutonInvRecherche() {
	$('resultat').style.display = 'none';
	$('tabville').style.display = 'block';
	$('boutontab').style.display = 'none';
	$('boutontab2').style.display = 'block'
}
function boutonInvRecherche2() {
	$('resultat').style.display = 'block';
	$('tabville').style.display = 'none';
	$('boutontab').style.display = 'block';
	$('boutontab2').style.display = 'none'
}
function appdis() {
	var myDate = new Date(); 
	if ($('checkAnnee').checked) {
		$('date1_deb').value = '01-01-'+myDate.getFullYear();
		$('date1_fin').value = '31-12-'+myDate.getFullYear();
		$('date2_deb').value = '';
		$('date2_fin').value = '';
		$('ouvAnne').style.visibility = "visible"
	} else {
		$('date1_deb').value = '';
		$('date1_fin').value = '';
		$('date2_deb').value = '';
		$('date2_fin').value = '';
		$('ouvAnne').style.visibility = "visible"
	}
}
function jsUpload(upload_field, id, titre) {
	var re_text = /\.jpg|\.jpeg/i;
	var filename = upload_field.value;
	var status = "upload_status" + id;
	if (titre.value == '' && id != "enTete") {
		document.getElementById("upload_status" + id).innerHTML = '<font color="#ff0000" face="Arial" size="2">Erreur:  Vous devez spécifier le Titre de l\'image</a>';
		upload_field.form.reset();
		return false
	}
	if (upload_field.value == '') {
		document.getElementById("upload_status" + id).innerHTML = '<font color="#ff0000" face="Arial" size="2">Erreur:  Vous devez séléctionner une image</a>';
		return false
	}
	if (filename.search(re_text) == -1) {
		document.getElementById("upload_status" + id).innerHTML = '<font color="#ff0000" face="Arial" size="2">Erreur de mise a jour :  utiliser les extensions suivantes : jpeg, jpg</a>';
		upload_field.form.reset();
		return false
	}
	var imagNumero = "imgNum" + id;
	document.getElementById(imagNumero).src = "images/boutons/ajax-loader-grand.gif";
	upload_field.form.submit();
	titre.disabled = true;
	upload_field.disabled = true;
	return true
}

/// PROMOVACANCE

// Dates
function addZero(vNumber){ 
	return ((vNumber < 10) ? "0" : "") + vNumber 
} 	
function formatDate(vDate, vFormat){ 
	var vDay                      = addZero(vDate.getDate()); 
	var vMonth            = addZero(vDate.getMonth()+1); 
	var vYearLong         = addZero(vDate.getFullYear()); 
	var vYearShort        = addZero(vDate.getFullYear().toString().substring(3,4)); 
	var vYear             = (vFormat.indexOf("yyyy")>-1?vYearLong:vYearShort) 
	var vHour             = addZero(vDate.getHours()); 
	var vMinute           = addZero(vDate.getMinutes()); 
	var vSecond           = addZero(vDate.getSeconds()); 
	var vDateString       = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear) 
	vDateString           = vDateString.replace(/hh/g, vHour).replace(/mm/g, vMinute).replace(/ss/g, vSecond) 
	return vDateString 
}
function FlyDate(){
	var myDate = new Date;
	var myDate2 = new Date;
	myDate.setDate(myDate.getDate()+5);
	myDate2.setDate(myDate2.getDate()+15);
	
	document.getElementById("vol_provenance").value = formatDate(myDate,'dd/MM/yyyy');
	document.getElementById("vol_destination").value = formatDate(myDate2,'dd/MM/yyyy');
}
// Fin Dates
function Check(){
// Contrôle de saisie des champs
	var TextError = "Il y a des erreurs :";
	var Position = new Array;
	var Position2 = new Array;
	var Dateprovenance = new Array;
	var DateRetour = new Array;
	var Error = 0;
	
	if (document.getElementById("provenance").value == '') { Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la ville de départ";} // Si Ville de départ non renseignée
	if (document.getElementById("destination").value == '') { Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la ville de d'arrivée";} // Si Ville de retour non renseignée
	if (document.getElementById("vol_provenance").value == '') { Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la date de départ";} // Si date de départ non renseignée
	if (document.getElementById("vol_provenance").value.length == 10)
		{
		j = 0;
		for (var i = 0; i < 11; i++)
			{
			chaine = document.getElementById("vol_provenance").value;
			if (chaine.charAt(i) == '/') {Position[j] = i;j++;}			
			}
		if (j != 2) { Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la date de depart au format JJ/MM/AAAA";}  // Si date de départ ne contient pas 2 / et donc n'est pas au format JJ/MM/AAAA
		}
		else
		{
		Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la date de départ au format JJ/MM/AAAA";  // Si date de départ ne contient pas 10 caractères
		}
	
	if (document.getElementById("simple").checked == false)
		{
		if (document.getElementById("vol_destination").value == '') { Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la date de retour";}  // Si date de retour n'est pas renseignée alors qu'il s'agit d'un aller retour
		if ((document.getElementById("vol_destination").value.length == 10))
			{
				j = 0;
				for (var i = 0; i < 11; i++)
					{
						chaine = document.getElementById("vol_destination").value;
						if (chaine.charAt(i) == '/') {Position2[j] = i;j++;}	
					}
				if (j != 2) { Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la date de retour au format JJ/MM/AAAA";}  // Si date de départ ne contient pas 2 / et donc n'est pas au format JJ/MM/AAAA
			}
			else
			{
				Error = Error + 1; TextError = TextError + "n - Veuillez renseigner la date de retour au format JJ/MM/AAAA";  // Si date de retour ne contient pas 10 caractères
			}
		}
	if (Error >= 1 ) { alert(TextError); Error=0;}
	else
	{
// Fin Contrôle de saisie des champs
// Redirection
	Dateprovenance[0] = document.getElementById("vol_provenance").value.substring(0,Position[0]); // Jour du départ	
	Dateprovenance[1] = document.getElementById("vol_provenance").value.substring(Position[0]+1,Position[1]); // Mois du départ
	Dateprovenance[2] = document.getElementById("vol_provenance").value.substring(Position[1]+1); // Année du départ
	if (document.getElementById("simple").checked) {document.getElementById("vol_destination").value = document.getElementById("vol_provenance").value;Position2=Position;} // En cas d'aller simple, retour = depart
	DateRetour[0] = document.getElementById("vol_destination").value.substring(0,Position2[0]); // Jour du retour	
	DateRetour[1] = document.getElementById("vol_destination").value.substring(Position2[0]+1,Position2[1]); // Mois du retour
	DateRetour[2] = document.getElementById("vol_destination").value.substring(Position2[1]+1); // Année du retour
	provenance = document.getElementById("provenance").value;
	destination = document.getElementById("destination").value;
	adultes = document.getElementById("adultes").selectedIndex + 1;
	enfants = document.getElementById("enfants").selectedIndex;
	bebes = document.getElementById("bebes").selectedIndex;
	if (document.getElementById("simple").checked) { simple = 0;} else { simple = 1;}
	var nav=(navigator.appName).toLowerCase(); 
		if (nav=="netscape"){ 
  		HTMLElement.prototype.insertAdjacentHTML = function (sWhere, sHTML) {
  		 var df;   // : DocumentFragment
  		 var r = this.ownerDocument.createRange();
   
 		  switch (String(sWhere).toLowerCase()) {  // convert to string and unify case
     			case "beforebegin":
				r.setStartBefore(this);
				df = r.createContextualFragment(sHTML);
				this.parentNode.insertBefore(df, this);
				break;
         
			case "afterbegin":
				r.selectNodeContents(this);
				r.collapse(true);
				df = r.createContextualFragment(sHTML);
				this.insertBefore(df, this.firstChild);
				break;
			}
		}
		}
	
		addFormElement('ALLERRETOUR', simple)
		addFormElement('DEPART_DD', Dateprovenance[0])
		addFormElement('DEPART_MM', Dateprovenance[1])
		addFormElement('DEPART_YYYY', Dateprovenance[2])
		addFormElement('RETOUR_DD', DateRetour[0])
		addFormElement('RETOUR_MM', DateRetour[1])
		addFormElement('RETOUR_YYYY', DateRetour[2])
	
		document.Mvols.submit();
		}
		}
		function addFormElement(inputName, inputValue)
		{
var addForm = document.createElement('input');
addForm.setAttribute('type','hidden');
addForm.setAttribute('name',inputName);
addForm.setAttribute('value',inputValue);
document.Mvols.appendChild(addForm);
}

//// FIN PROMOVACANCE

/**********************************************************************************************************************************************
 ********************************************** BANNIERE ENTETE *******************************************************************************
 **********************************************************************************************************************************************/
 
 // durée entre les images en ms
var time_banniere = 5000;
//image actuellement affichée
var current_image_banniere = 0;
//prochaine image à afficher
var next_image_banniere = 1;
//tableau contenant les images de la class "imageBanniere"
var image_banniere = new Array();


// cette fonction permet d'initialiser les images à afficher dans la banniere
// la premiere image image sera affichée, alors que les autres seront cachées (display=none)
function init_banniere() 
{
	if(document.getElementsByClassName("imageBanniere")) 
	{
		image_banniere = document.getElementsByClassName("imageBanniere");
		for(i=1; i < image_banniere.length; i++) 
		{
			image_banniere[i].style.display = "none";
		}
	}
	
	// si on a plus d'une image on lance la fonction bannieres() qui va faire defiler les images
	if(image_banniere.length > 1) bannieres();
}


// permet d'executer la fonction nextimage() avec un interval de temps defini dans time_banniere
function bannieres() 
{
	self.setTimeout("nextimage()",time_banniere);	
}

// permet de faire defiler les images avec l'effet de transition
function nextimage() 
{
	// applique les effets sur l'image courante et sur la prochaine image
	new Effect.Fade(image_banniere[current_image_banniere]); 
	new Effect.Appear(image_banniere[next_image_banniere]);
	
	// si la prochaine image est la derniere, on la traite et reinitialise le compteur à 0
	if(next_image_banniere == (image_banniere.length-1)) 
	{
		current_image_banniere = next_image_banniere;
		next_image_banniere = 0;
	} 
	else 
	{
		current_image_banniere = next_image_banniere;
		next_image_banniere++;
	}
	
	// on recommence
	bannieres();
}

/** Flash entete **/

function changePrice(id,compte)
{
	var tva =0.196;
	var coutTaxe=0;
	var totalTTC=0;
	var totalHT  = parseFloat(document.getElementById("totalHT"+compte).innerHTML);
	var opt      = parseFloat(document.getElementById("prixIndic"+id).innerHTML);
	
	if (document.getElementById("check"+id).checked)
	{
		
			document.getElementById("prix"+id).innerHTML=""+opt.toFixed(2);
			
			totalHT  = totalHT+opt;
			coutTaxe = totalHT*tva;
			totalTTC = totalHT+coutTaxe;
			
	}
	else
	{
			document.getElementById("prix"+id).innerHTML='0.00';
			totalHT  = totalHT-opt;
			coutTaxe = totalHT*tva;
			totalTTC = totalHT+coutTaxe;
	}
	
	document.getElementById("totalHT"+compte).innerHTML  = ""+totalHT.toFixed(2);
	document.getElementById("coutTTC"+compte).innerHTML  = ""+coutTaxe.toFixed(2);
	document.getElementById("totalTTC"+compte).innerHTML = ""+totalTTC.toFixed(2);

}

function fermer()
{
	var obj_window = window.open('', '_self');
	obj_window.opener = window;
	obj_window.focus();
	opener=self;
	self.close();
}

function lien_filtre_cat(fenetre, param)
{
	var lien = '';
	
	// on parcourt la liste des chaines passées en paramètres
	for(var i = 1 ; i < lien_filtre_cat.arguments.length ; i++)
	{
		// on reconstruit l'url
		lien += lien_filtre_cat.arguments[i];
	}
	
	//si http: n'apparait pas dans l'url
	var reg = new RegExp("http:","g");
	if(!lien.match(reg))
	{
		lien = 'http://mondialhotels.com'+lien;
	}
 
	// on redirige
	
	// alert(lien + " " + lien.lastIndexOf("mondialhotels.com"));
	if (lien.lastIndexOf("mondialhotels.com") != -1)
	{
		if(fenetre == 1)
			window.open(lien);
		else
			window.location.href = lien;
	}
	else 
	{		
		if(fenetre == 1)
			window.open('http://mondialhotels.com/transition.php?url='+encodeURIComponent(lien));
		else
			window.location.href = 'http://mondialhotels.com/transition.php?url='+encodeURIComponent(lien);
	}
}

function creerComboType() {
	// alert ('classement');
	comboType = $('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value;
	comboChaine = $('combo_chaine').options[$('combo_chaine').selectedIndex].value;
	comboPrix = $('combo_prix').options[$('combo_prix').selectedIndex].value;
	comboDept = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	comboVille = $('combo_ville').options[$('combo_ville').selectedIndex].value;
	comboClassement = $('combo_classement').options[$('combo_classement').selectedIndex].value;
		
	var type = new Ajax.Updater('divComboType', 'pages/ajax/creationFormulaireAJAX.php', {
		method: 'post',
		parameters: 'ligne=type&dept=' + comboDept + '&chaine=' + comboChaine + '&type=' + comboType + '&prix=' + comboPrix + '&ville=' + comboVille + '&classement=' + comboClassement
	})
}

function creerComboClassement() {
	// alert ('classement');
	comboType = $('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value;
	comboChaine = $('combo_chaine').options[$('combo_chaine').selectedIndex].value;
	comboPrix = $('combo_prix').options[$('combo_prix').selectedIndex].value;
	comboDept = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	comboVille = $('combo_ville').options[$('combo_ville').selectedIndex].value;
	comboClassement = $('combo_classement').options[$('combo_classement').selectedIndex].value;
		
	var type = new Ajax.Updater('divComboClassement', 'pages/ajax/creationFormulaireAJAX.php', {
		method: 'post',
		parameters: 'ligne=classement&dept=' + comboDept + '&chaine=' + comboChaine + '&type=' + comboType + '&prix=' + comboPrix + '&ville=' + comboVille + '&classement=' + comboClassement
	})
}

function creerComboDepartement() {
	// alert ('dept');
	comboType = $('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value;
	comboChaine = $('combo_chaine').options[$('combo_chaine').selectedIndex].value;
	comboPrix = $('combo_prix').options[$('combo_prix').selectedIndex].value;
	comboClassement = $('combo_classement').options[$('combo_classement').selectedIndex].value;
	comboDept = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	
	var type = new Ajax.Updater('divComboDept', 'pages/ajax/creationFormulaireAJAX.php', {
		method: 'post',
		parameters: 'ligne=dept&classement=' + comboClassement + '&chaine=' + comboChaine + '&type=' + comboType + '&prix=' + comboPrix + '&dept=' + comboDept
	})
}

function creerComboVille() {
	// alert ('ville');
	comboType = $('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value;
	comboChaine = $('combo_chaine').options[$('combo_chaine').selectedIndex].value;
	comboPrix = $('combo_prix').options[$('combo_prix').selectedIndex].value;
	comboDept = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	comboClassement = $('combo_classement').options[$('combo_classement').selectedIndex].value;
	
	var type = new Ajax.Updater('divComboVille', 'pages/ajax/creationFormulaireAJAX.php', {
		method: 'post',
		parameters: 'ligne=ville&dept=' + comboDept + '&chaine=' + comboChaine + '&type=' + comboType + '&prix=' + comboPrix + '&classement=' + comboClassement
	})
}

function creerComboChaine() {
	// alert ('chaine');
	comboType = $('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value;	
	comboPrix = $('combo_prix').options[$('combo_prix').selectedIndex].value;
	comboDept = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	comboVille = $('combo_ville').options[$('combo_ville').selectedIndex].value;
	comboClassement = $('combo_classement').options[$('combo_classement').selectedIndex].value;
	comboChaine = $('combo_chaine').options[$('combo_chaine').selectedIndex].value;
	
	var type = new Ajax.Updater('divComboChaine', 'pages/ajax/creationFormulaireAJAX.php', {
		method: 'post',
		parameters: 'ligne=chaine&dept=' + comboDept + '&chaine=' + comboChaine + '&type=' + comboType + '&prix=' + comboPrix + '&classement=' + comboClassement + '&ville=' + comboVille
	})
}

function creerComboPrix() {
	
	comboType = $('combo_type_etablissement').options[$('combo_type_etablissement').selectedIndex].value;	
	comboDept = $('combo_departement').options[$('combo_departement').selectedIndex].value;
	comboVille = $('combo_ville').options[$('combo_ville').selectedIndex].value;
	comboClassement = $('combo_classement').options[$('combo_classement').selectedIndex].value;
	comboChaine = $('combo_chaine').options[$('combo_chaine').selectedIndex].value;
	comboPrix = $('combo_prix').options[$('combo_prix').selectedIndex].value;
	// alert ('prix ' + comboPrix);
	var type = new Ajax.Updater('divComboPrix', 'pages/ajax/creationFormulaireAJAX.php', {
		method: 'post',
		parameters: 'ligne=prix&dept=' + comboDept + '&chaine=' + comboChaine + '&type=' + comboType + '&prix=' + comboPrix + '&classement=' + comboClassement + '&ville=' + comboVille
	})
}

var actiffenetre = false; 
function montre_fen(url,h,l) { 
var top=(screen.height-h)/2;
var left=(screen.width-l)/2;

	if (actiffenetre == false) { 
		eval ("var fenetre = window.open(url,'info','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=" + l + ",height=" + h + ",top="+top+",left="+left+"')") 
		if (fenetre != null) { if (fenetre.opener == null) { fenetre.opener = self; window.name = "infos"; fenetre.location.href=url; } }
	}
}
