window.addEvent('domready', function() {
	Element.implement({  
		//implement show
		show: function() {
			this.setStyle('display','');
		},  
		//implement hide
		hide: function() {  
			this.setStyle('display','none');  
		} 
	});
	
	if (provenance_resa == "retour") {
		recalcul();
	}
	
	if ($("pushhaut")) {
		$("pushhaut").setStyle('opacity', .7);
	}
	if ($("pushbas")) {
		$("pushbas").setStyle('opacity', .7);
	}
});
function centerPopup(element,parent) {
	var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	if(parent == "body"){
		myParent=document.body;
	}else{
		myParent=document.getElementById(element).parentNode;
	}
	var pHeight=myParent.offsetHeight;//Hauteur de l'élément parent
	var pWidth=myParent.offsetWidth;//Largeur de l'élément parent
	var sTop=myParent.scrollTop;//Hauteur de défilement de l'élément parent
	var sLeft=myParent.scrollLeft;//Longueur de défilement de l'élément parent
	var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X
	document.getElementById(element).style.top=posY+"px";
	document.getElementById(element).style.left=posX+"px";
}
function getIEVersionNumber() {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}
function hideLoading(style_page){
	ieVersion = getIEVersionNumber();
	if (ieVersion==6)
	{
		$$(".chp_recherche").each(function(el) {           
	        el.style.display = "";
	        //alert("fgd");
		});
		$$("#formReserver1").each(function(el) {           
	        el.style.display = "";
	        //alert("fgd");
		});
	}
	if ($("attente")) {
		$("attente").dispose();
		if(style_page == "alone"){
			$("loadingHome").hide();
			$("loadingHome").dispose();
		}else{
			$("loading").hide();
			$("loading").dispose();
		}
	}
}
function showLoading(style_page){
	ieVersion = getIEVersionNumber();
	if (ieVersion==6)
	{
		$$(".chp_recherche").each(function(el) {           
	        el.style.display = "none";
	        //alert("fgd");
		});
		$$("#formReserver1").each(function(el) {           
	        el.style.display = "none";
	        //alert("fgd");
		});
	}
	Attente = new Element('div', {
		'id'    : 'attente',
		'styles': {
	      'display'           : '',
	      'position'          : 'absolute',
	      'opacity'           : .75,
	      'z-index'           : 10000,
	      'background-color'  : "#fff",
	      'height'            : '180px',
	      'width'             : '180px'
		}
	});
	
	var obj;
	if ($('searchForm')) {
		obj = $('searchForm');
	} else {
		obj = $('searchFormHome');
	}
	
	
	Attente.set('html', '<center><img src="images/loader.gif" /><br /></center>');
	if(style_page == "alone"){
		OverlayHome = new Element('div', {
			'id'    : 'loadingHome',
			'styles': {
		      'display'           : 'none',
		      'position'          : 'absolute',
		      'top'               : obj.getTop() + 'px',
		      'left'              : obj.getLeft() + 'px',
		      'opacity'           : .75,
		      'z-index'           : 10000,
		      'background-color'  : "#fff",
		      'height'            : obj.getHeight() + 'px',
		      'width'             : obj.getWidth() + 'px'
			}
		});
		OverlayHome.injectInside(obj);
		Attente.injectInside($('loadingHome'));
		$("loadingHome").show();
		centerPopup('attente');
	}else{
		Overlay = new Element('div', {
			'id'    : 'loading',
			'styles': {
		      'display'           : 'none',
		      'position'          : 'absolute',
		      'top'               : '0',
		      'left'              : '0',
		      'opacity'           : .75,
		      'z-index'           : 15000,
		      'background-color'  : "#fff",
		      'height'            : window.getScrollHeight() + 'px',
		      'width'             : window.getScrollWidth() + 'px'
			}
		});
		Overlay.injectInside(document.body);
		Attente.injectInside($('loading'));
		$("loading").show();
		centerPopup('attente',"body");
	}
}

function showDiv(elem)
{
	/*
	var mySlide = new Fx.Slide(elem);
	mySlide.toggle();
	*/
	$(elem).setStyle('display','');
}
function hideDiv(elem)
{
	/*
	var mySlide = new Fx.Slide(elem);
	mySlide.toggle();
	*/
	$(elem).setStyle('display','none');
}
function showHide(elem)
{
	if($(elem).style.display == 'none')
	{
		showDiv(elem);
	}
	else
	{
		hideDiv(elem);
	}
}

function getSortBy(formName) {
	ret = "";
	if($('sortBy'+formName).checked)
	{
		ret = "";
	}
	if($('sortBy_base_price_desc'+formName).checked)
	{
		ret = "base_price_desc";
	}
	if($('sortBy_country'+formName).checked)
	{
		ret = "country";
	}
	
	return ret;
}

function getFormSerialized(formName){
	var fromCityCode = $('fromCityCode'+formName).value;
	var toCountryCode = $('toCountryCode'+formName).value;
	
	var filtre_region = "";
	if ($('filtre_region'+formName)) {
		filtre_region = $('filtre_region'+formName).value;
	}
	
	var toCityCode = "";
	if ($('toCityCode'+formName)) {
		toCityCode = $('toCityCode'+formName).value;
	}	
	
	var filtre_formule = $('filtre_formule'+formName).value;
	var filtre_prix = $('filtre_prix'+formName).value;
	
	var filtre_jours = "";
	if ($('filtre_jours'+formName)) {
		filtre_jours = $('filtre_jours'+formName).value;
	}
	var filtre_mois = $('filtre_mois'+formName).value;
	
	var departureDayRange = "";
	if ($('departureDayRange'+formName)) {
		departureDayRange = $('departureDayRange'+formName).value;
	}
	
	var filtre_duree = "";
	if ($('filtre_duree'+formName)) {
		filtre_duree = $('filtre_duree'+formName).value;
	}
	
	if($('filtre_promotionStatus'+formName).type == "hidden")
	{
		var filtre_promotionStatus = $('filtre_promotionStatus'+formName).value;
	}
	else
	{
		if($('filtre_promotionStatus'+formName).checked)
		{
			var filtre_promotionStatus = "1";
		}
		else
		{
			var filtre_promotionStatus = "";
		}
	}
	if($('sortBy'+formName).type == "hidden")
	{
		var sortBy = $('sortBy'+formName).value;
	}
	else
	{
		var sortBy = getSortBy(formName);
	}
	var serialized;
	serialized = "fromCityCode="+fromCityCode;
	serialized+= "&toCountryCode="+toCountryCode;
	serialized+= "&filtre_region="+filtre_region;
	serialized+= "&toCityCode="+toCityCode;
	serialized+= "&filtre_formule="+filtre_formule;
	serialized+= "&filtre_prix="+filtre_prix;
	serialized+= "&filtre_jours="+filtre_jours;
	serialized+= "&filtre_mois="+filtre_mois;
	serialized+= "&departureDayRange="+departureDayRange;
	serialized+= "&filtre_duree="+filtre_duree;
	serialized+= "&filtre_promotionStatus="+filtre_promotionStatus;
	serialized+= "&sortBy="+sortBy;
	//alert(serialized);
	return serialized;
}

function chargeFiltreDepart(param,style_page,formName){
	if($('toCountryCode'+formName).value == ""){
		chargeFiltre(param,style_page,formName);
	}
}
function chargeFiltreDestination(param,style_page,formName){
	if($('fromCityCode'+formName).value == "!XXX"){
		chargeFiltre(param,style_page,formName);
	}
}

function chargeFiltre(param,style_page,formName) {
	$('pg'+formName).value = 1;
	if(style_page == 'alone'){
		var formSend = new Request.HTML({url:'ajax/filtre.php?style_page='+style_page+'&'+getFormSerialized(formName)+'&last_filtre='+param, 
			onSuccess: function(html) {
				//Clear the text currently inside the results div.
				$('searchFormC').set('text', '');
				//Inject the new DOM elements into the results div.
				$('searchFormC').adopt(html);
				//hideLoading(style_page);
			},
			onFailure: function() {
				$('searchFormC').set('text', 'The request failed.');
			},
			onRequest : function () {					
					showLoading(style_page);
				}		
		});
		formSend.send();
	}
	else{
		showLoading('');
		$('last_filtre'+formName).value = param;
		$(formName).submit();
	}
}

function submitFormulaire(last_filtre,formName){
	$('pg'+formName).value = 1;
	showLoading('');
	$('last_filtre'+formName).value = last_filtre;
	$(formName).submit();
}
function submitFormulaireSort(last_filtre, sortBy,formName){
	$('pg'+formName).value = 1;
	$('sortBy'+formName).value = sortBy;
	//hideLoading();
	showLoading('');
	$('last_filtre'+formName).value = last_filtre;
	$(formName).submit();
}

function changePage(indice) {	
	showLoading('');
	$('pg'+"form_filtre").value = indice;
	document.form_filtre.submit();
}
function calendarPrix(id,page)
{
	var calendarPrixSend = new Request.HTML({url:'ajax/calendarPrix.php?id_sejour='+id+'&'+getFormSerialized("form_filtre")+'&pg='+page, 
		onSuccess: function(html) {
			
			//Clear the text currently inside the results div.
			$('calendarPrix'+id).set('text', '');
			//Inject the new DOM elements into the results div.
			$('calendarPrix'+id).adopt(html);
			hideLoading('');
			
			if ($("hiddenCalendar").value != "") showHideCalendar("containerCalendar"  + $("hiddenCalendar").value, "containerCalendarClass" + $("hiddenCalendar").value);
		},
		onFailure: function() {
			$('calendarPrix'+id).set('text', 'The request failed.');
		},
		onRequest : function () {					
				showLoading('');
			}		
	});
	calendarPrixSend.send();
}
function hideAllCalendar(){
	$$('div.calendarVille').setStyle('display','none');
}
function hideAllDispoPrixDetail(){
	$$('div.dispoPrixDetail').setStyle('display','none');
}

function showHideCalendar(elem,spanName){
	hideAllCalendar();
	$$('span.containerCalendarClass').setStyle("font-weight","normal");
	$(spanName).setStyle("font-weight","bolder");
	showDiv(elem);
}

function showDispoPrixDetail(elem){
	hideAllDispoPrixDetail();
	
	showDiv(elem);
}
function scrollToNext(elem, container)
{
	//On commence par recuperer la position
	var pos = $(elem).getPosition($(container));
	var x = Math.abs(pos.x);
	var nextX = x+150;
	var myFx = new Fx.Scroll(elem, {
	    duration: 1000,
	    wait: false
	}).start(nextX,0);
}
function scrollToPrev(elem, container)
{
	//On commence par recuperer la position
	var pos = $(elem).getPosition($(container));
	var x = Math.abs(pos.x);
	var nextX = x-150;
	var myFx = new Fx.Scroll(elem, {
	    duration: 500,
	    wait: false
	}).start(nextX,0);
}

function getSejour(id_sejour, page) {	
	showLoading('');
	location.href = 'detail.php?id_sejour='+id_sejour+'&pg='+page+'&'+getFormSerialized('form_filtre');
}
function getSejourIndex(id_sejour, pays, ville, date, page) {	
	showLoading('');
	location.href = 'detail.php?id_sejour='+id_sejour+'&toCountryCode='+pays+'&fromCityCode='+ville+'&pg='+page+'&date='+date;
}
function getSejourWithDate(id_sejour, page, ville, date, pays) {
	showLoading('');
	location.href = 'detail.php?id_sejour='+id_sejour+'&pg='+page+'&fromCityCode='+ville+'&date='+date+'&toCountryCode='+pays;
}

function getNbSejour(formName)
{
	return $('nbSejour'+formName).value;
}

function interogationQuotation(){
	//Demande de dispo avec le webservice de resa
	$("boutonReservation").hide();
	var interogationQuotationSend = new Request.HTML({url:'ajax/interogation_quotation.php?'+getFormResaSerialized('form_filtre'), 
		evalScripts: true, 
		onSuccess: function(html) {
			hideLoading('');
			//Clear the text currently inside the results div.
			$('boutonReservation').set('text', '');
			//Inject the new DOM elements into the results div.
			$('boutonReservation').adopt(html);
		},
		onFailure: function() {
			//$('boutonReservation').set('text', 'The request failed.');
		},
		onRequest : function () {					
				showLoading('');
			}		
	});
	interogationQuotationSend.send();
}

function getFormResaSerialized(formName){
	
	var sejour_id = $("sejour_id").value;
	var ville_depart = $("grp_disponibilites").value;
	var numDate = $(ville_depart+"Date_depart").value;
	var nbAdultes = $("nb_adultes").value;
	var nbEnfants = $("nb_enfants").value;
	var nbBebes = $("nb_bebes").value;
	var nom_to = $("nom_to").value;
	var ref_to = $("ref_to").value;
	
	var serialized;
	serialized = "sejour_id="+sejour_id;
	serialized+= "&ville_depart="+ville_depart;
	serialized+= "&numDate="+numDate;
	serialized+= "&nbAdultes="+nbAdultes;
	serialized+= "&nbEnfants="+nbEnfants;
	serialized+= "&nbBebes="+nbBebes;
	serialized+= "&nom_to="+nom_to;
	serialized+= "&ref_to="+ref_to;
	
	for(i=0; i < nbEnfants; i++)
	{
		serialized+= "&ageEnfant"+i+"="+$("age_"+i).value;
	}
	//alert(serialized);
	return serialized;
}

function showDiaporama(id_sejour) {
	window.open("diaporama.php?id_sejour="+id_sejour, "diaporama", "top=1px, left=1px, height=700px, width=900px, resizable=yes, scrollbars=yes, menubar=no, titlebar=no");
}

function loadDiaporama()
{
	var data = $$('div.slideShowData').get('id');
	var myShow = new Slideshow.KenBurns('show', data, {controller: true, delay: 4000, duration: 1000, height: 170, thumbnails: false, width: 250});
}
function loadDiaporama2()
{
	var data = $$('div.slideShowData').get('id');
	var myShow = new Slideshow.KenBurns('show', data, {controller: true, delay: 4000, duration: 1000, height: 600, thumbnails: false, width: 800});
}
function processReservation(){
	showLoading('');
	document.location.href = 'process_reservation.php';
}
function valideReservation(){
	showLoading('');
	
	$('form_sejour').type_requete.value = "reservation";
    $('form_sejour').set('send', {
    	evalScripts:true,
    	onComplete: function(response) { 
        	//hideLoading('');
    	}
    });
    
    //Send the form.
    $('form_sejour').send();
}

function affiche_ages(valeur, min, max) {
	var age_min = parseInt(min, 10);
	var age_max = parseInt(max, 10);
	
	var template = "Enfant ag&eacute; de <select id=\"age_XXX\" name=\"age_XXX\" class=\"bloc\">"
	
	for (var j = age_min; j<=age_max; j++) {
		template 		+= "<option value=\"" + j + "\">" + j + "</option>";
	}
	template 		+= "</select>";
	
	valeur = parseInt(valeur, 10);
	//if (valeur > 0) {
		var html 		= "";
		for (var i=0; i<valeur; i++) {
			html 		+= template.replace(/XXX/g, i) + "<br />";			
		}
		$("age_enfants").style.display 		= "";
		$("age_html").innerHTML 			= html;				
		

	//}
	
	//showDetailGroupeVille('disponibilites_duree', false, who);
}

function displayError(id_div, message) {
	if ($(id_div)) {
		window.scrollTo(0, 0);
		busy = true;
		$(id_div).style.display = "";
		$(id_div).innerHTML 	= message;
		$(id_div).innerHTML 	+= "<div style=\"position:absolute;right:1px;bottom:1px\"><a href=\"javascript:hideError('" + id_div + "')\" class=\"lien_erreur\">fermer</a></div>";
		var imgEffect = $(id_div).effect('opacity', {duration: 1500});
		imgEffect.start(1).chain(function() {					
			busy = false;
			/*var imgEffect2 = $(id_div).effect('opacity', {duration: 2000});
			imgEffect2.start(0).chain(function() {
				$(id_div).style.display = "none";
				busy = false;
			});*/
		});	
		
		if (id_div == "message_available") {
			if ($("message_available_2")) {
				$("message_available_2").style.display = "";
				$("message_available_2").innerHTML 	= message;
				$("message_available_2").innerHTML 	+= "<div style=\"position:absolute;right:1px;bottom:1px\"><a href=\"javascript:hideError('" + id_div + "')\" class=\"lien_erreur\">fermer</a></div>";
				var imgEffect = $("message_available_2").effect('opacity', {duration: 1500});
				imgEffect.start(1).chain(function() {					
					busy = false;
					/*var imgEffect2 = $(id_div).effect('opacity', {duration: 2000});
					imgEffect2.start(0).chain(function() {
						$(id_div).style.display = "none";
						busy = false;
					});*/
				});	
			}
		}
	}
}

function hideError(id_div) {
	if ($(id_div)) {
		busy = true;
		//$(id_div).style.display = "";
		//$(id_div).innerHTML 	= message;
		//$(id_div).innerHTML 	+= "<div style=\"position:absolute;right:1px;bottom:1px\"><a href=\"javascript:hideError()\" class=\"lien_erreur\">fermer</a></div>";
		var imgEffect = $(id_div).effect('opacity', {duration: 1500});
		imgEffect.start(0).chain(function() {					
			$(id_div).style.display = "none";
			busy = false;
			/*var imgEffect2 = $(id_div).effect('opacity', {duration: 2000});
			imgEffect2.start(0).chain(function() {
				$(id_div).style.display = "none";
				busy = false;
			});*/
		});	
		
		if (id_div == "message_available") {
			if ($("message_available_2")) {
				busy = true;
				var imgEffect = $("message_available_2").effect('opacity', {duration: 1500});
				imgEffect.start(0).chain(function() {					
					$("message_available_2").style.display = "none";
					busy = false;							
				});	
			}
		}
	}
}

function checkMeal() {
	flag_recalcul = false;
	$$(".tablemeal").each(function(el) {	
		if (el.type.indexOf("select") != -1) {
			var acc = $("choix_accomodation").value;
			if (el.id == "meal_select_" + acc) {
				if ($("id_meal_selected").value.indexOf("," + el.value + ",") == -1) {
					flag_recalcul = true;					
				}
			}
		}	
	});
	
	if (flag_recalcul) {
		$("tdtotal").style.display = "none";
		$("btnrecalcul").style.display = "";
	} else {
		$("tdtotal").style.display = "";
		$("btnrecalcul").style.display = "none";
	}
}

function recalcul() {
	var total = 0;
	var flag_btn_recalcul = false;
	$$(".calcul").each(function(el) {				
		var valeur = el.value.replace(/,/g, "\.");
		
		if (!isNaN(valeur) && valeur != "") {
			if (el.id.indexOf("hid_") != -1) {
				//si champs selection user
				var tab = el.id.split("_");
				
				if (el.id.indexOf("accomodation") != -1) {					
					//on prend la valeur de la combo
					var acc = $("choix_accomodation").value;
					if (tab[2] + "" == acc + "") {
						total += parseFloat(valeur);
					}
				} else if (el.id.indexOf("beginaddon") != -1) {				
					if ($("begin_addon_" + tab[2] + "_" + tab[3])) {
						var addonselect = $("begin_addon_" + tab[2] + "_" + tab[3]).value;
						var addoncheck 	= false;
						var obj 		= $("addon_" + tab[2] + "_" + tab[3]);
						if (obj) {
							addoncheck = obj.checked;
						}
						obj 		= $("group_addon_" + tab[2]);
						if (obj) {
							addoncheck = addoncheck && obj.checked;
						}						
						
						var addonnb		= 0;
						if (tab[5] == "Person") {
							var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_person");
							if (obj) {
								addonnb += parseInt(obj.value, 10);
							}
							var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_adult");
							if (obj) {
								addonnb += parseInt(obj.value, 10);
							}
							var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_child");
							if (obj) {
								addonnb += parseInt(obj.value, 10);
							}
							var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_infant");
							if (obj) {
								addonnb += parseInt(obj.value, 10);
							}
						} else {
							var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_" + tab[5]);
							if (obj) {
								addonnb = parseInt(obj.value, 10);
							}
						}
						
						if (addoncheck) {						
							if (tab[4] + "" == addonselect + "") {
								total += parseFloat(valeur) * addonnb;
								var objlib = $("px_addon_" +  tab[2] + "_" + tab[3]);
								if (objlib) {
									objlib.innerHTML = (parseFloat(valeur) * addonnb).toFixed(2) + " &euro;";
								}
							} else {
								var objlib = $("px_addon_" +  tab[2] + "_" + tab[3]);
								if (objlib) {
									objlib.innerHTML = "&euro;";
								}
							}
						} else {
							var objlib = $("px_addon_" +  tab[2] + "_" + tab[3]);
							if (objlib) {
								objlib.innerHTML = "&euro;";
							}
						}
					}
				} else if (el.id.indexOf("hid_addon_") != -1) {
					if (!$("begin_addon_" + tab[2] + "_" + tab[3])) {
						var addoncheck 	= "";
						var obj 		= $("addon_" + tab[2] + "_" + tab[3]);
						if (obj) {
							addoncheck = obj.checked;
						}
						obj 		= $("group_addon_" + tab[2]);
						if (obj) {
							addoncheck = addoncheck && obj.checked;
						}
						
						var addonnb		= 0;
						var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_person");
						if (obj) {
							addonnb += obj.value;
						}
						var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_adult");
						if (obj) {
							addonnb += obj.value;
						}
						var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_child");
						if (obj) {
							addonnb += obj.value;
						}
						var obj		= $("part_addon_" + tab[2] + "_" + tab[3] + "_infant");
						if (obj) {
							addonnb += obj.value;
						}						
						
						if (addoncheck) {
							total += parseFloat(valeur) * addonnb;
							var objlib = $("px_addon_" +  tab[2] + "_" + tab[3]);
							if (objlib) {
								objlib.innerHTML = (parseFloat(valeur) * addonnb).toFixed(2) + " &euro;";
							}																			
						} else {
							var objlib = $("px_addon_" +  tab[2] + "_" + tab[3]);
							if (objlib) {
								objlib.innerHTML = "&euro;";
							}
						}
					}
				}
			} else if (el.id.indexOf("hidcat_") != -1) {
				//si element unitaire / categorie
				var tab = el.id.split("_");
				if (tab[2] && tab[3]) {
					var id_champs = tab[2] + "_" + tab[3];
					if ($("cat_" + id_champs)) {
						if ($("cat_" + id_champs).checked) {
							total += parseFloat(valeur);
						}
					}
				}
			} else {
				//sinon on ajoute tltemps				
				total += parseFloat(valeur);
			}
		} else if (valeur == "") {
			//on a pas le prix d'un element pouvant jouer sur le prix final
			if (el.id.indexOf("obligatoire") == -1) {
				var tab = el.id.split("_");
				
				if (el.id.indexOf("hid_addon_") != -1) {
					var addoncheck 	= "";
					var obj 		= $("addon_" + tab[2] + "_" + tab[3]);
					if (obj) {
						addoncheck = obj.checked;
					}
					obj 		= $("group_addon_" + tab[2]);
					if (obj) {
						addoncheck = addoncheck && obj.checked;
					}
					
					if (addoncheck) {						
						flag_btn_recalcul = true;
					}
				} else if (el.id.indexOf("accomodation") != -1) {					
					//on prend la valeur de la combo
					var acc = $("choix_accomodation").value;
					if (tab[2] + "" == acc + "") {
						flag_btn_recalcul = true;
					}
				}
			}
		}
	});
	
	if (flag_btn_recalcul) {
		$("tdtotal").style.display = "none";
		$("btnrecalcul").style.display = "";
	} else {
		if (!isNaN(total)) {
			$("thetotal").innerHTML = total.toFixed(2) + " &euro;";
			$("totalflux").value = total.toFixed(2);
			impactePrix();
		}
		
		$("btnrecalcul").style.display = "none";
		$("tdtotal").style.display = "";		
	}
}

function checkFils(obj) {
	var flag = false;
	if (obj.checked) {
		flag = true;
	} 
	
	var tab 	= new Array();
	var indice 	= 0;
	
	$$(".addonfils").each(function(el) {
		var tmp = el.id;				
		if (tmp.indexOf("_" + obj.value + "_") != -1) {
			tab[indice] = el.id;
			indice++;
		}
	});	
	
	if (tab.length == 1) {			
		document.getElementById(tab[0]).checked = flag; 
	}
}

function checkParent(obj) {
	if (obj.checked) {
		var tab = obj.id.split("_");
		var objParent = $("group_addon_" + tab[1]);
		if (objParent) {
			objParent.checked = true;
		}
	}
}

function plierDeplier(div){
	if($(div).style.display == 'none')
	{
		$('img_'+div).src = "./images/moins_nav.gif";
		showDiv(div);
	}
	else
	{
		$('img_'+div).src = "./images/plus_nav.gif";
		hideDiv(div);
	}
}

function recalculQuote() {
    showLoading('');
    
    $('form_sejour').type_requete.value = "quotation";
    $('form_sejour').set('send', {
    	evalScripts:true,
    	onComplete: function(response) { 
         	hideLoading('');
    	}
    });
    
    //Send the form.
    $('form_sejour').send();
}

function reinitClassRoom() {
	$$(".room").each(function(el) {				
		el.style.color = "";
	});	
}

function reloadformCheckPaiement(){
	var myCheck = new FormCheck('formVoyageurs', {
		submitByAjax: true,	
		ajaxEvalScripts: true,			
		display : {
			showErrors : 1,
            indicateErrors : 1,
            indicateErrorsInit : 0,
            checkValueIfEmpty : 0,
            scrollToFirst : true
        },
        alerts : {
            required : 'This field is ablolutely required! Please enter a value'
        },
        onAjaxRequest : function(res) {
        	$("reponseTmp").innerHTML = "";	
        	showLoading();
        },
        onAjaxSuccess : function(res) {
        	hideLoading();
        	$("reponseTmp").innerHTML = res;
        	$('CBForm').dispose();
        }
    });
}
function inscriptionVoyageur(idAdelya, nomAdelya){
	var inscriptionVoyageur = new Request.HTML({url:'ajax/inscriptionVoyageur.php?idAdelya='+idAdelya+'&nomAdelya='+nomAdelya, 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('inscriptionVoyageur').set('text', '');
			//Inject the new DOM elements into the results div.
			$('inscriptionVoyageur').adopt(html);
			//Validation du formulaire de choix_passagers
			
			var myCheck = new FormCheck('formVoyageurs', {
				submitByAjax: true,	
				ajaxEvalScripts: true,			
				display : {
					showErrors : 1,
		            indicateErrors : 1,
		            indicateErrorsInit : 0,
		            checkValueIfEmpty : 0,
		            scrollToFirst : true
		        },
		        alerts : {
		            required : 'This field is ablolutely required! Please enter a value'
		        },
		        onAjaxRequest : function(res) {
		        	$("reponseTmp").innerHTML = "";	
		        	showLoading();		        	
		        },
		        onAjaxSuccess : function(res) {
		        	hideLoading();
		        	$("reponseTmp").innerHTML = res;
		        	//$('CBForm').dispose();
		        }
		    });
		    Sexy = new SexyAlertBox();			
		},
		onFailure: function() {
			$('inscriptionVoyageur').set('html', 'The request failed.');
		},
		onRequest : function () {					
				
			}		
	});
	inscriptionVoyageur.send();
}

function showGoBanque() {
	if ($("action_form")) {
		$("rqpaiement").action = $("action_form").value;
		$("action_form").value = "";		
		$("rqpaiement").submit();
	}	
}

function markErreur(lib) {
	if (document.getElementById(lib)) {
		document.getElementById(lib).style.color = "#FF0000";
	}
}

function getCategorieAddons(param) {
	var obj = $("cat_" + param);
	
	if (obj) {
		var obj_add = $("tr_grpaddon_" + param);
		if (obj_add) {
			if (obj.checked) {
				obj_add.style.display = "";
			} else {
				obj_add.style.display = "none";
			}
		}
	}				
}

function impactePrix() {
	var prix = parseFloat($("totalflux").value);
	
	//code promo
	if ($("coupon_value").value != "") {
		var valcoupon = parseFloat($("coupon_value").value);
		var valunit = $("coupon_unit").value;
		var prixpromo = 0;
		
		if (valunit == "percent") {
			prixpromo = prix * (valcoupon/100);			
		} else {
			prixpromo = valcoupon;
		}
		
		prix -= parseFloat(prixpromo);	
		$("htmlpromo").innerHTML = prixpromo.toFixed(2) + " &euro;";
			
	}
	
	if (prix < 0) {
		prix = 0;
	}
	
	//assurance
	var obj = $("form_sejour").id_assurance;
	if (obj) {
		var valeur = "";
		for (var i=0; i<obj.length; i++) {
			if (obj[i].checked) {
				valeur = obj[i].value;
			}
		}
		
		var objPrix = $("ass_" + valeur);
		if (objPrix) {			
			prix += parseFloat(objPrix.value);
		}				
	}
	
	//frais dossier
	prix += parseFloat($("frdossossier").value);
	
	$("thetotal").innerHTML = prix.toFixed(2) + " &euro;";
}

function retourProduit() {
	$("form_retour").submit();
}

function checkCodePromo() {
	if ($("code_promo")) {
		var promo = new Request.HTML({url:'ajax/check_code_promo.php?code=' + $("code_promo").value, 
			evalScripts: true,
			onSuccess: function(html) {
				hideLoading('');
				impactePrix();
			},
			onFailure: function() {
				hideLoading('');
			},
			onRequest : function () {
				$("htmlpromo").innerHTML = '';
				$('coupon_value').value = '';
				$('coupon_unit').value = '';					
				showLoading('');
			}		
		});
		promo.send();
	}
}
function getSejourHp() {
	var num = $("cpthp").value;
	if ($("idhp_" + num)) {
		showLoading('');
		location.href = 'detail.php?id_sejour='+$("idhp_" + num).value+'&pg=1&toCountryCode='+$("paysDesthp_" + num).value+'&fromCityCode='+$("villehp_" + num).value+'&date='+$("datehp_" + num).value+'&nbSejour='+getNbSejour('form_filtre');
	}
}
function chargePush(num) {
	if ($("vhp_" + num)) {http://localhost/carlson_adp/resultat.php?last_filtre=filtre_pays&nbSejour=1510&pg=1&sortBy=&fromCityCode=!XXX&toCountryCode=TN&filtre_region=&toCityCode=&filtre_jours=&filtre_mois=&departureDayRange=&filtre_formule=&filtre_prix=&filtre_duree=
		$("pushprincipalabs").style.backgroundImage = "url(" + $("vhp_" + num).value + ")";
		$("pxpush").innerHTML = $("pxhp_" + num).value;
		$("libpush").innerHTML = $("libhp_" + num).value;
		$("cpthp").value = num;
	}
}
function redirigeCoordonnees() {
	$("form_redirect").submit();
}
function reinitChampsClasses() {
	$$(".champs").each(function(el) {				
		el.className = "champs";
	});
}
function visuOptions() {
	if ($("taboptionssup")) {
		if ($("taboptionssup").style.display == "none") {
			$("taboptionssup").style.display = "";
			$("spanoptionssup").innerHTML = "&gt;&gt; Cacher les options suppl&eacute;mentaires";
		} else {
			$("taboptionssup").style.display = "none";
			$("spanoptionssup").innerHTML = "&gt;&gt; Voir les options suppl&eacute;mentaires";
		}
	}
}
function redirectModule(module) {
	/*document.location.href = "http://www.voyages-aeroportsdeparis.com/";*/
	switch (module) {
		case "vol":
			document.location.href = "http://www.voyages-aeroportsdeparis.com/vol/vols.php";
		break;
		case "hotel":
			document.location.href = "http://www.voyages-aeroportsdeparis.com/hotel/hotels.php";
			break;
		case "voiture":
			document.location.href = "http://www.voyages-aeroportsdeparis.com/voiture/voiture.php";
			break;
		case "volhotel":
			document.location.href = "http://www.voyages-aeroportsdeparis.com/forfait/weekends.php";
			break;
		case "sejours":
			document.location.href = "http://www.voyages-aeroportsdeparis.com/sejour/";
			break;
	}
}
function submitForm3Dsecure(form,url,pareq,urlretour,md){
	$(form).action = url;
	$('PaReq').value = pareq;
	$('TermUrl').value = urlretour;
	$('MD').velue = md;
	$(form).submit();
}
function submitNewsletter() {
	$("formnews").submit();
}
function resetChamps(obj, valdefaut) {
	if (obj.value == valdefaut) {
		obj.value = "";
	}
}
function imprime() {
	if (typeof(window.print) != 'undefined')
	{ window.print(); }
}
function bloqueCtrlV(evt) {	
	if(evt.ctrlKey) {
		//Touche v ou V enfoncée
		if((evt.keyCode == 86) || (evt.keyCode == 118)) { 
			evt.returnValue = false;
		}
	}	
}