function hideEditorNote(numPartie) {
	$("#xhtmleditor_note_" + numPartie).hide();
	$("#content_note_" + numPartie).show();
}

function editNote(append, numPartie) {
	if($("#note_type_" + numPartie).val() == "xhtml") {
		if(append) {
			if(!$("#note_contrib_editor_" + numPartie)[0].hasChildNodes()) {
				$("#note_contrib_editor_" + numPartie).append($("#contrib_editor"));
				$("#contrib_editor").hide();
			}
		}
		
		if(document.getElementById("editFrame").contentWindow.document.getElementById("contentPane") == null) {
			setTimeout("editNote(false, " + numPartie + ")",20);
			return;
		}

		$("#xhtmleditor_note_" + numPartie).show();
		$("#contrib_editor").show();
		setFrameEditable("editFrame", function() {
			document.getElementById("editFrame").contentWindow.document.body.innerHTML = $("#content_note_" + numPartie).html();
			$("#content_note_" + numPartie).hide();
		});
	} else {
		var xmlhttp;
		var data;
		var content;
		
		var textarea = document.createElement("textarea");
		
		$(textarea).attr("rows","6");
		$(textarea).attr("id", "phpeditor");
		if(!$("#note_contrib_editor_" + numPartie)[0].hasChildNodes()) {
			$("#note_contrib_editor_" + numPartie).append($(textarea));
		}
		$("#xhtmleditor_note_" + numPartie).show();
		
		data = "numpage=" + $("#numpage").val()
			+ "&numpartie=" + numPartie
			+ "&action=editNote";
			
		post("ajax/post_AjNotesAdmin.php", data, function(xmlhttp) {
			var reponse = xmlhttp.responseText;
			$(textarea).val(reponse);
		});
		$("#content_note_" + numPartie).hide();
	}
}

function saveContent(frameName, numPartie) {
	var xmlhttp;
	var data;
	var content;
	
	if($("#" + frameName)[0].nodeName == "textarea")
		content = $("#" + frameName).val();
	else {
		if($("#" + frameName).is(':hidden'))
			content = $("#AjEdition_txt").val();
		else
			content = $("#" + frameName)[0].contentWindow.document.body.innerHTML;
		//content = $("#" + frameName)[0].contentWindow.document.body.innerHTML;
	}
	
	data = "numpage=" + $("#numpage").val()
		+ "&numpartie=" + numPartie
		+ "&content=" + encodeURIComponent(content)
		+ "&action=updateNote";
	
	post("ajax/post_AjNotesAdmin.php", data, function(xmlhttp) {
		var reponse = xmlhttp.responseText;
	
		if(reponse.substring(0,2) == "OK") {
			alert("Enregistrement correctement effectué");
			document.location.reload();
		} else {
			alert(reponse.substring(3));
		}
	});
}