$(document).ready(function() {
 $("#liste_caddy").hide();
 

 $.post("traitement_lastviewed.asp",{operation : "liste"},function(data){
     
	   if(data!="vide"){
	     $("#conteneur_annonce").append(data);  
		 $("#liste_caddy").slideDown();
	   }
       });
 
 //$("a[id^='ajout_caddy']").click(function(){
    numann = $("a[id^='ajout_caddy']").attr("name");
	if(numann!=""){
	//alert(numann);
    $.post("traitement_lastviewed.asp",{numann :  numann, operation : "ajout"},function(data){
	   /*if(data!="erreur"){
	    $('html,body').animate({scrollTop: 0}, 'slow');
	    if($("#liste_caddy").is(":hidden")){
		   $("#liste_caddy").slideDown();
         }		
	    $("#conteneur_annonce").append(data);  */
	   
	   
	});
	}
 /* return false;
}
);*/


$("a[id^='delete_caddy']").live('click',function(){
  
    numann = $(this).attr("name");
    $.post("traitement_lastviewed.asp",{numann :  numann, operation : "retire"},function(data){
	    //alert($("div[name^='bloc_annonce']").length);
	   if(data!="erreur"){
	    $("div[id="+numann+"]").fadeOut().remove();
		if($("div[name^='bloc_annonce']").length==0){
		   $("#liste_caddy").slideUp();
		}
	   }
	   
	});
  return false;
}
);



});


