function dialog(dialog, type, message, fonction) {		
	$("#"+dialog+" p").html(message);
	
	$("#"+dialog+" .fermer").unbind();
	$("#"+dialog+" .fermer").click( function() {
		$("#"+dialog).fadeOut("fast");
		
		if (typeof(fonction) != 'undefined') eval(fonction);
		
		return false;
	});
	
	if ( type == "message" || type == "erreur" )
	{
		if ( type == "message" )
		{
			$("#"+dialog+" h2").html("Message");
			
			$("#"+dialog).removeClass("erreur");
			$("#"+dialog).removeClass("alert");
			$("#"+dialog).removeClass("confirm");
			$("#"+dialog).addClass("message");
		}
		else if ( type == "erreur" )
		{
			$("#"+dialog+" h2").html("Erreur");
			
			$("#"+dialog).removeClass("message");
			$("#"+dialog).removeClass("alert");
			$("#"+dialog).removeClass("confirm");
			$("#"+dialog).addClass("erreur");
		}

		$("#"+dialog+" .ok").unbind();
		$("#"+dialog+" .ok").click( function() {
			$("#"+dialog).fadeOut("fast");
			
			if (typeof(fonction) != 'undefined') eval(fonction);
			
			return false;
		});
		
		$("#"+dialog+" .ko").hide();
	}
	else if ( type == "alert" || type == "confirm" )
	{
		$("#"+dialog).removeClass("message");
		$("#"+dialog).removeClass("erreur");
		$("#"+dialog).removeClass("confirm");
		$("#"+dialog).removeClass("alert");
		
		if ( type == "alert" ) {
			$("#"+dialog+" h2").html("Alerte");
			$("#"+dialog).addClass("alert");
		}
		else if ( type == "confirm" ) {
			$("#"+dialog+" h2").html("Confirmation");
			$("#"+dialog).addClass("confirm");
		}
		
		$("#"+dialog+" .ok").unbind();
		$("#"+dialog+" .ok").click( function() {
			$("#"+dialog).fadeOut("fast");
			eval(fonction);
			return false;
		});
		
		$("#"+dialog+" .ko").show();
		$("#"+dialog+" .ko").unbind();
		$("#"+dialog+" .ko").click( function() {
			$("#"+dialog).fadeOut("fast");
			return false;
		});
	}
	else
	{
		$("#"+dialog+" .ko").show();
		$("#"+dialog+" .ko").unbind();
		$("#"+dialog+" .ko").click( function() {
			$("#"+dialog).fadeOut("fast");
			return false;
		});
	}
	
	var t = (( $(window).height() - $("#"+dialog).height() ) / 2) + $(window).scrollTop();
	var l = ( $(window).width() - $("#"+dialog).width() ) / 2 + $(window).scrollLeft();
	
	$("#"+dialog).css({'top':t, 'left':l});
	
	$("#"+dialog).fadeIn("fast");
}

function fermerDialog(dialog) {
	$("#"+dialog).fadeOut("fast");
}
