<!--
function insertTag(startTag, endTag, textareaId, tagType) {
	var field = document.getElementById(textareaId);
	field.focus();
	
	if (window.ActiveXObject) {
		var textRange = document.selection.createRange();            
		var currentSelection = textRange.text;
	} else {
		var startSelection   = field.value.substring(0, field.selectionStart);
		var currentSelection = field.value.substring(field.selectionStart, field.selectionEnd);
		var endSelection     = field.value.substring(field.selectionEnd);
	}
	
	if (tagType) {
		switch (tagType) {
			case "lien":
					endTag = "[/url]";
					if (currentSelection) {
							if (currentSelection.indexOf("http://") == 0 || currentSelection.indexOf("https://") == 0 || currentSelection.indexOf("ftp://") == 0 || currentSelection.indexOf("www.") == 0) {
									var label = prompt("Quel est le libellé du lien ?") || "";
									startTag = "[url=\"" + currentSelection + "\"]";
									currentSelection = label;
							} else {
									var URL = prompt("Quelle est l'url ?");
									startTag = "[url=\"" + URL + "\"]";
							}
					} else {
							var URL = prompt("Quelle est l'url ?") || "";
							var label = prompt("Quel est le libellé du lien ?") || "";
							startTag = "[url=\"" + URL + "\"]";
							currentSelection = label;                     
					}
			break;
			case "img":
					endTag = "[/img]";
					if (currentSelection) {
							if (currentSelection.indexOf("http://") == 0 || currentSelection.indexOf("https://") == 0 || currentSelection.indexOf("ftp://") == 0 || currentSelection.indexOf("www.") == 0) {
									var label = prompt("Quel est le titre de l'image ?") || "";
									startTag = "[img=\"" + currentSelection + "\"]";
									currentSelection = label;
							} else {
									var URL = prompt("Quelle est l'url de l'image?");
									startTag = "[img=\"" + URL + "\"]";
							}
					} else {
							var URL = prompt("Quelle est l'url de l'image ?") || "";
							var label = prompt("Quel est le titre de l'image ?") || "";
							startTag = "[img=\"" + URL + "\"]";
							currentSelection = label;                     
					}
			break;
			case "video":
					endTag = " /]";
					if (currentSelection) {
							if (currentSelection.indexOf("http://") == 0 || currentSelection.indexOf("https://") == 0 || currentSelection.indexOf("ftp://") == 0 || currentSelection.indexOf("www.") == 0) {
									startTag = "[video=\"" + currentSelection + "\"";
									currentSelection = "";
							} else {
									var URL = prompt("Quelle est l'url de la vidéo ?");
									startTag = "[video=\"" + URL + "\"";
							}
					} else {
							var URL = prompt("Quelle est l'url de la vidéo ?") || "";
							startTag = "[video=\"" + URL + "\"";
							currentSelection = "";                     
					}
			break;
		}
	}
	
	if (window.ActiveXObject) {
		textRange.text = startTag + currentSelection + endTag;
		textRange.moveStart('character', -endTag.length-currentSelection.length);
		textRange.moveEnd('character', -endTag.length);
		textRange.select();  
	} else { // Ce n'est pas IE
		field.value = startSelection + startTag + currentSelection + endTag + endSelection;
		field.focus();
		field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
	}      
}

//-->