﻿<SCRIPT LANGUAGE="JavaScript" type="text/javascript"> 
function majListe(item,inputText,txtDefaut) {
	
	if (item.checked==false) {item.checked=true;} else {item.checked=false;}

	if (inputText.value == unescape(txtDefaut)) {inputText.value = '';}
					
	if (getID(item.id).checked == true) {
		inputText.value += ', ' + getID('hidden'+item.id).value;
	}
	else {
		inputText.value = inputText.value.replace(getID('hidden'+item.id).value + ', ','');
		inputText.value = inputText.value.replace(', ' + getID('hidden'+item.id).value ,'');
		inputText.value = inputText.value.replace(getID('hidden'+item.id).value ,'');
	}
	if (inputText.value.substring(0,2) == ', ') {inputText.value = inputText.value.substring(2, inputText.value.length);}
	if (inputText.value == '') {inputText.value = unescape(txtDefaut);}
}
// ======================================================================================================================================
function majListeUnique(item,inputText,txtDefaut) {
	
	var coche;
	if (item.checked==false) {coche=1;} else {coche=0;}
	
	var longueur_prop_prefix;//fix mantis 317
	longueur_prop_prefix = item.id.indexOf('_');
	if (longueur_prop_prefix <= 0) {
		longueur_prop_prefix = 6;//ancienne valeur
	}
	
	for (cpt=1; cpt < document.rechannonce.length; cpt++) {
		if (document.rechannonce[cpt].name) {
			if (document.rechannonce[cpt].name.substr(0,longueur_prop_prefix) == item.id.substr(0,longueur_prop_prefix)) {
				document.rechannonce[cpt].checked = false;
			}
		}
	}
	if (coche==1) {
		item.checked=true;
		inputText.value = getID('hidden'+item.id).value;
	} else {
		item.checked=false;
		inputText.value = unescape(txtDefaut);
	}
}
// ======================================================================================================================================
function supprCrit(item,inputText) {
	inputText.value = inputText.value.replace(getID('hidden'+item.id).value + ', ','');
	inputText.value = inputText.value.replace(', ' + getID('hidden'+item.id).value ,'');
	inputText.value = inputText.value.replace(getID('hidden'+item.id).value ,'');
}
// ======================================================================================================================================
function supprPaysLoca(exception) {
	for (cpt=1; cpt < document.rechannonce.length; cpt++) {
		if (document.rechannonce[cpt].id) {
			idElement = document.rechannonce[cpt].id;
			if (idElement.substr(0,9) == 'paysloca_') {
				if (idElement != exception.id) {
					getID(idElement).checked = false;
				}
			}
		}
	}
	getID('boxpaysloca').value = '';
}
// ======================================================================================================================================
function razListe(item, inputText, txtDefaut) {
	if (item.checked==false) {
		item.checked=true;
	
		for (cpt=1; cpt < document.rechannonce.length; cpt++) {
			if (document.rechannonce[cpt].name) {
				
				if (document.rechannonce[cpt].name.substr(0) == item.id.substr(0)) /*fix mantis 317, suppr borne supérieure (6) */{
					document.rechannonce[cpt].checked = false;
				}
			}
		}
		
		inputText.value = unescape(txtDefaut);
	}
	else {
		item.checked=false;
	}
}
// ======================================================================================================================================
function majPrix (valeur,inputText,valeurDefaut) {
	if (valeur != '') {		
		getID(inputText).value = valeurDefaut + ' : ' + valeur;
	}
	else {
		getID(inputText).value = valeurDefaut 
	}
}
// ======================================================================================================================================
function cacheOptions() {
	if (navigator.appVersion.indexOf('MSIE 6') > 0) {
		getID('tri').style.visibility = 'hidden';	
		getID('affPhotos').style.visibility = 'hidden';	
		getID('affNbAnn').style.visibility = 'hidden';
	}
}
// ======================================================================================================================================
function afficheOptions() {
	if (navigator.appVersion.indexOf('MSIE 6') > 0) {
		getID('tri').style.visibility = 'visible';	
		getID('affPhotos').style.visibility = 'visible';	
		getID('affNbAnn').style.visibility = 'visible';
	}
}
// ======================================================================================================================================
function checkTypeRech() {
	 if (getID('typeRech').value=='a') {
	 	// Recherche avancée
	 	getID('separAv').style.display = 'block';
		getID('divRechAvancee').style.display = 'block';
		getID('divTitreRechLoca').style.display = 'block';
		getID('divRechCrit').style.display = 'block';
		getID('divLienPlus').style.display = 'none';
		getID('divLienMoins').style.display = 'block';
		getID('divLienSimple').style.display = 'none';
	}
	else {
		// Recherche simple
		getID('divLienPlus').style.display = 'block';
		getID('divLienMoins').style.display = 'none';
		getID('divLienSimple').style.display = 'none';
	}
	// Recherche géo ou non
	if (getID('typeRechLoca').value=='1') {
		getID('separLoca').style.display = 'block';
	 	getID('divLoca').style.display = 'block';
		getID('divTitreRechLoca').style.display = 'block';
		getID('divRechLoca').style.display = 'block';
		getID('divLienLoca').style.display = 'none';
		getID('divLienSimple').style.display = 'block';
	}
	else {
		getID('divLoca').style.display = 'none';
		getID('divTitreRechLoca').style.display = 'none';
		getID('divRechLoca').style.display = 'none';
		getID('divLienLoca').style.display = 'block';
	}
	redimCacheurDivs();
}
// ======================================================================================================================================
function affDivRechAvancee() {
	getID('separAv').style.display = 'block';
	getID('divRechAvancee').style.display = 'block';
	getID('divRechCrit').style.display = 'block';
	getID('divLienMoins').style.display = 'block';
	getID('divLienPlus').style.display = 'none';
	getID('typeRech').value='a';
}
// ======================================================================================================================================
function cacheDivRechAvancee() {
	getID('separAv').style.display = 'none';
	getID('divRechAvancee').style.display = 'none';
	getID('divRechCrit').style.display = 'none';
	getID('divLienMoins').style.display = 'none';
	getID('divLienPlus').style.display = 'block';
	getID('typeRech').value='s';
	videFormAvance();
}
// ======================================================================================================================================
function affDivLoca() {
	getID('separLoca').style.display = 'block';
	getID('divLoca').style.display = 'block';
	getID('divTitreRechLoca').style.display = 'block';
	getID('divRechLoca').style.display = 'block';
	getID('divLienLoca').style.display = 'none';
	getID('divLienSimple').style.display = 'block';
	
	if (getID('divRechAvancee').style.display == 'none') {
		getID('divLienPlus').style.display = 'block';
	}	
	getID('typeRechLoca').value='1';
}
// ======================================================================================================================================
function cacheDivLoca() {
	getID('separLoca').style.display = 'none';
	getID('divLoca').style.display = 'none';
	getID('divTitreRechLoca').style.display = 'none';
	getID('divRechLoca').style.display = 'none';
	getID('divLienLoca').style.display = 'block';
	getID('divLienSimple').style.display = 'none';
	getID('typeRechLoca').value='';
}
// ======================================================================================================================================
function cacheAutresDivs(exception) {
	tableDiv = document.getElementsByTagName('div')
	for (cpt=0; cpt<tableDiv.length; cpt++) {
		toto = cpt+''
		
		if (tableDiv[cpt].id.substr(0,7) == 'deroule') {
			if (tableDiv[cpt].id != exception) {
				if (tableDiv[cpt].style.display == 'block') {
					tableDiv[cpt].style.display='none';					
				}
			}
		}
	}
	if (exception == '') {afficheOptions();}
} 
// ======================================================================================================================================
function redimCacheurDivs() {
	getID('cacheurDivs').style.width = 660;
	if (getID('typeRech').value=='a' && getID('typeRechLoca').value=='1') {getID('cacheurDivs').style.height = 150;} else {getID('cacheurDivs').style.height = 100;}
}
// ======================================================================================================================================
function getID(id){
	return document.getElementById(id);
}
// ======================================================================================================================================
function videFormAvance() {
	//getID('boxpaysID').value = '<%=EncodeJS(AffTrad("", 1193, ""))%>';
	getID('boxpaysloca').value = '<%=EncodeJS(AffTrad("", 1195, ""))%>';
	getID('codePostal').value = '<%=EncodeJS(AffTrad("", 1196, ""))%>';
	getID('distanceMax').value = '<%=EncodeJS(AffTrad("", 1197, ""))%>';
	getID('boxcrit').value = '<%=EncodeJS(AffTrad("", 1240, ""))%>';
	
	for (cpt=1; cpt < document.rechannonce.length; cpt++) {
		if (!document.rechannonce[cpt].name) {
			// rien
		}		
		else {	
			if (document.rechannonce[cpt].name.substr(0,6) == 'paysID' || document.rechannonce[cpt].name.substr(0,8) == 'paysloca' || document.rechannonce[cpt].name.substr(0,5) == 'crit_') {
				document.rechannonce[cpt].checked = false;
			}
		}
	}
}
// ======================================================================================================================================
function videPays() {
	//getID('boxpaysID').value = '<%=EncodeJS(AffTrad("", 1193, ""))%>';
	for (cpt=1; cpt < document.rechannonce.length; cpt++) {
		if (!document.rechannonce[cpt].name) {
			// rien
		}		
		else {	
			if (document.rechannonce[cpt].name.substr(0,6) == 'paysID') {
				document.rechannonce[cpt].checked = false;
			}
		}
	}
}
// ======================================================================================================================================
function affDiv(id) {getID(id).style.display='block';}
function cachDiv(id) {getID(id).style.display='none';}
function isDivAff(id) {return (getID(id).style.display == 'block');}
</script>
