/* Fonctions lancées après le chargement de la page */
$(document).ready(function() { 
    $('#form_comment_add').ajaxForm({ 
		type : 			'post',
		beforeSubmit:	beforeCommentAdd,
        success:   		afterCommentAdd,  	
		timeout:   		10000 
    });              
});
/* Fin Fonctions lancées après le chargement de la page */

/* Fonctions générales */
function redirection(page)
{
	window.location=page;
}
/* Fin Fonctions générales */

/* Fonction sur l'ajout d'un commentaire */
function beforeCommentAdd()
{
	$("#form_comment_add_result").html('<span class="orange"><img src="/themes/chargement.gif" alt="Adding..." title="Adding..." /> Adding comment...</span>');
}
function afterCommentAdd(data)
{
	if (data == "commentok")  
	{
		$("#form_comment_add_result").html('<span class="vert">Comment have been added.</span>');
		commentReload($("#postid").val());
		$('#form_comment_add').resetForm();
	}
	else { $("#form_comment_add_result").html(data); }
	setTimeout('$("#form_comment_add_result").html(\'\')',5000);
}
function commentReload(tmp)
{
	$("#list_comment").html('<span class="orange"><img src="/themes/chargement.gif" alt="Loading..." title="Loading..." /> Loading...</span>'); 
	$.ajax({
		type: "post",
		url: "ajax.php",
		data: "btReloadComment="+tmp,
		success: function(data)
				{
					$("#list_comment").html(data);  
				}
	 });	
}
/* Fin Fonction sur l'ajout d'un commentaire */

/* Fonction d'ajout dans les favoris */
function favoris(url,titre)
{
	if (window.sidebar) // firefox
	{
		window.sidebar.addPanel(titre, url, "");
	}
	else if(window.opera && window.print) // opera
	{
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',titre);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
	{
		window.external.AddFavorite(url, titre);
	}
}
/* Fin fonction d'ajout dans les favoris */
