

	var tab_newMsg=new Array();//tableau contenant les connections à faire clignotés où il y a des nouveaux msg
	var curIdCo=0;
	var prevIdCo=0;
	var timer_checkMsg;
	var timer_checkCo;
	var nbCo=0;
	var oldNbCo=0;
	var valMove=1;
	var etatChat="closed";
	var reduce=0;

	
	
	
function afficher_chatCo(){ 
	//$('chatCo').hide();
	//ouvrir("IHM/IHM_Chat_bis.php?mod=afficherChatCo",'chatCo');
}
function afficher_chat(){
// 	new Draggable('containerChat');
// 	etatChat="open";
// 	$('containerChat').show();
// 	$('containerChat').style.width='350';
//   	$('containerChat').style.height='250';
//   	$('containerChatCo').style.width='180';
//   	$('containerChatCo').style.height='30';
	//ouvrir("IHM/IHM_Chat_bis.php?mod=afficher",'containerChat');
	//setTimeout("$('txtMsg').focus();",500);	
}

function check_msg(){
	
	//clearTimeout(timer_checkMsg);
	//ouvrir("IHM/IHM_Chat_bis.php?mod=check_msg",'chatCoCheck');
	//setTimeout('blink()',500);
	//timer_checkMsg=setTimeout('check_msg()',10000);
}

function check_new_co(){
	//clearTimeout(timer_checkCo);
	//ouvrir("IHM/IHM_Chat_bis.php?mod=check_co&curIdCo="+curIdCo,'containerChatCo');	
	//timer_checkCo=setTimeout('check_new_co()',10000);
}

function blink(){
	if($('chatCo').style.height==''){
		$('chatCo').style.height=25;
	}
	newHeight=nbCo*17;
	oldHeight=oldNbCo*17;
	valMove=(newHeight-oldHeight);
	oldNbCo=nbCo;
	if(reduce==0){
		new Effect.Move( 'menu', {x:0, y:valMove} );
		new Effect.Move( 'header', {x:0, y:valMove} );
		new Effect.ReSize($('chatCo'), {direction:'vert', amount:valMove});	
	}

	var tab=$A(tab_newMsg); 
		tab.each(
		   function(id){			  
			 
			   if(id>0){				   
				   if(curIdCo!=id){
					    if(curIdCo>0){
					 		$('div'+id).style.background='#f00';
				 		}
			   	   }else{
				   		read_msg(id);   
			   	   }
		   		}
			}
		)
	
}


function read_msg(id_co){
	if(etatChat=="closed"){
		afficher_chat();
		setTimeout("read_msg("+id_co+")",500);
	}
	curIdCo=id_co;
	if(prevIdCo>0){
		$('div'+prevIdCo).style.background='#fff';
	}
	if(curIdCo>0){
		$('div'+id_co).style.background='#fc0';
	}
	ouvrir("IHM/IHM_Chat_bis.php?mod=readMsg&id_co="+id_co,'dialog');
}
function send_msg(){
	ouvrir("IHM/IHM_Chat_bis.php?mod=sendMsg&id_co="+curIdCo+"&msg="+$('txtMsg').value,'dialog');
	setTimeout("read_msg("+curIdCo+")",200);
	$('txtMsg').value='';
}

function closeChat(){
	
	  etatChat="closed";
	  $('containerChat').hide();
		if(curIdCo>0){
		  	$('div'+curIdCo).style.background='#fff';
	  	}
	  curIdCo=0;

  }
  
  function closeCo(id_co){

	ouvrir("IHM/IHM_Chat_bis.php?mod=deco&id_co="+id_co,'chatCoCheck');		
	$('div'+id_co).innerHTML='';
	curIdCo=0;
	nbCo--;
	blink();
	check_new_co();
  }
  
  function more(){
	  $('chatCoMore').style.width='0px';
	  ouvrir("IHM/IHM_Chat_bis.php?mod=afficheMore",'chatCoMore');	  
  }
  
  function setCo(){
	  valeur=$('comboMore').options[$('comboMore').selectedIndex].value;
	  if(valeur>0){
	  	ouvrir("IHM/IHM_Chat_bis.php?mod=setCo&id="+valeur,''); 
	  	nbCo++;
	    blink();
	    check_new_co();
  	  }
	  $('chatCoMore').innerHTML='';
	 
  }
  
  function setReduce(){
	 if(reduce==0){
		$('up').hide();		
		newHeight=28;
		oldHeight=parseInt($('chatCo').style.height);
		valMove=(newHeight-oldHeight);
		reduce=1;
	  	new Effect.Move( 'menu', {x:0, y:valMove} );
		new Effect.Move( 'header', {x:0, y:valMove} );
		new Effect.ReSize($('chatCo'), {direction:'vert', amount:valMove});	

  	}else{
	  	$('up').show();
	  	reduce=0;
	  	newHeight=oldNbCo*17;
		oldHeight=0;
		valMove=(newHeight-oldHeight);
		new Effect.Move( 'menu', {x:0, y:valMove} );
		new Effect.Move( 'header', {x:0, y:valMove} );
		new Effect.ReSize($('chatCo'), {direction:'vert', amount:valMove});	
     }
  }
