function SetCriteriaResultatProduits(){
	var strCriteriaResultatProduits = "";
	var dpci = document.getElementById("dpciDepartDe").value;
	var forfaitVol = document.getElementById("hpfvDepartDe").value;
	var formule = document.getElementById("hpfoDepartDe").value;
	var typeVol = document.getElementById("hptvDepartDe").value;
	var destination = document.getElementById("hpdeDepartDe").value;
	var dd = document.getElementById("ddDepartDe").value;
	var dmy = document.getElementById("dmyDepartDe").value;
	var aj = document.getElementById("ajDepartDe").value;
	strCriteriaResultatProduits = "dpci="+dpci+"&c.hpfv="+forfaitVol+"&c.hpfo="+formule+"&c.hptv="+typeVol+"&c.hpde="+destination+"&dd="+dd+"&dmy="+dmy+"&aj="+aj;
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', strCriteriaResultatProduits);
}
function setVolCriteria(dpci,hpde,hpfo,hpfv){
	var url = "";
	if(hpfo == ""){
		url = "dpci="+dpci+"&c.hpde="+hpde+"&c.hpfv=vo";
	}
	if(hpde == ""){
		url = "dpci="+dpci+"&c.hpfo="+hpfo+"&c.hpfv=vo";
	}
	if(dpci == ""){
		url = "c.hpde="+hpde+"&c.hpfo="+hpfo+"&c.hpfv=vo";
	}
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', url);
}

function RemoveCritereVoyage(url,critere,critereCode){
	var url = url;
	var strCritere = "";
	if(url.indexOf("fin=")>-1){
		url = url.replace(RegExp("fin="),"");
	}
	if(url.indexOf("lin=")>-1){
		url = url.replace(RegExp("lin="),"");
	}
	if(critere != ""){
		if(critere == "c.hpfo"){
			var CritereLabel = "";
			var id = "";
			if(critereCode == "cl") CritereLabel = "clubs";
			if(critereCode == "ci") CritereLabel = "circuits";
			if(critereCode == "se") CritereLabel = "sejours";
			if(critereCode == "au") CritereLabel = "autotours";
			if(critereCode == "pe") CritereLabel = "periples";
			if(critereCode == "vo") CritereLabel = "vols-secs";
			if(critereCode == "ho") CritereLabel = "hotels";
			if(critereCode == "lo") CritereLabel = "locations";
			if(critereCode == "cr") CritereLabel = "croisieres";
			id="mi_"+critereCode;
			Out(document.getElementById(id),CritereLabel,'/CS/images');
		}
		if(critereCode.indexOf("*") > -1){
			critereCode = critereCode.substring(0,critereCode.indexOf("*"));
			url = url.replace(/\*/,"");
			strCritere = critere + "=" + critereCode;
			url = url.replace(RegExp(strCritere),critere+"=");
		}
		if(critereCode.indexOf(",") > -1){
			var secondString = url.split(critere+"=")[1];
			var stroldCode = secondString.substring(0, secondString.indexOf("&"));
			strCritere = critere + "=" + stroldCode;
			url = url.replace(RegExp(strCritere),critere+"=");
		}
		strCritere = critere + "=" + critereCode;
		url = url.replace(RegExp(strCritere),critere+"=");
	}
	if(critere == ""){
		url = "dd=&dmy=&aj=&dpci=&c.hpde=&c.hpfo=&mmp=&c.hpth=&minMan=&c.hpco=&c.hppe=&VacScolaires=";
		if(critereCode!=""){
		if(critereCode == "cl") CritereLabel = "clubs";
		if(critereCode == "ci") CritereLabel = "circuits";
		if(critereCode == "se") CritereLabel = "sejours";
		if(critereCode == "au") CritereLabel = "autotours";
		if(critereCode == "pe") CritereLabel = "periples";
		if(critereCode == "vo") CritereLabel = "vols-secs";
		if(critereCode == "ho") CritereLabel = "hotels";
		if(critereCode == "lo") CritereLabel = "locations";
		if(critereCode == "cr") CritereLabel = "croisieres";
		id="mi_"+critereCode;
		Out(document.getElementById(id),CritereLabel,'/CS/images');
		}
	}
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', url);
}

function RemoveDate(url){
	var url = url;
	if(url.indexOf("fin=")>-1){
		url = url.replace(RegExp("fin="),"");
	}
	if(url.indexOf("lin=")>-1){
		url = url.replace(RegExp("lin="),"");
	}
	if(url.indexOf("dd") != -1){
		var array=url.split("dd=");
		if(array.length==1){
			var firstString = array[0];
			url=firstString;
		}else if(array.length>1){
			var firstString = array[0];

			var secondString = array[1];
			if(secondString.indexOf("=")>0){
			secondString = secondString.substring(secondString.indexOf("&"));
			}else{
			secondString="";
			}
			url=firstString+secondString;
		}

	}

	if(url.indexOf("dmy") != -1){

		var array=url.split("dmy=");
		if(array.length==1){
			var firstString = array[0];
			if(firstString.indexOf("&")>0){
			var month=firstString.substring(0,firstString.indexOf("&"));
			}else{
			var month=firstString;
			}
			url=firstString+"&month="+month;
		}else if(array.length>1){
			var firstString = array[0];

			var secondString = array[1];
			if(secondString.indexOf("&")>0){
			var month=secondString.substring(0,secondString.indexOf("&"));
			}else{
			var month=secondString;
			}
			if(secondString.indexOf("=")>0){
			secondString = secondString.substring(secondString.indexOf("&"));
			}else{
			secondString="";
			}
			url=firstString+secondString+"&month="+month;;
		}
	}
	url = url.replace(RegExp("&&&"),"&");
	url = url.replace(RegExp("&&"),"&");
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', url);
}
function AddCritereVoyage(url,critere,critereCode){
	var url = url;
	if(url.indexOf(critere) == -1){
		url += "&"+critere+"="+critereCode;
	}else{
		var strCritere = critere+"=";
		url = url.replace(RegExp(strCritere),strCritere+critereCode);
	}
	if(url.indexOf("fin=")>-1){
		url = url.replace(RegExp("fin="),"");
	}
	if(url.indexOf("lin=")>-1){
		url = url.replace(RegExp("lin="),"");
	}
	if(critere == "c.hpfo"){
		var CritereLabel = "";
		var id = "";
		if(critereCode == "cl") CritereLabel = "clubs";
		if(critereCode == "ci") CritereLabel = "circuits";
		if(critereCode == "se") CritereLabel = "sejours";
		if(critereCode == "au") CritereLabel = "autotours";
		if(critereCode == "pe") CritereLabel = "periples";
		if(critereCode == "vo") CritereLabel = "vols-secs";
		if(critereCode == "ho") CritereLabel = "hotels";
		if(critereCode == "lo") CritereLabel = "locations";
		if(critereCode == "cr") CritereLabel = "croisieres";
		id="mi_"+critereCode;
		Over(document.getElementById(id),CritereLabel,'/CS/images');
	}
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', url);
}
function AddDestinationCritereVoyage(url,critere,critereCode){
	var url = url;
	if(url.indexOf("fin=")>-1){
		url = url.replace(RegExp("fin="),"");
	}
	if(url.indexOf("lin=")>-1){
		url = url.replace(RegExp("lin="),"");
	}
	if(url.indexOf(critere) == -1){
		url += "&"+critere+"="+critereCode;
	}else{
		var array=url.split(critere+"=");
		if(array.length==1){
			var firstString = array[0];
			url=firstString+"&"+critere+"="+critereCode;
		}else if(array.length>1){
			var firstString = array[0];

			var secondString = array[1];
			if(secondString.indexOf("=")>0){
			secondString = secondString.substring(secondString.indexOf("&"));
			}else{
			secondString="";

			}
			url=firstString+secondString+"&"+critere+"="+critereCode;
		}

	}
	url = url.replace(RegExp("&&"),"&");
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', url);
}

function AddDateDepart(url,ddValue,dmyValue,ajValue){
	var url = url;
	if(url.indexOf("fin=")>-1){
		url = url.replace(RegExp("fin="),"");
	}
	if(url.indexOf("lin=")>-1){
		url = url.replace(RegExp("lin="),"");
	}
	if(url.indexOf("dd") == -1){
		url += "&dd="+ddValue;
	}else{
		var array=url.split("dd=");
		if(array.length==1){
			var firstString = array[0];
			url=firstString+"&dd="+ddValue;
		}else if(array.length>1){
			var firstString = array[0];

			var secondString = array[1];
			if(secondString.indexOf("=")>0){
			secondString = secondString.substring(secondString.indexOf("&"));
			}else{
			secondString="";
			}
			url=firstString+secondString+"&dd="+ddValue;
		}
	}

	if(url.indexOf("dmy") == -1){
		url += "&dmy="+dmyValue;
	}else{
		var array=url.split("dmy=");
		if(array.length==1){
			var firstString = array[0];
			url=firstString+"&dmy="+dmyValue;
		}else if(array.length>1){
			var firstString = array[0];

			var secondString = array[1];
			if(secondString.indexOf("=")>0){
			secondString = secondString.substring(secondString.indexOf("&"));
			}else{
			secondString="";
			}
			url=firstString+secondString+"&dmy="+dmyValue;
		}
	}


	if(url.indexOf("aj") == -1){
		url += "&aj="+ajValue;
	}else{
		var array=url.split("aj=");
		if(array.length==1){
			var firstString = array[0];
			url=firstString+"&aj="+ajValue;
		}else if(array.length>1){
			var firstString = array[0];

			var secondString = array[1];
			if(secondString.indexOf("=")>0){
			secondString = secondString.substring(secondString.indexOf("&"));
			}else{
			secondString="";
			}
			url=firstString+secondString+"&aj="+ajValue;
		}
	}
	url = url.replace(RegExp("&&&"),"&");
	url = url.replace(RegExp("&&"),"&");
	GetCartouchesProduits('/elements/resultat-produits-ajax.jsp', url);
}




var strUrlCartoucheProduit="";
// Debut Resultat Produits
function GetCartouchesProduits(pageName, params){
	xhResultatProduits = GetXmlHttpObject();
	if(xhResultatProduits == null){
		alert ("Votre navigateur ne supporte pas AJAX!");
  		return;
  	}
	var url = pageName + "?" + params ;
	strUrlCartoucheProduit=url;
	document.getElementById(ctResultatProduits).innerHTML = "<div style='padding-top:300px;'><center><img src='/CS/images/ajax-loader-big.gif' /></center>";
	xhResultatProduits.onreadystatechange = hdResultatProduits;
	xhResultatProduits.open("GET",url,true);
	xhResultatProduits.send(null);
	}
//String.prototype.trim = function() {return this.replace(/^\s+/, '').replace(/\s+$/, '');}
function hdResultatProduits(){
	if(xhResultatProduits.readyState == 4){
		if(xhResultatProduits.status == 200){
			var response;
			response = xhResultatProduits.responseText;
			document.getElementById(ctResultatProduits).innerHTML = response;

			try{
				eval(document.getElementById('script_flash').innerHTML);
			}catch(ex){
				// Image is not flash, script was not written in JSP and will not be executed
			}
			var nbProducts = document.getElementById("IdProd").value;
			for (var ix=1; ix<nbProducts; ix++) {
				if (document.getElementById('dispo_script_'+ix)) {
					var sMyScript = document.getElementById('dispo_script_'+ix).innerHTML;
					sMyScript = sMyScript.replace(/<\/script>/, "//End script");
					sMyScript = sMyScript.replace(/<script/, "//Start script");
					try{
						eval(sMyScript);
					}catch(ex){
					}
				}
			}
			try{
				eval(document.getElementById('periodeDepart').innerHTML);
			}catch(ex){}
			hiddenAffinezRecherche();
		}else{
			//alert("An error has occured.");
		}
	}
}
// Fin Resultat Produits


function ShowCritere(crit){
		var critere = document.getElementById(crit);
		for (var i = 1; i <= 8; i++){
			if (document.getElementById('critere'+i)){
				document.getElementById('critere'+i).style.display = 'none';
			}
		}
		if (critere){
			critere.style.display = '';
		}
		return false;
	}

function hiddenAffinezRecherche(){
	if(document.getElementById('criteres-selectionnes')){
		var criteresContent=document.getElementById('criteres-selectionnes').innerHTML;
		criteresContent=criteresContent.trim();
		if(criteresContent==""){
			document.getElementById("filtrage").style.display='none';
			document.getElementById("critereLine").style.display='none';

		}
	}

}
