	var test=0;
	var com=new Array();
	var Acom=new Array();
	var Wcom=new Array();
	$(document).ready(function(){
	if(!test)
	{
		chargerBox(0,1);
		test=1; 
	}
	$( "#tabs" ).tabs({
	load: function(event, ui) {
		$('a', ui.panel).click(function() {
		$(ui.panel).load(this.href);
		return false;
		});
	}
	});
		
	});
	function chargerBox(type, page)
	{
		$.ajax
		({
			type: "POST",
			url: "modules/flux/flux_afficher.php",
			data: "type="+type+"&page="+page,
			dataType: "html",
			success: function(msg){
				$('#BoxFlux').html(msg);
			}
		});
	}
	
	function chargerBox(type, page, filtre)
	{
		$.ajax
		({
			type: "POST",
			url: "modules/flux/flux_afficher.php",
			data: "type="+type+"&page="+page+"&filtre="+filtre,
			dataType: "html",
			success: function(msg){
				$('#BoxFlux').html(msg);
			}
		});	
	}

	function chargerBox(type, page, keytype, keyword)	
	{
		com=new Array();
		Acom=new Array();
		Wcom=new Array();		
		$('#BoxFlux').html("<div style='text-align:center'><img src='modules/flux/style/images/loader.gif' /></div>");
		if(keytype!=undefined&&keyword!=undefined)
		{
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_afficher.php",
				data: "type="+type+"&page="+page+"&keytype="+keytype+"&keyword="+keyword,
				dataType: "html",
				success: function(msg){
					$('#BoxFlux').html(msg);
				}
			});
		}
		else if(keytype!=undefined&&keyword==undefined)
		{
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_afficher.php",
				data: "type="+type+"&page="+page+"&filtre="+keytype,
				dataType: "html",
				success: function(msg){
					$('#BoxFlux').html(msg);
				}
			});		
		}
		else
		{
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_afficher.php",
				data: "type="+type+"&page="+page,
				dataType: "html",
				success: function(msg){
					$('#BoxFlux').html(msg);
				}
			});		
		}		
	}
	
	function afficherComm(id, page)
	{
		if(com[id]==1)
		{
			$('#BoxComm'+id).hide();
			$('#flux_footer'+id).hide();
			com[id]=0;
			$('#WriteComm'+id).hide();
			$('#fluxFooter'+id).hide();
			Acom[id]=0;			
		}
		else
		{
			$('#BoxComm'+id).show();
			$('#BoxComm'+id).html("<td colspan='3'><div style='text-align:center'><img src='modules/flux/style/images/loader.gif' /></div></td>");
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_afficher_comm.php",
				data: "id="+id+"&page="+page,
				dataType: "html",
				success: function(msg){
					$('#BoxComm'+id).hide();
					$('#BoxComm'+id).html(msg);
					$('#BoxComm'+id).show();
					$('#flux_footer'+id).show();
				}
			});
			com[id]=1;
		}
	}
	function ecrireComm(id)
	{
		if(Acom[id]!=1)
		{
			$('#WriteComm'+id).show();
			$('#fluxFooter'+id).show();
			Acom[id]=1;
		}
		else
		{
			$('#WriteComm'+id).hide();
			$('#fluxFooter'+id).hide();
			Acom[id]=0;
		}
	}	

	function sendComm(id)
	{
		if(Acom[id]==1)
		{
			text=document.getElementById("TextArea"+id).value;
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_send_comm.php",
				data: "id="+id+"&text="+text,
				dataType: "html",
				success: function(msg){
					$('#WriteComm'+id).hide();
					$('#fluxFooter'+id).hide();
					com[id]=0;
					nombreComm(id);
					afficherComm(id,'1');
					Acom[id]=0;
				}
			});
			document.getElementById("TextArea"+id).value="";
		}
	}
	
	function editComm(id, page, edit)
	{
		if(com[id]==1)
		{
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_send_comm.php",
				data: "edit="+edit+"&id="+id+"&page="+page,
				dataType: "html",
				success: function(msg){
					$('#WriteComm'+id).html(msg);
					$('#WriteComm'+id).show();
					$('#fluxFooter'+id).show();
					Acom[id]=1;
				}
			});
		}
	}

	function editComm2(id, page, edit)
	{
		text=document.getElementById("TextArea"+id).value;
		$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_send_comm.php",
				data: "edit="+edit+"&valid=true&text="+text,
				dataType: "html",
				success: function(msg){
					$('#WriteComm'+id).html(msg);
					$('#WriteComm'+id).hide();
					$('#fluxFooter'+id).hide();
					Acom[id]=0;
					com[id]=0;
					afficherComm(id,page);
				}
			});
	}	

	function delComm(id, page, suppr)
	{
		if(com[id]==1)
		{
			$.ajax
			({
				type: "POST",
				url: "modules/flux/flux_send_comm.php",
				data: "delete="+suppr,
				dataType: "html",
				success: function(msg){
					com[id]=0;
					nombreComm(id);
					afficherComm(id,page);
				}
			});
		}
	}
	function nombreComm(id)
	{
		$.ajax
		({
			type: "POST",
			url: "modules/flux/flux_afficher_comm.php",
			data: "id="+id+"&nombre_comm=1",
			dataType: "html",
			success: function(msg){
				$('#nbreComm'+id).html(msg);
			}
		});	
	}
	
	function maintFlux(type, page, id, option)
	{
		/*Options disponibles
		1->Delete
		2->Edit
		3->Activer Accueil
		4->Desctiver Accueil
		*/
		$.ajax
		({
			type: "POST",
			url: "modules/flux/flux_maint.php",
			data: "id="+id+"&option="+option,
			dataType: "html",
			success: function(msg){
				chargerBox(type,page);
				$('#maint').html(msg);
			}
		});
	}	
