


// récupère les variables de recherche dans le formulaire et les envoie au serveur avec un httpXMLRequest
function sendVariablesLoc (sel) 
{
	
	var typeBien = document.getElementById('typeBienLoc');
    var nbrPieces = document.getElementById('nbrPiecesLoc');
	var localisation_Loc = document.getElementById('localisation_Loc');
	var loyer = document.getElementById('loyer');
	var criteresPlus = document.getElementById('criteresPlusLoc');
	
	
	// A priori aucun champ n'est obligatoire donc pas de validation a faire
   
   
	showProgressionLoc(); // load bar

	
	// convert (&, +, =) to string equivs. Needed so URL encoded POST won't choke.
	var str1 = typeBien.value;
	str1 = str1.replace(/&/g,"**am**");
	str1 = str1.replace(/=/g,"**eq**");
	str1 = str1.replace(/\+/g,"**pl**");
	var str2 = nbrPieces.value;
	str2 = str2.replace(/&/g,"**am**");
	str2 = str2.replace(/=/g,"**eq**");
	str2 = str2.replace(/\+/g,"**pl**");
    var str3 = localisation_Loc.value;
	str3 = str3.replace(/&/g,"**am**");
	str3 = str3.replace(/=/g,"**eq**");
	str3 = str3.replace(/\+/g,"**pl**");
	var str4 = loyer.value;
	str4 = str4.replace(/&/g,"**am**");
	str4 = str4.replace(/=/g,"**eq**");
	str4 = str4.replace(/\+/g,"**pl**");
    var str5 = criteresPlus.value;
	str5 = str5.replace(/&/g,"**am**");
	str5 = str5.replace(/=/g,"**eq**");
	str5 = str5.replace(/\+/g,"**pl**");

	var page = "scripts/xmlHttpRequest_loc.php";
	var variables = "typeBien="+str1+"&nbrPieces="+str2+"&localisation="+str3+"&loyer="+str4+"&criteresPlus="+str5+"&sel="+sel;
	
	

	loadXMLPosDocLoc(page,variables);
	
}


function showProgressionLoc () 
{
	var loader = document.getElementById('loadBarLoc');
	var frmEl = document.getElementById('cFormLoc');
	
	$("#loadBarLoc").fadeIn(200);
	
	//showResultatsLoc();
}



function ajaxRechercheLoc() 
{
	var frmEl = document.getElementById('cFormLoc');
	addEvent(frmEl, 'submit', sendVariablesLoc, false);
	frmEl.onsubmit = function() { return false; }
}


addEvent(window, 'load', ajaxRechercheLoc, false);
