//Utilisation du script présenté par ThunderSeb sur le site du sero http://www.siteduzero.com
function insertTagNews(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":
							startTag = "<a href=\"" + currentSelection + "\">";
							endTag = "</a>";                    
							break;
                        case "citation":
							startTag = "<div class=\"quote\"><span class=\"quoted\"></span>";
							endTag = "</div>";
							break;
                }
        }
        
        if (window.ActiveXObject) {
                textRange.text = startTag + currentSelection + endTag;
                textRange.moveStart("character", -endTag.length - currentSelection.length);
                textRange.moveEnd("character", -endTag.length);
                textRange.select();     
        } else {
                field.value = startSelection + startTag + currentSelection + endTag + endSelection;
                field.focus();
                field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
        }       
}

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":
							startTag = "[url=" + currentSelection + "]";
							endTag = "[/url]";                    
							break;
                }
        }
        
        if (window.ActiveXObject) {
                textRange.text = startTag + currentSelection + endTag;
                textRange.moveStart("character", -endTag.length - currentSelection.length);
                textRange.moveEnd("character", -endTag.length);
                textRange.select();     
        } else {
                field.value = startSelection + startTag + currentSelection + endTag + endSelection;
                field.focus();
                field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
        }       
}
