function Ejecuta(editor, accion, opcion) {
	editor.focus();
	if (opcion=="removeFormat") {
		accion=opcion;
		opcion=null;
	}

	if (editor.document.queryCommandEnabled(accion)){
		if (opcion==null)
			editor.document.execCommand(accion);
		else 
			editor.document.execCommand(accion,"",opcion);
	}
	else {
		if ((accion != "undo") && (accion != "redo"))	
			window.alert("No se puede ejecutar la acción deseada sobre la selección actual.");
	}
  
	editor.focus();
}

/* valor=0 barra superior, valor=1 barra inferior */
function BarraCofis(editor, valor) {
	editor.focus();
	var tr = editor.document.selection.createRange();
if (valor==1) {
	miStr="\
<TABLE  border='0' width='100%' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>\
	<TR>\
			<TD colspan='3' height='6' bgcolor='#FFFFFF'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='6' BORDER='0' ALT=''></TD>\
	</TR>\
	<TR>\
		<TD width='1' height='2' class='barracofis'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='2' BORDER='0' ALT=''></TD>\
		<TD height='1' width='100%' bgcolor='#FFFFFF'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='1' BORDER='0' ALT=''></TD>\
		<TD width='1' height='2' class='barracofis'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='2' BORDER='0' ALT=''></TD>\
	</TR>\
	<TR>\
		<TD colspan='3' height='2' class='barracofis'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='2' BORDER='0' ALT=''></TD>\
	</TR>\
	<TR>\
		<TD colspan='3' height='6' bgcolor='#FFFFFF'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='6' BORDER='0' ALT=''></TD>\
	</TR>\
</TABLE>\
";
} else {
	miStr="\
<TABLE  border='0' width='100%' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>\
	<TR>\
			<TD colspan='3' height='6' bgcolor='#FFFFFF'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='6' BORDER='0' ALT=''></TD>\
	</TR>\
	<TR>\
		<TD colspan='3' height='2' class='barracofis'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='2' BORDER='0' ALT=''></TD>\
	</TR>\
	<TR>\
		<TD width='1' height='2' class='barracofis'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='2' BORDER='0' ALT=''></TD>\
		<TD height='1' width='100%' bgcolor='#FFFFFF'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='1' BORDER='0' ALT=''></TD>\
		<TD width='1' height='2' class='barracofis'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='2' BORDER='0' ALT=''></TD>\
	</TR>\
	<TR>\
		<TD colspan='3' height='6' bgcolor='#FFFFFF'><IMG SRC='img/punto_claro.gif' WIDTH='1' HEIGHT='6' BORDER='0' ALT=''></TD>\
	</TR>\
</TABLE>\
";
}

	tr.pasteHTML(miStr);
}

function EjecutaSiSeleccion(editor, accion){
    if (editor.document.selection.type!="None") {
		Ejecuta(editor, accion);
    }
}

function eliminaEnlaces( valor ) {
	var re, res;
	res = valor;
	re = new RegExp("<A[^>]*>","g");
	res = res.replace(re, "");
	re = new RegExp("</A>","g");
	res = res.replace(re, "");
	return res;
}



function Enlace (editor) {
	var url, htmlText, tr, texto, res, urlDialog ;
	htmlText="";
	texto="";
	if (editor.document.selection.type=="None") {   
		urlDialog = "editor/enlaces.asp";
		alert( urlDialog );
		var vals = window.showModalDialog (urlDialog, null,"scroll:no;status:no;dialogWidth:480px;dialogHeight:220px");
		texto = vals["Texto"];
		if ((vals != null) && (vals["Address"] != "") && (vals["Texto"] != "")){
			editor.focus();
			var strDestino="";
			if (vals["destino"]!="") {
				strDestino = " target='"+ vals["destino"] +"' ";
			}
			tr = editor.document.selection.createRange();
			if (vals['Tipo']=="recurso") vals['Tipo']="";
			if (vals['Tipo']=="url") {
				url = vals['Address'];
			} else {
				url = vals['Tipo'] + vals['Address'];
			}
			res = vals['Texto'];
			res = eliminaEnlaces( res );
			htmlText = "<A name='"+ vals['nombre'] +"' HREF=\""+  url +"\" "+strDestino+">"+ res +"</A> ";
		}
	}
	else {
		tr = editor.document.selection.createRange();
		texto = tr.htmlText;
		
		var vals = window.showModalDialog ("editor/enlaces.asp", tr.text, "scroll:no;status:no;dialogWidth:450px;dialogHeight:220px");
		if ((vals != null) && (vals["Address"] != "")){
			var strDestino="";
			if (vals["destino"]!="") {
				strDestino = " target='"+ vals["destino"] +"' ";
			}
			if (vals['Tipo']=="") vals['Tipo']="";
			if (vals['Tipo']=="url") {
				url = vals['Address'];
			} else {
				url = vals['Tipo'] + vals['Address'];
			}
			res = tr.htmlText;
			res = eliminaEnlaces( res );
			htmlText = "<A name='"+ vals['nombre'] +"' HREF=\""+ url +"\" "+strDestino+">"+ res +"</A> ";
		}
		if ((vals != null) && (vals["Address"] == "")){
			res = tr.htmlText;
			res = eliminaEnlaces( res );
			htmlText = res;
		}
	}
	if (vals!=null) {
		if (vals["Address"] == "" && vals['nombre']!="" ) {
			tr = editor.document.selection.createRange();
			var nodos = editor.document.all[ vals['nombre'] ];
			if (nodos!=null) {
				if (nodos.length==null) {
					nodos.name="";
					nodos.className="";
				} else {
					for(i=0;i<nodos.length;i++) {
						nodos[i].name="";
						nodos[i].className="";
					}
				}
			}
			//alert(nodos);
			res = tr.htmlText;
			res = eliminaEnlaces( res );
			htmlText = "<A class='enlacename' title='"+ vals['nombre'] +"' name='"+ vals['nombre'] +"'>"+ res +"</A> "
		} 
	}
	if (htmlText!="") {
		tr.pasteHTML( htmlText );
		tr.select();
	}
}

function eliminarSpanVacio(nodo) {
	var res, re;

	/*if (nodo.tagName=="SPAN") {
		alert(nodo.tagName + "-" +nodo.children.length );
		if (nodo.children.length==1) {
			nodoHijo = nodo.children(0);
			if (nodoHijo.tagName=="SPAN") {
				alert("Reemplazo"+nodo.outerHTML);
				eliminarSpanVacio(nodoHijo);
				nodo.replaceNode(nodoHijo);
			}
		} else {
			for(i=0; i<nodo.children.length; i++) {
				var nodohijo = nodo.children(i);
				eliminarSpanVacio(nodohijo);
			}
		}
	} else {
        for(i=0; i<nodo.children.length; i++) {
            var nodohijo = nodo.children(i);
			eliminarSpanVacio(nodohijo);
        }
	}*/
}

function Fuente (editor) {
	var vals = window.showModalDialog ("editor/fuente.html",null,"directories=no;location:no;menubar:no;resizable:no;scrollbar:no;status:no;toolbar:no;");
	if (vals != null){		
		if (vals["Fuente"]!="") {
			var tr = editor.document.selection.createRange();
			//Elimino del contenido de la selección los spanes con clase texto_titulo
			var cadena = tr.htmlText;
			
			var res, re;
			res = cadena;

			if (vals["Fuente"]=="textopregunta") {
				re = new RegExp("<SPAN( class=)?[^>]*>","g");
				res = res.replace(re, "");

				re = new RegExp("</SPAN>","g");
				res = res.replace(re, "");

				re = new RegExp("<P( class=)?[^>]*>","g");
				res = res.replace(re, "<P class='"+ vals["Fuente"] +"'>");

				//re = new RegExp("<P [^ >]*>","g");
				//res = res.replace(re, "<P class='"+ vals["Fuente"] +"'>");
				//alert(res);

				//Elimino del editor de texto enriquecido todos los SPANS vacios.
				//alert(editor.innerHTML);
				//eliminarSpanVacio(editor);

				tr.pasteHTML("<span class='"+ vals["Fuente"] +"'>"+res+"</span>");
				tr.select();

				var nodo = editor.children(0);
				if (nodo.tagName=="SPAN") {
					//alert(nodo.innerHTML);
					nodo.outerHTML = nodo.innerHTML;
				}
				
			} else {
				re = new RegExp("<SPAN( class=)?[^>]*>","g");
				res = res.replace(re, "");

				re = new RegExp("</SPAN>","g");
				res = res.replace(re, "");

				tr.pasteHTML("<span class='"+ vals["Fuente"] +"'>"+res+"</span>");
			}

		    //tr.pasteHTML("<span class='"+ vals["Fuente"] +"'>"+res+"</span>");
			//tr.select();			
		} 
	}
}

function Fuente2 (editor) {
	var nodo, nodoIni, nodoFin , tr, tr2, trInicial, trFinal;
	var vals = window.showModalDialog ("editor/fuente.html",null,"directories=no;location:no;menubar:no;resizable:no;scrollbar:no;status:no;toolbar:no;");
	if (vals != null){		
		if (vals["Fuente"]!="") {
			if (editor.document.selection.type!="None") {
				tr = editor.document.selection.createRange();
				tr.expand();
				texto = tr.htmlText;
				nuevoTexto = texto;
				debug( "Fuente - tr.htmlText: " + texto );

				//Quito los spanes para comparar:
				var re = new RegExp("<.?SPAN( )?([^ >]*)>","g");
				nuevoTexto = nuevoTexto.replace(re, "");
				//Si no tiene marcas utilizo SPANS, busco el padre.
				if (nuevoTexto.indexOf("<")<0) {
					encontrado = false;
				} else {
					encontrado = true;
				}
				if (!encontrado) {
					tr.pasteHTML("<span class='"+ vals["Fuente"] +"'>"+nuevoTexto+"</span>");
					//tr.move("character",0)
				} else {
					tr2 = tr.duplicate();
					tr2.move("character",0)
					nodoIni = tr2.parentElement();
					while (nodoIni.tagName=="SPAN") {
						nodoIni= nodoIni.parentElement;
					}

					trInicial = editor.document.selection.createRange();
					trInicial.moveToElementText(nodoIni);
					trInicial.setEndPoint("EndToStart", tr);

					debug( "Fuente - Parrafo inicial: *" + trInicial.htmlText +"* de *"+tr.htmlText);
					htmlInicial = trInicial.htmlText;

					
					tr2 = tr.duplicate();
					tr2.collapse(false);
					nodoFin = tr2.parentElement();
					while (nodoFin.tagName=="SPAN") {
						nodoFin = nodoFin.parentElement;
					}

					debug( "Fuente - Nodo Final: *" + nodoFin.outerHTML );

					trFinal = editor.document.selection.createRange();
					trFinal.moveToElementText(nodoFin);				
					trFinal.setEndPoint("StartToEnd", tr);
					htmlFinal = trFinal.htmlText;
					debug( "Fuente - Parrafo Final: *" + trFinal.htmlText +"* de *"+tr.htmlText );

					var re = new RegExp("<.?SPAN( )?([^ >]*)>","g");
					texto = texto.replace(re, "");

					var re = new RegExp("<P( )?([^ >]*)>","g");
					texto = texto.replace(re, "<P$1$2><SPAN CLASS='"+ vals["Fuente"] +"'>");

					var re = new RegExp("</P>","g");
					texto = texto.replace(re, "</SPAN></P>");

					var re = new RegExp("<LI( )?([^ >]*)>","g");
					texto = texto.replace(re, "<LI$1$2><SPAN CLASS='"+ vals["Fuente"] +"'>");

					var re = new RegExp("</LI>","g");
					texto = texto.replace(re, "</SPAN></LI>");

					var re = new RegExp("<OL( )?([^ >]*)>","g");
					texto = texto.replace(re, "<OL$1$2><SPAN CLASS='"+ vals["Fuente"] +"'>");

					var re = new RegExp("</OL>","g");
					texto = texto.replace(re, "</SPAN></OL>");

					var re = new RegExp("<UL( )?([^ >]*)>","g");
					texto = texto.replace(re, "<UL$1$2><SPAN CLASS='"+ vals["Fuente"] +"'>");

					var re = new RegExp("</UL>","g");
					texto = texto.replace(re, "</SPAN></UL>");

					//Añado el comienzo del parrafo a el párrafo
					pos = texto.indexOf(">");
					texto = texto.substr(0,pos+1)+ htmlInicial +texto.substr(pos+1)

					pos = texto.lastIndexOf("</");
					texto = texto.substr(0,pos)+ htmlFinal +texto.substr(pos)

					debug( "Fuente - Texto Final: " + texto +"\ny nodo.innerHTML=");

					//nodoIni.outerHTML=texto;
					//nodoFin.outerHTML="";
					trInicial.setEndPoint("EndToEnd", trFinal);
					trInicial.pasteHTML(texto);
				}
					//trInicial.select();

					//tr.pasteHTML(texto);
					//nodo.innerHTML = htmlInicial;

					//debug();
				/*} else {
					//debug("Fuente: "+texto);
					tr.move("character",0);
					pini = tr.parentElement();
					//Itero por los parrafos hasta que encuentre el fin y lo establezco
					pini.className = vals["Fuente"];

					//debug("Fuente: P="+pini.outerHTML);

					//tr.pasteHTML("<span class='"+ vals["Fuente"] +"'>");
				}*/

			}
		} 
	}
}
function getXML(url) {
    var xmlDoc;
    xmlDoc = new ActiveXObject("MSXML2.DOMDocument")
    xmlDoc.async=false;
    xmlDoc.load(url);
    return xmlDoc;
}

function debug(cadena) {
	//getXML("http://trinity.red.vsf.es:91/editor/debug.asp?msg="+cadena);
}


function insertaTabla(editor){
	editor.focus();	
	var vals = window.showModalDialog ("editor/tabla.html",null,"directories=no;location:no;menubar:no;resizable:no;scrollbar:no;status:no;toolbar:no;");
	if (vals != null){
		var cadTabla = construyeCadenaTabla(vals);
		var tr = editor.document.selection.createRange();
		tr.pasteHTML(cadTabla);
		tr.select();	
	}	
}

function construyeCadenaTabla(vals){
	var cadBor;
	var strAux = "<TABLE ";
	
	// El borde.
	if (vals["Borde"] == "0") {
		strAux += "BORDER='1' ";
		cadBor = "STYLE='border-style:dotted; font:10pt arial,sans-serif' ";
		strAux += cadBor;
	}
	else {
		strAux += "BORDER='" + vals["Borde"] + "' ";
		strAux += "STYLE='font:10pt arial,sans-serif' ";
		cadBor = "";
	}
	
	// El ancho.
	strAux += "WIDTH='" + vals["Ancho"] + vals["Medida"] + "' ";
	
	// El espacio entre celdas.
	if (vals["EspacioCelda"] != "")
		strAux += "CELLSPACING='" + vals["EspacioCelda"] + "' ";
		
	// El relleno de la celda.
	if (vals["EspacioCelda"] != "")
		strAux += "CELLPPADING='" + vals["EspacioCelda"] + "' ";

	// Final inicio tabla.
	strAux += ">";
	
	// Las filas y columnas.
	numFilas = parseInt(vals["Filas"]);
	numColumnas = parseInt(vals["Columnas"]);
	for(i = 0;(i < numFilas); i++) {
		strAux += "<TR>";
		for(j = 0;(j < numColumnas); j++) {
			strAux += "<TD " + cadBor + "></TD>";
		}
		strAux += "</TR>";
	}
	
	// Final de tabla.
	strAux += "</TABLE>";
	return strAux;
}


  var ventana=null, i=0;

  function abrirVentana(nombre){
    if (ventana!=null) {
	     if (!ventana.closed) ventana.close();
    }
    ventana=window.open(nombre,"ventana"+(i++),"screenX=10, screenY=10,width=400,height=300,menubar=0,directories=0,status=0,scrollbars=1,alwaysRaised=1");
  }
  
function Imagen(editor, nombreCampo){
	//Obtengo el ultimo id de la lista de elementos de imagenes
/*	var nodes = window.parent.document.getElementById(nombreCampo+"_lineas_imagenes").getElementsByTagName("TR");
	var numeroFila = nodes[ nodes.length-1 ].getAttribute("id").substring( (nombreCampo+"_imagen_fila_").length,100);
	var nombreFile = nombreCampo+"_imagen_"+numeroFila+"_myfile";

	debug("Imagen: "+nombreFile);
*/
	window.top.nombreFile = nombreFile;
	var miarray=new Array(self, nombreFile);
	var strAdicional;
	var val = window.showModalDialog ("editor/imagen.asp", miarray ,"scroll:no;status:no;dialogWidth:450px;dialogHeight:230px");
	if (val!=null) {
		var nombreUrl=null;
		var alineacion = val[2];
		var borde= val[3];
		var texto_alternativo=  val[4];
		if (val[0]=="url") {
			nombreUrl = val[1];
		} else if (val[0]=="file") {
			var nombreFile = val[1];
			nombreUrl = "download/"+nombreFile;
		}
		if (nombreUrl!=null) {
			editor.focus();
		    var tr = editor.document.selection.createRange();
			var html="";
			if (nombreUrl.toLowerCase().indexOf(".swf")!=-1) {

				html = ""+
"<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' WIDTH='550' HEIGHT='400' id='myMovieName'>" +
"	<PARAM NAME=movie VALUE='"+nombreUrl+"'>" +
"	<PARAM NAME=play VALUE='1'>" +
"	<PARAM NAME=quality VALUE=high>" +
"	<PARAM NAME=bgcolor VALUE=#FFFFFF>" +
"<EMBED src='"+nombreUrl+"' quality=high bgcolor=#FFFFFF WIDTH='550' HEIGHT='400' NAME='myMovieName' ALIGN='' swLiveConnect=true TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>" +
"</OBJECT>";
			} else {
				if (borde==0) strAdicional = "border='0'";
				else strAdicional = "style='border-width: 11px; border-color: #ffffff' border=''";
				if (alineacion=="center") {
					html = "<center><img "+ strAdicional +"src='"+nombreUrl+"' alt='"+ texto_alternativo +"' align='"+alineacion+"'></center>";
				} else if (alineacion=="") {
					html = "<img "+ strAdicional +" src='"+nombreUrl+"' alt='"+ texto_alternativo +"'>";
				} else {
					html = "<img "+ strAdicional +" src='"+nombreUrl+"' alt='"+ texto_alternativo +"' align='"+alineacion+"'>";
				}
			}
			tr.pasteHTML( html );

		}
	}
}

function Fondo(editor) {
	colorDialog.CancelError = true;
	try {
		colorDialog.ShowColor();
	}catch (e){
		var vals = window.showModalDialog ("editor/color.html",null,"directories=no;location:no;menubar:no;resizable:no;scrollbar:no;status:no;toolbar:no;");
		if (vals != null)
			Ejecuta('BackColor', vals['Color']);
		else 
			return;
	}
	var color = colorDialog.Color;
	Ejecuta('BackColor', color);
}

function dameClave(editor){
	var fecha = new Date();
	return "img" + fecha.getDate() + fecha.getMonth() + fecha.getYear() + fecha.getHours() + fecha.getMinutes() + fecha.getSeconds();
}


function confirmarEliminacionImagen() {
	return confirm('¿Está usted seguro que no desea subir esta imagen al servidor?');
}

function habilitaFilesImagenes(campo) {
/*	var nodes = document.getElementById(campo+"_lineas_imagenes").getElementsByTagName("TR");
	var numeroFila, num;
	for (i=1; i<nodes.length ; i++) {
		numeroFila = nodes[ i ].getAttribute("id").substring( (campo+"_imagen_fila_").length,100);
		num = parseInt(numeroFila);
		document.getElementById(campo+"_imagen_"+num+"_myfile").disabled = false;
	}*/
}


// Borra la fila idFila de la tabla idTabla.
function borraFila(idTabla, idFila){
	// Buscamos la tabla y buscamos su cuerpo.
	var tbody = tablaYCuerpo(idTabla);
	// Buscamos la fila a borrar.
	var fila = document.getElementById(idFila);
	if (fila != null) {
		tbody.removeChild(fila);
	}
}


function nuevoNumero(idTabla, prefijo) {
		var nodes = document.getElementById(idTabla).getElementsByTagName("TR");
		var numeroFila = nodes[ nodes.length-1 ].getAttribute("id").substring( (prefijo + "fila_").length,100);

		var num = parseInt(numeroFila) + 1;
		return num;
}

// Añade una nueva fila a la tabla de identificador id,
// siempre que la fila numFila sea la última fila y 
// esté sin modificar.
function ponFilaPrefijo (idTabla, numFila, prefijo, elementos) {
	//var elementos = new String("borrar nombre tamanio idtipo destacado url file");
	var re = / /
	var elementosDeFila= elementos.split (re);

	var i, strElemento;
	// Nos aseguramos de que hay que insertar una fila
	// (estamos en la última fila y está sin modificar).
	var imagen = document.getElementById(prefijo + numFila + "_borrar");
	if ((imagen != null) && (imagen.style.visibility == 'hidden')){
		// Hacemos visible la imagen.
		//imagen.style.visibility = 'visible';

		// Buscamos la tabla y buscamos su cuerpo.
		var tbody = tablaYCuerpo(idTabla);
		// Buscamos un identificador para la nueva fila.


		// Buscamos un identificador para la nueva fila.
		var num = nuevoNumero(idTabla, prefijo);

		// Creamos las celdas, las añadimos a una fila, 
		// y la fila a la tabla.
		var fila = document.createElement("TR");
		fila.setAttribute("id", prefijo+"fila_"+num);

		var re1 = /\d+_/g;
		var re2 = /_\d+/g;
		var re3 = /,\d+/g;
	//	var re4 = /value=\d+/g;
		
		for (i=0; i<elementosDeFila.length; i++) {
			strElemento=elementosDeFila[i];
			var td = document.createElement("TD");
			var elemCopia = document.getElementById(prefijo+numFila+"_"+strElemento);
			var valorOld = elemCopia.getAttribute("value");
			elemCopia.setAttribute("value", "");
			str = document.getElementById(prefijo+numFila+"_"+strElemento).outerHTML;
			newStr = str.replace(re1, num+"_").replace(re2, "_"+num).replace(re3, ","+num);
			td.innerHTML = newStr;
			fila.appendChild(td);
			elemCopia.setAttribute("value", valorOld);
		}
		debug("ponFilaPrefijo - Append: "+fila.outerHTML);
		tbody.appendChild(fila);

		//Hacemos visibles los elementos de la fila que aparece
		for (i=0; i<elementosDeFila.length; i++) {
			strElemento=elementosDeFila[i];
			//alert(numFila+"_"+strElemento);
			document.getElementById(prefijo+numFila+"_"+strElemento).style.visibility = 'visible';
		}
	}
}


// Función para buscar una tabla y su cuerpo
function tablaYCuerpo (id){
	// Buscamos la tabla y buscamos su cuerpo.
	var tabla = document.getElementById(id);
	if (tabla == null){
		window.alert("Error al buscar la tabla.");
		return null;
	}
	var aux = tabla.firstChild;
	while((aux != null) && (aux.tagName != "TBODY"))
		aux = aux.nextSibling;
	if (aux == null){
		window.alert("Error al encontrar el TBODY.");
		return null;
	}
	return aux;
}

function editor_onpaste() {
	var i=0;
	event.returnValue = false;
	var tr = document.selection.createRange();
	var textData = clipboardData.getData("Text");
	var vTextData = textData.split("\n");
	var miStr="";
	var id;
	for (i=0;i<vTextData.length;i++ ) {
		if (i==0) {
			miStr += vTextData[i];
		} else if (i==vTextData.length-1) {
			miStr += "<p>" + vTextData[i];
		} else {
			miStr += "<p>"+vTextData[i]+"</p>";
		}
	}
	tr.pasteHTML(miStr);
}
