

function slidedown(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; // cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}

function slideup(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "none")
                return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}

function startslide(objname){
        obj[objname] = document.getElementById(objname);

        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();

        if(dir[objname] == "down"){
                obj[objname].style.height = "1px";
        }

        obj[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname){
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                        d = endHeight[objname] - d;

                obj[objname].style.height = d + "px";
        }

        return;
}

function endSlide(objname){
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

        obj[objname].style.height = endHeight[objname] + "px";

        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);

        return;
}

function toggleSlide(objname,close_objname){
  if(document.getElementById(objname).style.display == "none"){
    // div is hidden, so let's slide down
    slidedown(objname);
  }else{
    // div is not hidden, so slide up
    slideup(objname);
  }
  //fermer les autres div
  a=toggleSlide.arguments
  for(i=1; i<a.length; i++)
  {
  eval("document.getElementById('"+a[i]+"').style.display='none'");
  }
}

/*function showSpinner (id_chat)
{
$('spinner').show();
}*/

/*function hideSpinner (id_chat)
{
eval("$('spinner"+id_chat+"').hide()");
}*/



function check_question(id_chat)
{
//PSEUDO=eval('pseudo'+id_chat);
PSEUDO='pseudo'+id_chat;
MSG='msg'+id_chat;
EMAIL='email'+id_chat;
QUESTION='question'+id_chat;
	new Ajax.Request("js/ajax_php/check_question.php",
	{
	method : 'post',
	parameters : $H({PSEUDO : $F(PSEUDO), EMAIL : $F(EMAIL), QUESTION : $F(QUESTION), 'id_chat' : id_chat}).toQueryString(),
	//onLoaded : $('spin_question').innerHTML='<img src="spinner.gif" width="16" height="16" alt="" border="0" />',
	onComplete : function (retour)
			{
				//$('spin_question').hide();
				reponse=retour.responseText.split("|");
				$(MSG).update(reponse[0]);
				//vider les champs
				if(typeof(reponse[1])!="undefined")
				{
				$(QUESTION).clear();
				setTimeout("$(MSG).update('Vous pouvez poser une autre question.')",4000);
				}
			}//function (retour)
			//onSuccess:function(){mask_msg($(MSG),3000);}
	})
}//check_question

function check_prevenir(id_chat)
{
EMAIL_DEST='email_dest'+id_chat;
EMAIL_EXP='email_exp'+id_chat;
MESSAGE='message'+id_chat;
MSG='msg_prev'+id_chat;
	new Ajax.Request("js/ajax_php/check_prevenir.php",
	{
	method : 'post',
	parameters : $H({EMAIL_DEST : $F(EMAIL_DEST), EMAIL_EXP : $F(EMAIL_EXP), MESSAGE : $F(MESSAGE), 'id_chat' : id_chat}).toQueryString(),
	//onLoaded : $('spin_question').innerHTML='<img src="spinner.gif" width="16" height="16" alt="" border="0" />',
	onComplete : function (retour)
			{
				//$('spin_question').hide();
				reponse=retour.responseText.split("|");
				$(MSG).update(reponse[0]);
				//vider les champs
				if(typeof(reponse[1])!="undefined")
				{
				$(EMAIL_DEST).clear();
				$(MESSAGE).clear();
				setTimeout("$(MSG).update('Vous pouvez prévenir une autre personne.')",4000);
				}
			}//function (retour)
	})
}//check_prevenir

function check_avertir(id_chat)
{
EMAIL_AV='email_av'+id_chat;
MSG='msg_avertir'+id_chat;
FORM='form'+id_chat;
BTN_VALID='valid'+id_chat;
	new Ajax.Request("js/ajax_php/check_avertir.php",
	{
	method : 'post',
	parameters : $H({EMAIL_AV : $F(EMAIL_AV), 'id_chat' : id_chat}).toQueryString(),
	//onLoaded : $('spin_question').innerHTML='<img src="spinner.gif" width="16" height="16" alt="" border="0" />',
	onComplete : function (retour)
			{
				//$('spin_question').hide();
				reponse=retour.responseText.split("|");
				$(MSG).update(reponse[0]);
				if(typeof(reponse[1])!="undefined")
				{
				$(EMAIL_AV).clear();
				setTimeout("$(MSG).update()",4000);
				//FORM.disable(); 
				$(BTN_VALID).hide();
				}
			}//function (retour)
	})
}//check_avertir