
function static_var( name,cat,value ) {

    switch (name) {
	 case 'nb_page':
		  if ( typeof this.nb_page == 'undefined' ) this.nb_page = [];
   
		 if (value == 'false'){
		  	return this.nb_page[cat];
		 }else{
		 	this.nb_page[cat]=value;
		 }
	 break;
	 
	 case 'i':
		if ( typeof this.i == 'undefined' ) this.i = [];
		if (value == 'false'){
		  	return this.i[cat];
		 }else if(value == 'more'){
		 	this.i[cat]++;
		 	//return this.i[cat];
		 }else if(value == 'less'){
		 	this.i[cat]--;
		 }else{
		 	this.i[cat]=value;
		 }
	 break;
	 
	 case 'y':
		 if (value == 'false'){
		  	return this.y[cat];
		 }else if(value == 'more'){
		 	this.y[cat]++;
		 	//return this.i[cat];
		 }
	 break;
	 
	 default: 
	
	 break;
	}
    
    

} // end of 'testStaticMultiple()'


function display_list_widget(cat, url)
{
	
	$.get(url,{ nb_rows: 0 , cat: cat, action: 'count'}, function(count){
		
		nb_post = count;
		nombre_page= Math.ceil(nb_post / 3);
		static_var('nb_page',cat,nombre_page)
		nb_rows=0;
		static_var('i',cat,1);
		
		$.get(url, { nb_rows: nb_rows, cat: cat}, function(data){
			$("#contenue-module-" + cat).empty(); // on vide le div
			$("#contenue-module-" + cat).append(data);
			$("#" + cat + "1").fadeIn(200);
		});
		
		$("#" + cat + "-fleche-haut").hide();
		
		if (nb_post <= 3){$("#" + cat + "-fleche-bas").hide();}
		
		
		jQuery().ready(function(){
		
			$("#" + cat + "-fleche-bas").click(function(){
				
				x = static_var('i',cat,'false');
				y = x + 1;
				$("#" + cat + x).hide(200);
				$("#" + cat + y).fadeIn(300);
				static_var('i',cat,'more')
				nbr_page = static_var('nb_page',cat,'false');
				if (y >= nbr_page){$("#" + cat + "-fleche-bas").hide();}
				$("#" + cat + "-fleche-haut").show();
				
			});
			
			$("#" + cat + "-fleche-haut").click(function(){
				
				x = static_var('i',cat,'false');
				y = x - 1 ;
				$("#" + cat + y).slideDown(300);
				$("#" + cat + x).hide(100);
				static_var('i',cat,'less')
				if (y == 1){$("#" + cat + "-fleche-haut").hide();}
				$("#" + cat + "-fleche-bas").show();
			});
		
		});
	});	
}
