function listObjetHome(){
	$.ajax({
		type: 'POST',
		data: 'noMenu=1',
		url: '/objets/command.php/objet/listHome',
		cache: false,
	
		success: function(html){
			$("#list-home").html(html);
		}
	});	
}

function listObjetImmo(model){
	$.ajax({
		type: 'POST',
		data: 'noMenu=1&model='+model,
		url: '/objets/command.php/objet/listObjet',
		cache: false,
	
		success: function(html){
			$("#"+model).html(html);
		}
	});	
}

function getDossier(id_objet){
	
	$.ajax({
		type: 'POST',
		data: 'noMenu=1&id_objet=' + id_objet,
		url: '/objets/command.php/objet/getForm',
		cache: false,
	
		success: function(html){
			$("BODY").prepend(html);
		}
	});
}

function deleteFrom(){
	$("#formGetDossier").remove();	
}

function sendDossier(){
	email = $("#email").val();
	message = $("#message").val();
	id_objet = $("#id_objet").val();
	
	$.ajax({
		type:'POST',
		url: '/objets/command.php/objet/demandeDossier',
		cache: false,
		dataType: 'json',
		data: 'email=' + email + '&message=' + message + '&id_objet=' + id_objet,
		success: function(data){
			
			// On détecte si des erreurs
			if(data.error == "yes"){
				$("#msgError").html("Adresse E-Mail non valide");
				$("#msgError").fadeIn("slow");
			}
			else{
				$("#msgError").fadeOut("slow", function(){
					$("#ctnForRemerciements").html("<span style='text-align:center;'>" + data.message + "</span>");
				});
			}
		}
	},"json");	
}

$(document).ready(function() {
	if($("#list-home").length>0){
		listObjetImmo("list-home");
	}
	
	if($("#list-prestige").length>0) listObjetImmo("list-prestige");
	if($("#list-promo").length>0) listObjetImmo("list-promo");
	if($("#list-location").length>0) listObjetImmo("list-location");	
	
});

