function serialization() {   
	criteres = $("form").serialize(); 
	$.post("recherche.php", criteres);
}

$(document).ready(function() {	
						   
    $.getJSON("ajax/populerType.php",{rubrique: 1, ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#GleType").html(options);						   
	  })					   
						   
$('#rechercheAvancee').hide();
$('#RechercheNbrRes').hide()
$('#RecherchePrix').hide();
$('#offreVente').hide();
$('#offreLocation').hide();
$('#demandeVente').hide();
$('#demandeLocation').hide();
$('a#showVenteOffre').click(function() {
  $('#offreLocation').hide('fast');
  $('#offreVente').show('slow');
  return false;
});

$('a#showLocationOffre').click(function() {
  $('#offreVente').hide('fast');
  $('#offreLocation').show('slow');
  return false;
});
  
$('a#showVenteDemande').click(function() {
  $('#demandeLocation').hide('fast');
  $('#demandeVente').show('slow');
  return false;
});

$('a#showLocationDemande').click(function() {
  $('#demandeVente').hide('fast');
  $('#demandeLocation').show('slow');
  return false;
});  

$('a#afficherRechercheAvancee').click(function() {
	$('#rechercheAvancee').show('slow');
  return false;
});

$('a#cacherRechercheAvancee').click(function() {
  $('#rechercheAvancee').hide('fast');
  return false;
});

$('a#afficherRecherchePrix').click(function() {
	$('#RecherchePrix').show('fast');
  return false;
});

$('input#cacherRecherchePrix').click(function() {
  $('#RecherchePrix').hide('slow');
  return false;
});

$('a#afficherRechercheNbrRes').click(function() {
	$('#RechercheNbrRes').show('fast');
  return false;
});

$('input#cacherRechercheNbrRes').click(function() {
  $('#RechercheNbrRes').hide('slow');
  return false;
});


});

$(function(){
  $("select#ctlPays").change(function(){
    $.getJSON("ajax/populerProvince.php",{pays_id: $(this).val(), ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#ctlProvince").html(options);
    })
  })
})

$(function(){
  $("select#ctlProvince").change(function(){
    $.getJSON("ajax/populerRegion.php",{province_id: $(this).val(), ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#ctlRegion").html(options);
    })
  })
})

$(function(){
  $("select#ctlRegion").change(function(){
    $.getJSON("ajax/populerVille.php",{region_id: $(this).val(), ajax: 'true'}, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#ctlVille").html(options);
    })
  })
});

function affmas(div)
{
	if(document.getElementById('in'+div).style.display=='none')
	{
		document.getElementById('in'+div).style.display = '';	
		document.getElementById('aff'+div).src = 'images/close.jpg';
	}
	else
	{
		document.getElementById('in'+div).style.display = 'none';
		document.getElementById('aff'+div).src = 'images/open.jpg';		
	}
}

function modifierValeurBase(valeur) {
	document.getElementById('critereBase').value = valeur;
}

function removeSpaces(string) {
 return string.split(' ').join('');
}

function modifierSelect() {
	var sel = document.getElementById("GleType");
	var verif = sel.options[sel.selectedIndex].value;
	appartementLAB = document.getElementById('appartement').value;
	maisonLAB = document.getElementById('maison').value;
		if (verif == 1) {
			document.getElementById('sousCatRecherche').style.visibility = "visible";
		} else {
			document.getElementById('sousCatRecherche').style.visibility = "hidden";
		}
}

