function sendMsg(el, id, user_name, default_title) {
	var receivId = id;
	var dialog_box = ''
		+ '<div id="dialogSendMsg" title="Message pour '+user_name+'">'
		+ '<p id="validateTips">Tous les champs sont obligatoires.</p>'
		+ '<form style="height: 200px;">'
		+ '<p><label for="msgSubject">Sujet : </label>'
		+ '<input type="text" name="msgSubject" id="msgSubject" class="text ui-widget-content ui-corner-all" value="'+default_title+'" ></p>'
		+ '<p><textarea name="msgContent" id="msgContent" class="text ui-widget-content ui-corner-all" style="width:100%;height:100px;"></textarea></p>'
		+ '</form>'
		+ '</div>';
	
	$('body').append(dialog_box);
	
	var msgSubject = $("#msgSubject"),
	msgContent = $("#msgContent"),
	allFields = $([]).add(msgSubject).add(msgContent),
	tips = $("#validateTips");
	allFields.focus(
			function() 
			{
				$(this).removeClass('ui-state-error');
			}
	);
	var boxDialogSendMsg = $("#dialogSendMsg").dialog({
		bgiframe: true,
		autoOpen: true,
		height: 350,
		width: 450,
		modal: true,
		buttons: {
			'Envoyer': function() {
				var bValid = true;
				allFields.removeClass('ui-state-error');

				bValid = bValid && checkLength(msgSubject,"du sujet",3,30);
				bValid = bValid && checkLength(msgContent,"du message",5,500);

				if (bValid) {
					
					$(this).dialog('option', 'buttons', {});
					$("#validateTips").html("Envoi en cours.");
					$.post(URL_APPLICATION_FULLPATH+"index.php?module=user&page=sendMsg",
							{
								subject: msgSubject.val(),
								content: msgContent.val(),
								userDest: receivId
							},
							function(data){
								$("#validateTips").html(data);
								$("#dialogSendMsg").dialog('option', 'buttons', { "Ok": function() { $(this).dialog("close"); } });
							}
					);
					$("#dialogSendMsg").children("form").remove();
				}
			},
			'Annuler': function() {
				$(this).dialog('close');
			}
		},
		close: function() {
			$("#dialogSendMsg").remove();
		}
	});
	//$('div[aria-labelledby=ui-dialog-title-dialogSendMsg]').css('', ;
	//alert('tes');
	return false;
}

function checkLength(o,n,min,max) {

	if ( o.val().length > max || o.val().length < min ) {
		o.addClass('ui-state-error');
		$("#validateTips").html("La longueure " + n + " doit être comprise entre "+min+" et "+max+" caractères.");
		return false;
	} else {
		return true;
	}

}