function insertTagImage(imgName)
{
var textArea = $("#textAreaEditorId"); //asigna el objeto Area de Texto por medio de su id.var text = textArea.text(); //asigna todo el texto del Area de Texto.var caret = textArea.caret(); //asigna el caret del Area del Texto.var posA = caret.start; //asigna la posicion INICIAL.var posB = caret.end; //asigna la posicion FINAL.var maxT = text.length; //asigna el largo total del texto completo del Area de Texto.var imgText = "<img src='" + imgName + "' />"; //asigna el texto tag de imagen.var textBefore = "";var textAfter = "";var newText = "";textBefore = text.substring(0, posA); //asigna el texto antes de la posicion inicial del carettextAfter = text.substring(posB, maxT); //asigna el texto despues de la posicion final del caretnewText = textBefore + imgText + textAfter; //crea y asigna el nuevo texto para el area de texto.textArea.text( newText ); //asigna por medio de la funcion text() el nuevo texto al Area de Texto.