$(document).ready(function() {
	var sel = null;
	if($('#quoiVente').attr('checked') == true) {
		sel = 1;
	} else if($('#quoiLocation').attr('checked') == true) {
		sel = 2;
	} else if($('#quoiService').attr('checked') == true) {
		sel = 3;
	} else {
		sel = 1;
		$('#quoiVente').attr('checked', 'checked');
	}
	if(sel) {
		MettreEnVert();
		$.getJSON("ajax/populerType.php",{rubrique: sel, 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#leType").html(options);
		});
	}
});

function MettreEnVert() {
	document.getElementById('leType').style.border = '1px solid green';
}

$(function(){
  $("input#quoiVente").click(function(){
	MettreEnVert();
    $.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#leType").html(options);
    })
  })
})

$(function(){
  $("input#quoiLocation").click(function(){
	MettreEnVert();										 
    $.getJSON("ajax/populerType.php",{rubrique: 2, 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#leType").html(options);
    })
  })
})

$(function(){
  $("input#quoiService").click(function(){
    $.getJSON("ajax/populerType.php",{rubrique: 3, ajax: 'true'}, function(j){
	MettreEnVert();																		   
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#leType").html(options);
    })
  })
})


$(function(){
  $("input#GquoiVente").click(function(){
	MettreEnVert();
    $.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);
    })
  })
})

$(function(){
  $("input#GquoiLocation").click(function(){
	MettreEnVert();										 
    $.getJSON("ajax/populerType.php",{rubrique: 2, 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);
    })
  })
})

$(function(){
  $("input#GquoiService").click(function(){
    $.getJSON("ajax/populerType.php",{rubrique: 3, ajax: 'true'}, function(j){
	MettreEnVert();																		   
      var options = '';
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#GleType").html(options);
    })
  })
})

