function doCouche() {
  var postdata = {};
  $("input.Type,input.Couvre,input.Taille,input.Matiere,input.Attache,input.Lieu").each(function(i){
    if (this.checked) {
	    postdata[this.name] = this.value;
    }
  });
  $.post("couches_ajax.html", postdata,
		function(data){
			//alert(data);
			var TypeArray = Array();
			$.each(data.Type, function (i,item){
				TypeArray[i++] = item;
			});
			$('input.Type').each(function() {
				if (TypeArray.in_array(this.value))
				{
					this.disabled = false;
					this.nextSibling.className = 'enable';
				}
				else
				{
					this.disabled = true;
					this.checked = false;
					this.nextSibling.className = 'disable';
				}
			});

			var CouvreArray = Array();
			$.each(data.Couvre, function (i,item){
				CouvreArray[i++] = item;
			});
			$('input.Couvre').each(function() {
				if (CouvreArray.in_array(this.value))
				{
					this.disabled = false;
					this.nextSibling.className = 'enable';
				}
				else
				{
					this.disabled = true;
					this.checked = false;
					this.nextSibling.className = 'disable';
				}
			});

			var TailleArray = Array();
			$.each(data.Taille, function (i,item){
				TailleArray[i++] = item;
			});
			$('input.Taille').each(function() {
				if (TailleArray.in_array(this.value))
				{
					this.disabled = false;
					this.nextSibling.className = 'enable';
				}
				else
				{
					this.disabled = true;
					this.checked = false;
					this.nextSibling.className = 'disable';
				}
			});

			var MatiereArray = Array();
			$.each(data.Matiere, function (i,item){
				MatiereArray[i++] = item;
			});
			$('input.Matiere').each(function() {
				if (MatiereArray.in_array(this.value))
				{
					this.disabled = false;
					this.nextSibling.className = 'enable';
				}
				else
				{
					this.disabled = true;
					this.checked = false;
					this.nextSibling.className = 'disable';
				}
			});

			var AttacheArray = Array();
			$.each(data.Attache, function (i,item){
				AttacheArray[i++] = item;
			});
			$('input.Attache').each(function() {
				if (AttacheArray.in_array(this.value))
				{
					this.disabled = false;
					this.nextSibling.className = 'enable';
				}
				else
				{
					this.disabled = true;
					this.checked = false;
					this.nextSibling.className = 'disable';
				}
			});

			var LieuArray = Array();
			$.each(data.Lieu, function (i,item){
				LieuArray[i++] = item;
			});
			$('input.Lieu').each(function() {
				if (LieuArray.in_array(this.value))
				{
					this.disabled = false;
					this.nextSibling.className = 'enable';
				}
				else
				{
					this.disabled = true;
					this.checked = false;
					this.nextSibling.className = 'disable';
				}
			});
	}, "json");
	$.get("couches_get.html", postdata, function(resultat) {
		$("#ResultDiv").html(resultat);
	});
}

$(document).ready(function() {
  $("input.Type,input.Couvre,input.Taille,input.Matiere,input.Attache,input.Lieu").click( doCouche );
  doCouche();
});

