
function textoFocusin() {

    document.getElementById("texto").focus();

}

var elEditor;      // declaracion necesaria para el funcionamiento de la libreria editor.js


function negrita() {

    if(!_lector()) {
        _insertar(elEditor, '<b>'+prompt("Texto en negrita:", _lector())+'</b>');
    } else {
        _insertar(elEditor, '<b>'+_lector()+ '</b>');
    }

}

function cursiva() {

    if(!_lector()) {
        _insertar(elEditor, '<i>'+prompt("Texto en cursiva:", _lector())+'</i>');
    } else {
        _insertar(elEditor, '<i>'+_lector()+ '</i>');
    }
}

function subrayado() {

    if(!_lector()) {
        _insertar(elEditor, '<u>'+prompt("Texto subrayado:", _lector())+'</u>');
    } else {
        _insertar(elEditor, '<u>'+_lector()+ '</u>');
    }
}

function alineacion(adonde) {

    if(adonde=="izquierda") {
        var convertido="left";
    }
    else if(adonde=="derecha") {
        var convertido="right";
    }
    else if(adonde=="centro") {
        var convertido="center";
    }
    else if(adonde=="justificado") {
        var convertido="justify";
    }
    else {
        var convertido="left";
    }
	
    if(!_lector()) {
        _insertar(elEditor, '[p align='+convertido+' \]'+prompt("Texto alineado a "+adonde+":", _lector())+'[/p]');
    } else {
        _insertar(elEditor, '[p align='+convertido+' \]'+_lector()+'[/p]');
    }

}


function sangria() {
    if(!_lector()) {
        _insertar(elEditor, '[blockquote]'+prompt("Texto con sangria:", _lector())+'[/blockquote]');
    } else {
        _insertar(elEditor, '[blockquote]'+_lector()+ '[/blockquote]');
    }

}
function cancelar(que) {

    objeto=document.getElementById(que);
    objetoS=document.getElementById(que+"S");

    objeto.innerHTML="";
    objeto.className="";
    objetoS.className="";

    document.getElementById("texto").focus();
}
function seleccionarColorHipervinculo(quecolor) {

    document.getElementById("tablaMuestraColorHiper").style.backgroundColor=quecolor;
    document.getElementById("colorHipervinculo").value=quecolor;

}

function hipervinculo() {

    var capaHiper=document.getElementById("capaHipervinculo");
    var capaHiperS=document.getElementById("capaHipervinculoS");

    capaHiper.className="capaHipervinculo";
    capaHiperS.className="capaHipervinculoS";

    var cadena = _lector();

    var siesweb=/^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)( [a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$/i.exec(cadena);
    var siesweb=/^http:\/\//i.exec(cadena);
    var siesemail=/@/g.exec(cadena);
    var sieswebwww=/^www./i.exec(cadena);

    var quees="nada";

    if(siesweb) {
        quees="web";
    }
    else if(sieswebwww) {
        quees="webwww";
    }
    else if(siesemail) {
        quees="email";
    }

    if (quees=="web") {
        capaHiper.innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Hiperv&iacute;nculo</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=155 valign=top><tr><td width=60% height=155><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=left>URL del enlace:</td></tr><tr><td width=100%><input type=text id=urlhipervinculo class=urlhipervinculo size=25 value='"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100% align=left>Texto para mostrar:</td></tr><tr><td width=100%><input type=text id=txthipervinculo class=urlhipervinculo size=25 value='"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100%>Que se abra: <select id=apertura class=urlhipervinculo><option value=nueva>Nueva ventana</option><option value=misma>Dentro ventana</option><option value=parent>Ventana padre</option></select></td></tr></table></td><td width=40% height=155 valign=top><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100%>Color:</td></tr><tr><td width=100%><table width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColorHipervinculo('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColorHipervinculo('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColorHipervinculo('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColorHipervinculo('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColorHipervinculo('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColorHipervinculo('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColorHipervinculo('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColorHipervinculo('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColorHipervinculo('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColorHipervinculo('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColorHipervinculo('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColorHipervinculo('#888888');>&nbsp;</td></tr></table>&nbsp;<table width=80 align=center border=0 cellspacing=0 cellpadding=0 height=35 id=tablaMuestraColorHiper style=background-color:blue;><tr><td width=100% height=100%>&nbsp;<INPUT TYPE=HIDDEN ID=colorHipervinculo value=blue></td></tr></table></td></tr></table></td></tr><tr><td width=100% colspan=2 align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaHipervinculo');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:crearHipervinculo();>Aceptar</td></tr></table></td></tr></table>";
    }
    else if (quees=="webwww") {
        capaHiper.innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Hiperv&iacute;nculo</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=155 valign=top><tr><td width=60% height=155><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=left>URL del enlace:</td></tr><tr><td width=100%><input type=text id=urlhipervinculo class=urlhipervinculo size=25 value='http://"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100% align=left>Texto para mostrar:</td></tr><tr><td width=100%><input type=text id=txthipervinculo class=urlhipervinculo size=25 value='http://"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100%>Que se abra: <select id=apertura class=urlhipervinculo><option value=nueva>Nueva ventana</option><option value=misma>Dentro ventana</option><option value=parent>Ventana padre</option></select></td></tr></table></td><td width=40% height=155 valign=top><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100%>Color:</td></tr><tr><td width=100%><table width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColorHipervinculo('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColorHipervinculo('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColorHipervinculo('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColorHipervinculo('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColorHipervinculo('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColorHipervinculo('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColorHipervinculo('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColorHipervinculo('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColorHipervinculo('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColorHipervinculo('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColorHipervinculo('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColorHipervinculo('#888888');>&nbsp;</td></tr></table>&nbsp;<table width=80 align=center border=0 cellspacing=0 cellpadding=0 height=35 id=tablaMuestraColorHiper style=background-color:blue;><tr><td width=100% height=100%>&nbsp;<INPUT TYPE=HIDDEN ID=colorHipervinculo value=blue></td></tr></table></td></tr></table></td></tr><tr><td width=100% colspan=2 align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaHipervinculo');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:crearHipervinculo();>Aceptar</td></tr></table></td></tr></table>";
    }

    else if(quees=="email") {
        capaHiper.innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Hiperv&iacute;nculo</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=155 valign=top><tr><td width=60% height=155><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=left>URL del enlace:</td></tr><tr><td width=100%><input type=text id=urlhipervinculo class=urlhipervinculo size=25 value='mailto:"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100% align=left>Texto para mostrar:</td></tr><tr><td width=100%><input type=text id=txthipervinculo class=urlhipervinculo size=25 value='"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100%>Que se abra: <select id=apertura class=urlhipervinculo><option value=nueva>Nueva ventana</option><option value=misma>Dentro ventana</option><option value=parent>Ventana padre</option></select></td></tr></table></td><td width=40% height=155 valign=top><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100%>Color:</td></tr><tr><td width=100%><table width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColorHipervinculo('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColorHipervinculo('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColorHipervinculo('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColorHipervinculo('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColorHipervinculo('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColorHipervinculo('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColorHipervinculo('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColorHipervinculo('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColorHipervinculo('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColorHipervinculo('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColorHipervinculo('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColorHipervinculo('#888888');>&nbsp;</td></tr></table>&nbsp;<table width=80 align=center border=0 cellspacing=0 cellpadding=0 height=35 id=tablaMuestraColorHiper style=background-color:blue;><tr><td width=100% height=100%>&nbsp;<INPUT TYPE=HIDDEN ID=colorHipervinculo value=blue></td></tr></table></td></tr></table></td></tr><tr><td width=100% colspan=2 align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaHipervinculo');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:crearHipervinculo();>Aceptar</td></tr></table></td></tr></table>";
    } else {
        capaHiper.innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Hiperv&iacute;nculo</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=155 valign=top><tr><td width=60% height=155><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=left>URL del enlace:</td></tr><tr><td width=100%><input type=text id=urlhipervinculo class=urlhipervinculo size=25 value=''></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100% align=left>Texto para mostrar:</td></tr><tr><td width=100%><input type=text id=txthipervinculo class=urlhipervinculo size=25 value='"+_lector()+"'></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100%>Que se abra: <select id=apertura class=urlhipervinculo><option value=nueva>Nueva ventana</option><option value=misma>Dentro ventana</option><option value=parent>Ventana padre</option></select></td></tr></table></td><td width=40% height=155 valign=top><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100%>Color:</td></tr><tr><td width=100%><table width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColorHipervinculo('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColorHipervinculo('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColorHipervinculo('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColorHipervinculo('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColorHipervinculo('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColorHipervinculo('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColorHipervinculo('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColorHipervinculo('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColorHipervinculo('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColorHipervinculo('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColorHipervinculo('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColorHipervinculo('#888888');>&nbsp;</td></tr></table>&nbsp;<table width=80 align=center border=0 cellspacing=0 cellpadding=0 height=35 id=tablaMuestraColorHiper style=background-color:blue;><tr><td width=100% height=100%>&nbsp;<INPUT TYPE=HIDDEN ID=colorHipervinculo value=blue></td></tr></table></td></tr></table></td></tr><tr><td width=100% colspan=2 align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaHipervinculo');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:crearHipervinculo();>Aceptar</td></tr></table></td></tr></table>";
    }

    document.getElementById("txthipervinculo").focus()
    document.getElementById("txthipervinculo").select()
}

function crearHipervinculo() {

    var url=document.getElementById("urlhipervinculo").value;
    var txt=document.getElementById("txthipervinculo").value;
    var apertura=document.getElementById("apertura").value;
    var color=document.getElementById("colorHipervinculo").value;

    if(url) {

        if(txt) {
            if(apertura=="nueva") {
                _insertar(elEditor, "[a href=\""+url+"\" target=_blank style=color:"+color+"; \]"+txt+"[/a]");
            } else if(apertura=="misma") {
                _insertar(elEditor, "[a href=\""+url+"\" target=_self style=color:"+color+"; \]"+txt+"[/a]");
            } else if(apertura=="parent") {
                _insertar(elEditor, "[a href=\""+url+"\" target=_parent style=color:"+color+"; \]"+txt+"[/a]");
            }
        } else {
            _insertar(elEditor, "[a href=\""+url+"\" target=_blank style=color:"+color+"; \]"+url+"[/a]");
        }

    }

    cancelar('capaHipervinculo');
    document.getElementById("texto").focus();

}
function formatoFuente() {

    var capaFF=document.getElementById("capaFormatoFuente");
    var capaFFS=document.getElementById("capaFormatoFuenteS");

    capaFF.className="capaFormatoFuente";
    capaFFS.className="capaFormatoFuenteS";

    capaFF.innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Formato de fuente</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=155 valign=top><tr><td width=60% height=155><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=left>Fuente y tama&ntilde;o:</td></tr><tr><td width=100%><select id=tipografia class=urlhipervinculo style=font-size:10pt; onchange=javascript:compruebaFormatoFuente();><option style='font-family: Arial;' value='Arial'>Arial</option><option style='font-family: Century Schoolbook L;' value='Century Schoolbook L'>Century Schoolbook L</option><option style='font-family: Comic Sans MS;' value='Comic Sans MS'>Comic Sans MS</option><option style='font-family: Courier New;' value='Courier New'>Courier New</option><option style='font-family: Georgia;' value='Georgia'>Georgia</option><option style='font-family: Impact;' value='Impact'>Impact</option><option style='font-family: Sans Serif;' value='Sans Serif'>Sans Serif</option><option style='font-family: Serif;' value='Serif'>Serif</option><option style='font-family: Tahoma;' value='Tahoma'>Tahoma</option><option style='font-family: Times New Roman;' value='Times New Roman'>Times New Roman</option><option style='font-family: Trebuchet MS;' value='Trebuchet MS' selected>Trebuchet MS</option><option style='font-family: Verdana;' value='Verdana'>Verdana</option><option style='font-family: Waree;font-size: 9pt;' value='Waree'>Waree</option></select> &nbsp; <select id=tamanotxt class=urlhipervinculo onchange=javascript:compruebaFormatoFuente();><option value=8>8</option><option value=9>9</option><option value='9.5' selected>9.5</option><option value=10>10</option><option value='10.5'>10.5</option><option value=11>11</option><option value=12>12</option><option value=14>14</option><option value=16>16</option><option value=18>18</option><option value=20>20</option><option value=22>22</option><option value=24>24</option><option value=28>28</option></select></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100% align=left>Estilo de texto:</td></tr><tr><td width=100%><select id=estilotxt class=urlhipervinculo onchange=javascript:compruebaFormatoFuente();><option value=normal>Normal</option><option style=font-weight:bold; value=negrita>Negrita</option><option style=font-style:italic; value=italic>Cursiva</option><option style=font-style:italic;font-weight:bold; value=negritacursiva>Negrita y cursiva</option></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100%>Efectos de texto:</td></tr><tr><td width=100%><select id=efectostxt class=urlhipervinculo onchange=javascript:compruebaFormatoFuente();><option value=normal>Normal</option><option style=text-decoration:blink; value=parpadeo>Parpadeante</option><option style=text-decoration:overline; value=suprarrayado>Suprarrayado</option><option style=text-decoration:underline; value=subrayado>Subrayado</option><option style=font-variant:small-caps; value=versalita>Versalita</option></select></td></tr></table></td><td width=40% height=155 valign=top><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100%>Color:</td></tr><tr><td width=100%><table onclick=javascript:compruebaFormatoFuente(); width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColorHipervinculo('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColorHipervinculo('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColorHipervinculo('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColorHipervinculo('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColorHipervinculo('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColorHipervinculo('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColorHipervinculo('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColorHipervinculo('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColorHipervinculo('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColorHipervinculo('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColorHipervinculo('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColorHipervinculo('#888888');>&nbsp;</td></tr></table>&nbsp;<table width=80 align=center border=0 cellspacing=0 cellpadding=0 height=35 id=tablaMuestraColorHiper style=background-color:black;><tr><td width=100% height=100%>&nbsp;<INPUT TYPE=HIDDEN ID=colorHipervinculo value=black onchange=javascript:compruebaFormatoFuente();></td></tr></table></td></tr></table></td></tr><tr><td width=100% colspan=2 height=77 valign=middle align=center><div id=previaTxt class=previaTxt>&nbsp;</div></td></tr><tr><td width=100% colspan=2 align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaFormatoFuente');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:crearFormatoFuente();>Aceptar</td></tr></table></td></tr></table>";


    compruebaFormatoFuente();

}

function compruebaFormatoFuente() {

    var fuente=document.getElementById("tipografia").value;
    var tamano=document.getElementById("tamanotxt").value;
    var efectos=document.getElementById("efectostxt").value;
    var estilo=document.getElementById("estilotxt").value;
    var color=document.getElementById("colorHipervinculo").value;

    if(estilo=="normal") {
        estiloa="font-style:normal;";
    }
    else if(estilo=="negrita") {
        estiloa="font-weight:bold;";
    }
    else if(estilo=="italic") {
        estiloa="font-style:italic;";
    }
    else if(estilo=="negritacursiva") {
        estiloa="font-style:italic;font-weight:bold;";
    }
    else {
        estiloa="font-style:normal;font-weight:normal;";
    }
	
    if(efectos=="normal") {
        efectosa="text-decoration:none;";
    }
    else if(efectos=="parpadeo") {
        efectosa="text-decoration:blink;";
    }
    else if(efectos=="suprarrayado") {
        efectosa="text-decoration:overline;";
    }
    else if(efectos=="subrayado") {
        efectosa="text-decoration:underline;";
    }
    else if(efectos=="versalita") {
        efectosa="font-variant:small-caps;";
    }
    else {
        efectosa="text-decoration:none;";
    }

    var colora="color:"+color+";";
    var tamanoa="font-size:"+tamano+"pt;";
    var fuentea="font-family:\""+fuente+"\";";

    var estilototal=estiloa + efectosa + colora + tamanoa + fuentea;

    if(_lector()) {
        document.getElementById("previaTxt").innerHTML="<font style='"+estilototal+"'>"+_lector()+"</font>";
    }
    else {
        document.getElementById("previaTxt").innerHTML="<textarea rows=4 cols=50 id='textoAponerFF' style='"+estilototal+"'>abcdefghijklmn&ntilde;opqrstuvwxyz\nABCDEFGHIJKLMN&Ntilde;OPQRSTUVWXYZ</textarea>";
    }
	
}

function crearFormatoFuente() {

    var fuente=document.getElementById("tipografia").value;
    var tamano=document.getElementById("tamanotxt").value;
    var efectos=document.getElementById("efectostxt").value;
    var estilo=document.getElementById("estilotxt").value;
    var color=document.getElementById("colorHipervinculo").value;

    if(estilo=="normal") {
        estiloa="font-style:normal;";
    }
    else if(estilo=="negrita") {
        estiloa="font-weight:bold;";
    }
    else if(estilo=="italic") {
        estiloa="font-style:italic;";
    }
    else if(estilo=="negritacursiva") {
        estiloa="font-style:italic;font-weight:bold;";
    }
    else {
        estiloa="font-style:normal;font-weight:normal;";
    }
	
    if(efectos=="normal") {
        efectosa="text-decoration:none;";
    }
    else if(efectos=="parpadeo") {
        efectosa="text-decoration:blink;";
    }
    else if(efectos=="suprarrayado") {
        efectosa="text-decoration:overline;";
    }
    else if(efectos=="subrayado") {
        efectosa="text-decoration:underline;";
    }
    else if(efectos=="versalita") {
        efectosa="font-variant:small-caps;";
    }
    else {
        efectosa="text-decoration:none;";
    }

    var colora="color:"+color+";";
    var tamanoa="font-size:"+tamano+"pt;";
    var fuentea="font-family:\""+fuente+"\";";

    var estilototal=estiloa + efectosa + colora + tamanoa + fuentea;

    _insertar(elEditor, "[font style=\'"+estilototal+"\' \]"+_lector()+"[/font]");

    cancelar('capaFormatoFuente');
    document.getElementById("texto").focus();

}

function colortexto() {


    var capaColorTexto=document.getElementById("capaColorTexto");
    var capaColorTextoS=document.getElementById("capaColorTextoS");

    capaColorTexto.className="capaColorTexto";
    capaColorTextoS.className="capaColorTextoS";

    capaColorTexto.innerHTML="<table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=center><b>Color de texto:</b></td></tr><tr><td width=100%><table onclick=javascript:compruebaFormatoFuente(); width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColor('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColor('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColor('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColor('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColor('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColor('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColor('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColor('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColor('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColor('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColor('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColor('#888888');>&nbsp;</td></tr></table></td></tr><tr><td width=100% align=right><table width=70% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=100% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaColorTexto');>Cancelar</td></tr></table></td></tr></table>";

}

function seleccionarColor(color) {

    _insertar(elEditor, "[font color="+color+" \]"+_lector()+"[/font]");

    cancelar("capaColorTexto");

}


function lista() {

    var capaFF=document.getElementById("capaFormatoFuente");
    var capaFFS=document.getElementById("capaFormatoFuenteS");

    capaFF.className="capaFormatoFuente";
    capaFFS.className="capaFormatoFuenteS";

    var tmp="";

    for(i=1;i<=100;i++) {

        tmp+="<input type=hidden id=tmp"+i+">";
    }

    capaFF.innerHTML="<table width=100% height=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Crear una lista</td></tr><tr><td width=100% height=90%>"+tmp+"<table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=90% valign=top><tr><td width=100% valign=top><input type=hidden id=numentradas value=0>Tipo de lista: <select id=tipolista class=urlhipervinculo><option value=ul>No numerada</option><option value=ol>Numerada</option></select>&nbsp; &nbsp;<input type=button class=urlhipervinculo style=border-style:outset; value='Crear Lista' id=crearlista onclick=javascript:crearLista();></td></tr><tr><td width=100% height=90% valign=top><br><div id=dondemeterlista style=overflow-y:auto;overflow-x:hidden;max-height:150;height:150;></div><center><input type=button class=urlhipervinculo style=font-weight:bold;background-color:#FF7708;color:white;font-size:11pt; value='A&ntilde;adir entrada' onclick=javascript:nuevaEntradaLista();></center></td></tr><tr><td width=100% align=right><br>&nbsp;<table width=48% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaFormatoFuente');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:crearCodigo();>Aceptar</td></tr></table></td></tr></table>";
}

function crearLista() {

    var tipolista=document.getElementById("tipolista").value;
    var num=document.getElementById("numentradas").value;
    if(tipolista=="ul") {

        document.getElementById("numentradas").value=Number(num)+1;

        document.getElementById("dondemeterlista").innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=0 style=font-size:9pt;><tr><td width=10% align=center valign=top><img src=img/listadesordenada.png border=0></td><td width=90%><textarea id=dato1 rows=5 cols=40 class=urlhipervinculo style=padding:6px;></textarea></td></tr></table>";
        document.getElementById("tipolista").disabled="True";
        document.getElementById("crearlista").disabled="True";
        document.getElementById("dato1").focus();
    }
    if(tipolista=="ol") {

        document.getElementById("numentradas").value=Number(num)+1;

        document.getElementById("dondemeterlista").innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=0 style=font-size:9pt;><tr><td width=10% align=center valign=top>1.</td><td width=90%><textarea id=dato1 rows=5 cols=40 class=urlhipervinculo style=padding:6px;></textarea></td></tr></table>";
        document.getElementById("tipolista").disabled="True";
        document.getElementById("crearlista").disabled="True";
        document.getElementById("dato1").focus();
    }

}

function nuevaEntradaLista() {

    var tipolista=document.getElementById("tipolista").value;
    var num=document.getElementById("numentradas").value;
    var entradaAntigua=document.getElementById("dato"+num).value;

    if(entradaAntigua) {
        if(tipolista=="ul") {


            document.getElementById("tmp"+num).value=entradaAntigua
            document.getElementById("numentradas").value=Number(num)+1;
            var jaumeni=Number(num)+1;
            document.getElementById("dondemeterlista").innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=0 style=font-size:9pt;><tr><td width=10% align=center valign=top><img src=img/listadesordenada.png border=0></td><td width=90%><textarea id=dato"+jaumeni+" rows=5 cols=40 class=urlhipervinculo style=padding:6px;></textarea></td></tr></table>";
            document.getElementById("dato"+jaumeni).focus();
        }
        if(tipolista=="ol") {

            document.getElementById("tmp"+num).value=entradaAntigua
            document.getElementById("numentradas").value=Number(num)+1;
            var jaumeni=Number(num)+1;
            document.getElementById("dondemeterlista").innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=0 style=font-size:9pt;><tr><td width=10% align=center valign=top>"+jaumeni+".</td><td width=90%><textarea id=dato"+jaumeni+" rows=5 cols=40 class=urlhipervinculo style=padding:6px;></textarea></td></tr></table>";
            document.getElementById("dato"+jaumeni).focus();
        }

    }

    document.getElementById("dato"+num).focus();
}

function crearCodigo() {
    var tipolista=document.getElementById("tipolista").value;
    var num=document.getElementById("numentradas").value;
    var ultimo=document.getElementById("dato"+num).value;

    var aescribir="["+tipolista+"]";

    for(i=1;i<num;i++) {

        tmp=document.getElementById("tmp"+i).value;

        aescribir+="[li]"+tmp+"[/li]";

    } if(ultimo) {
        aescribir+="[li]"+ultimo+"[/li]";
    }
    aescribir+="[/"+tipolista+"]";


    _insertar(elEditor, aescribir);

    cancelar('capaFormatoFuente');
}


function lineahorizontal() {


    var capaColorTexto=document.getElementById("capaColorTexto");
    var capaColorTextoS=document.getElementById("capaColorTextoS");

    capaColorTexto.className="capaColorTexto2";
    capaColorTextoS.className="capaColorTexto2S";

    capaColorTexto.innerHTML="<table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=center><b>Color de l&iacute;nea:</b></td></tr><tr><td width=100%><table width=120 border=0 align=center cellspacing=2 cellpadding=0><tr><td width=30 style=background-color:black; onclick=javascript:seleccionarColorLH('black');>&nbsp;</td><td width=30 style=background-color:blue; onclick=javascript:seleccionarColorLH('blue');>&nbsp;</td><td width=30 style=background-color:red; onclick=javascript:seleccionarColorLH('red');>&nbsp;</td><td width=30 style=background-color:green; onclick=javascript:seleccionarColorLH('green');>&nbsp;</td></tr><tr><td width=30 style=background-color:orange; onclick=javascript:seleccionarColorLH('orange');>&nbsp;</td><td width=30 style=background-color:purple; onclick=javascript:seleccionarColorLH('purple');>&nbsp;</td><td width=30 style=background-color:#730606; onclick=javascript:seleccionarColorLH('#730606');>&nbsp;</td><td width=30 style=background-color:#0F4507; onclick=javascript:seleccionarColorLH('#0F4507');>&nbsp;</td></tr><tr><td width=30 style=background-color:#88FF01; onclick=javascript:seleccionarColorLH('#88FF01');>&nbsp;</td><td width=30 style=background-color:#6ABCFF; onclick=javascript:seleccionarColorLH('#6ABCFF');>&nbsp;</td><td width=30 style=background-color:#7221FF; onclick=javascript:seleccionarColorLH('#7221FF');>&nbsp;</td><td width=30 style=background-color:#888888; onclick=javascript:seleccionarColorLH('#888888');>&nbsp;</td></tr></table></td></tr><tr><td width=100% align=right><table width=70% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=100% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaColorTexto');>Cancelar</td></tr></table></td></tr></table>";

}

function seleccionarColorLH(color) {

    _insertar(elEditor, "[hr size=1 color="+color+" \]");

    cancelar("capaColorTexto");

}
function codigoFuente() {

	var frase=_lector();

    _insertar(elEditor, "[blockquote][fieldset][legend]Citando:[/legend][code]"+frase+"\n[/code][/fieldset][/blockquote]");


}

function crearTabla() {

	
    var capaCrearTabla=document.getElementById("capaCrearTabla");
    var capaCrearTablaS=document.getElementById("capaCrearTablaS");

    capaCrearTabla.className="capaCrearTabla";
    capaCrearTablaS.className="capaCrearTablaS";

    var tablaColores="<table width=50 border=0 cellspacing=2 cellpadding=0 style=font-size:1px;><tr><td width=25% height=10 onclick=javascript:colorDeBorde('black'); style=background-color:black;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('green'); style=background-color:green;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('blue'); style=background-color:blue;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('purple'); style=background-color:purple;>&nbsp;</td></tr><tr><td width=25% height=10 onclick=javascript:colorDeBorde('orange'); style=background-color:orange;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('red'); style=background-color:red;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('#FFFF00'); style=background-color:#FFFF00;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('#599EFF'); style=background-color:#599EFF;>&nbsp;</td></tr><tr><td width=25% height=10 onclick=javascript:colorDeBorde('#6E0B0B'); style=background-color:#6E0B0B;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('#5E00FF'); style=background-color:#5E00FF;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('#5C5C5C'); style=background-color:#5C5C5C;>&nbsp;</td><td width=25% height=10 onclick=javascript:colorDeBorde('#D3D3D3'); style=background-color:#D3D3D3;border-color:6a6a6a;border-style:solid;border-width:0.5px;>&nbsp;</td></tr></table>";

    voyarellenarcon="<div id=ABSOLUTAMENTETODO style=overflow:auto;><table width=100% height=100% border=0 style=font-size:9pt; cellspacing=0 cellpadding=6><tr><td width=100% align=center><b><font size=4>Crear una tabla</font></b></td></tr>";

    voyarellenarcon+="<tr><td width=100% height=95%><table width=100% height=100% border=0 cellspacing=0 cellpadding=5><tr><td width=50% valign=top><table width=100% style=font-size:9pt; border=0><tr><td width=70% align=right>N&uacute;mero de columnas:</td><td width=30%><table width=100% border=0 cellspacing=2 cellpadding=0><tr><td width=50%><input readonly=readonly type=text size=2 class=urlhipervinculo style=text-align:right; id=columnas value=2></td><td width=50%><table width=12 height=24 border=0 cellspacing=0 cellpadding=0><td width=12 height=12><img src=img/flechaenanaarriba.png onclick=javascript:subirbajarcolumnas('subir'); border=0></td></tr><tr><td width=12 height=12><img src=img/flechaenanaabajo.png onclick=javascript:subirbajarcolumnas('bajar'); border=0></td></tr></table></td></tr></table></td></tr><tr><td width=70% align=right>N&uacute;mero de filas:</td><td width=30%><table width=100% border=0 cellspacing=2 cellpadding=0><tr><td width=50%><input type=text size=2 class=urlhipervinculo style=text-align:right; id=filas readonly=readonly value=2></td><td width=50%><table width=12 height=24 border=0 cellspacing=0 cellpadding=0><td width=12 height=12><img src=img/flechaenanaarriba.png onclick=javascript:subirbajarfilas('subir'); border=0></td></tr><tr><td width=12 height=12><img src=img/flechaenanaabajo.png onclick=javascript:subirbajarfilas('bajar'); border=0></td></tr></table></td></tr></table></td></tr><tr><td width=70% align=right>Tama&ntilde;o de borde:</td><td width=30%><table width=100% border=0 cellspacing=2 cellpadding=0><tr><td width=50%><input type=text size=2 class=urlhipervinculo style=text-align:right; id=borde readonly=readonly value=1></td><td width=50%><table width=12 height=24 border=0 cellspacing=0 cellpadding=0><td width=12 height=12><img src=img/flechaenanaarriba.png onclick=javascript:subirbajarborde('subir'); border=0></td></tr><tr><td width=12 height=12><img src=img/flechaenanaabajo.png onclick=javascript:subirbajarborde('bajar'); border=0></td></tr></table></td></tr></table></td></tr><tr><td width=70% align=right valign=top>Color de borde:<input type=hidden id=colorBorde value=black></td><td width=30%>"+tablaColores+"</td></tr><tr><td width=70% align=right>Poner t&iacute;tulos de columna: </td><td width=30%><select id=ponerTitulosColumna class=urlhipervinculo><option value=si>Si</option><option value=no>No</option></select></td></tr></table></td><td width=50% valign=top>";

    voyarellenarcon+="<table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:9pt;><tr><td width=10%></td><td width=90%>Encabezado:</td></tr><tr><td width=100% colspan=2><input type=text size=18 class=urlhipervinculo id=encabezado onkeypress=\"setTimeout('actualizarCreacionTabla()',20);\" style=font-weight:bold;font-size:10pt;></td></tr></table><br><table width=100% height=170 border=0 cellspacing=0 cellpadding=6><tr><td width=100% height=100%><div id=creaciondetabla style=max-height:160;overflow-x:hidden;overflow-y:auto;></div></td></tr></table>"

    voyarellenarcon+="</td></tr><tr><td width=100% height=50 colspan=2 align=right><br>&nbsp;<table width=48% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaCrearTabla');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:generacionTabla();>Aceptar</td></tr></table></td></tr></table></div>";

    capaCrearTabla.innerHTML=voyarellenarcon;
    actualizarCreacionTabla();
    document.getElementById("columnas").focus();
    document.getElementById("columnas").select();

}
function actualizarCreacionTabla() {

    var enDondeRellenar=document.getElementById("creaciondetabla");

    var filasTotal=document.getElementById("filas").value;
    var columnasTotal=document.getElementById("columnas").value;
    var borde=document.getElementById("borde").value;
    var colorBorde=document.getElementById("colorBorde").value;
    var encabezado=document.getElementById("encabezado").value;

    if(encabezado) {
        var cabeza="<tr><td width=100% colspan="+columnasTotal+" style=background-color:#595959;color:white;font-size:9px;border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid;><b>"+encabezado+"</b></td></tr>";
    } else {
        var cabeza="";
    }


    var filaActual=1;
    var columnaActual=1;
    var conjunto="";
    var tamanoColumna=100/Number(columnasTotal);
    tamanoColumna=tamanoColumna.toFixed(2);

    filasTotal=Number(filasTotal);
    columnasTotal=Number(columnasTotal);

    for(filaActual=1;filaActual<=filasTotal;filaActual++) {

        conjunto+="<tr>";

        while(columnaActual <= columnasTotal) {
     
           	 conjunto+="<td width="+tamanoColumna+"% style=font-size:5px;border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid;>&nbsp;</td>";

          	 columnaActual++;
        }
        conjunto+="</tr>";
        columnaActual=1;

    }

    var averdetodo="<table width=100% height=100% border="+borde+" style=border-color:"+colorBorde+"; cellspacing=0 cellpadding=0>"+cabeza+" "+conjunto+"</table>";

    enDondeRellenar.innerHTML=averdetodo;
}
function ampliarAnchoColumna(cual,cuantas) {

	var comoesta=document.getElementById("tamanoColumna"+cual).value;
	var dividirpor=cuantas-1;

	if(comoesta>95) {
	comoesta=Number(comoesta);
	comoesta=comoesta.toFixed(2);
	} else {
	comoesta=Number(comoesta)+5;
	comoesta=comoesta.toFixed(2);
	}
	var resto=100-comoesta;

	alosotros=resto/dividirpor;
	alosotros=alosotros.toFixed(2);
var estamosen=1;
	while(estamosen<=cuantas) {

		document.getElementById("tamanoColumna"+estamosen).value=alosotros;
		estamosen++;
	}

	document.getElementById("tamanoColumna"+cual).value=comoesta;
}

function reducirAnchoColumna(cual,cuantas) {

	var comoesta=document.getElementById("tamanoColumna"+cual).value;
	var dividirpor=cuantas-1;

	if(comoesta<5) {
	comoesta=Number(comoesta);
	comoesta=comoesta.toFixed(2);
	} else {
	comoesta=Number(comoesta)-5;
	comoesta=comoesta.toFixed(2);
	}
	var resto=100-comoesta;

	alosotros=resto/dividirpor;
	alosotros=alosotros.toFixed(2);
var estamosen=1;
	while(estamosen<=cuantas) {

		document.getElementById("tamanoColumna"+estamosen).value=alosotros;
		estamosen++;
	}

	document.getElementById("tamanoColumna"+cual).value=comoesta;
}

function generacionTabla() {

    var enDondeRellenar=document.getElementById("ABSOLUTAMENTETODO");

    var filasTotal=document.getElementById("filas").value;
    var columnasTotal=document.getElementById("columnas").value;
    var borde=document.getElementById("borde").value;
    var colorBorde=document.getElementById("colorBorde").value;
    var encabezado=document.getElementById("encabezado").value;
    var tituloscolumna=document.getElementById("ponerTitulosColumna").value;

    var filaActual=1;
    var columnaActual=1;
    var conjunto="";
    var tamanoColumna=100/Number(columnasTotal);
    tamanoColumna=tamanoColumna.toFixed(2);

    filasTotal=Number(filasTotal);
    columnasTotal=Number(columnasTotal);

if(tituloscolumna=="si") { filasTotal++; }

        anchocol="<tr>";

        while(columnaActual <= columnasTotal) {
            anchocol+="<td width="+tamanoColumna+"% style=font-size:9pt;background-color:#AFAFAF;border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid;text-align:center;><img src=img/flechaenanaizquierda.png border=0 style=cursor:pointer; title='Reducir ancho de columna' onclick=\"javascript:reducirAnchoColumna("+columnaActual+","+columnasTotal+");\">&nbsp;<input type=text size=5 value='"+tamanoColumna+"' class=urlhipervinculo id='tamanoColumna"+columnaActual+"'> %&nbsp;<img src=img/flechaenanaderecha.png border=0 style=cursor:pointer; title='Ampliar ancho de columna' onclick=\"javascript:ampliarAnchoColumna("+columnaActual+","+columnasTotal+");\"></td>";

            columnaActual++;
        }
        anchocol+="</tr>";
        columnaActual=1;

    if(encabezado) {

        var cabeza=anchocol+"<tr><td width=100% colspan="+columnasTotal+" style=background-color:#595959;color:white;font-size:13pt;border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid;><b>"+encabezado+"</b></td></tr>";
    } else {
        var cabeza=anchocol;
    }

    for(filaActual=1;filaActual<=filasTotal;filaActual++) {

        conjunto+="<tr>";

        while(columnaActual <= columnasTotal) {
            if(filaActual==1 && tituloscolumna=="si") {
                fondisimo="cfcfcf";rell="Titulo"+columnaActual;
            } else {
                fondisimo="none";rell="";
            }
            conjunto+="<td width="+tamanoColumna+"% style=font-size:8.5pt;background-color:"+fondisimo+";border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid;><input type=text size=16 value='"+rell+"' class=urlhipervinculo style=font-size:8.5pt; id='fila"+filaActual+"columna"+columnaActual+"'></td>";

            columnaActual++;
        }
        conjunto+="</tr>";
        columnaActual=1;

    }

    var averdetodo="<input type=hidden id=filas value="+filasTotal+"><input type=hidden id=columnas value="+columnasTotal+"><input type=hidden id=borde value="+borde+"><input type=hidden id=colorBorde value="+colorBorde+"><input type=hidden id='ponerTitulosColumna' value='"+tituloscolumna+"'><input type=hidden id=encabezado value='"+encabezado+"'><table cellpadding=7 border=0 width=100%><tr><td width=100%><div style=max-width:420px;width:420px;height:320px;max-height:320px;overflow:auto;><table width=100% border="+borde+" style=border-color:"+colorBorde+"; cellspacing=0 cellpadding=0>"+cabeza+" "+conjunto+"</table></div></td></tr><tr><td width=100% align=right><table width=48% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaCrearTabla');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:generacionTabla2();>Aceptar</td></tr></table></td></tr></table>";


    enDondeRellenar.innerHTML=averdetodo;

    document.getElementById("fila1columna1").focus();
    document.getElementById("fila1columna1").select();
}
function generacionTabla2() {

    var filasTotal=document.getElementById("filas").value;
    var columnasTotal=document.getElementById("columnas").value;
    var borde=document.getElementById("borde").value;
    var colorBorde=document.getElementById("colorBorde").value;
    var encabezado=document.getElementById("encabezado").value;
    var tituloscolumna=document.getElementById("ponerTitulosColumna").value;

    if(encabezado) {
        var cabeza="[tr][td width=100% colspan="+columnasTotal+" style=background-color:#595959;color:white;font-size:13pt;border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid; \]<b>"+encabezado+"</b>[/td][/tr]";
    } else {
        var cabeza="";
    }

    var conjunto="";

    filasTotal=Number(filasTotal);
    columnasTotal=Number(columnasTotal);


    for(filaActual=1;filaActual<=filasTotal;filaActual++) {

        conjunto+="[tr]";

        for(columnaActual=1; columnaActual <= columnasTotal; columnaActual++) {
            if(filaActual==1 && tituloscolumna=="si") {
                fondisimo="cfcfcf";negra="bold";
            } else {
                fondisimo="none";negra="none";
            }
		var tamanoColumna=document.getElementById("tamanoColumna"+columnaActual).value;

            queponerdetodos=document.getElementById("fila"+filaActual+"columna"+columnaActual).value;
            conjunto+="[td width="+tamanoColumna+"% style=font-size:9pt;background-color:"+fondisimo+";border-width:"+borde+"px;border-color:"+colorBorde+";border-style:solid;font-weight:"+negra+"; \]"+queponerdetodos+"[/td]";

        }
        conjunto+="[/tr]";

    }



    _insertar(elEditor,'[table width=100% border='+borde+' style=border-color:'+colorBorde+'; cellspacing=0 cellpadding=3 \]'+cabeza+' '+conjunto+'[/table]');

    cancelar('capaCrearTabla');

}
function insertarImagen() {

	document.getElementById("capaInsertarImagen").className="capaInsertarImagen";
	document.getElementById("capaInsertarImagenS").className="capaInsertarImagenS";
		document.getElementById("capaInsertarImagen").innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=7 style=font-size:9pt;><tr><td width=100% colspan=2 align=center style=font-weight:bold;font-size:13pt;>Insertar Imagen</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=5 style=font-size:8pt; height=155 valign=top><tr><td width=60% height=155><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100% align=left>URL de la imagen:</td></tr><tr><td width=100%><input type=text id=urlimagen class=urlhipervinculo size=25></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100% align=left>Texto alternativo:</td></tr><tr><td width=100%><input type=text id=txtalternativo class=urlhipervinculo size=25></td></tr><tr><td width=100% align=left>&nbsp;</td></tr><tr><td width=100%><table width=100% border=0 cellspacing=0 cellpadding=2><tr><td width=40% align=center><input type=text class=urlhipervinculo size=2 id=ancho></td><td width=5% align=center>x</td><td width=40% align=center><input type=text class=urlhipervinculo size=2 id=alto></td><td width=15% align=center><select id=pixporc class=urlhipervinculo><option value='%'>%</option><option value=' ' selected>px</option></select></td></tr><td width=40% align=center style=font-size:7.5pt;>Ancho</font></td><td width=5%></td><td width=40% align=center><font style=font-size:7.5pt;>Alto</td><td width=15% align=center><font style=font-size:7.5pt;>Modo</td></tr></table></td></tr></table></td><td width=40% height=155 valign=top><table width=100% border=0 cellspacing=0 style=font-size:9pt;><tr><td width=100%>Subir Imagen:</td></tr><tr><td width=100%><form name=formsubirimg enctype=multipart/form-data method=post action=subirImagen.php target=inv><input type=file size=8 class=urlhipervinculo name=imagen><br><br><div id=capaBotonSubirImg><input type=button class=urlhipervinculo onclick=javascript:subirImagen(); value=Subir style=border-style:outset;></div></form></td></tr></table>Alineaci&oacute;n:<br><select id=alineasion><option selected value=center>Centro</option><option value=left>Izquierda</option><option value=right>Derecha</option></select></td></tr><tr><td width=100% colspan=2 align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaInsertarImagen');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:insertarImagenYa();>Aceptar</td></tr></table></td></tr></table>";


}

function seleccionarColorBorde(quecolor) {

    document.getElementById("tablaMuestraColorBorde").style.backgroundColor=quecolor;
    document.getElementById("colorBorde").value=quecolor;

}

function insertarImagenYa() {

	var url=document.getElementById("urlimagen").value;
	var ancho=document.getElementById("ancho").value;
	var alto=document.getElementById("alto").value;
	var modo=document.getElementById("pixporc").value;
	var txtalt=document.getElementById("txtalternativo").value;
	var alineasion=document.getElementById("alineasion").value;
if(ancho && alto) {
    _insertar(elEditor,'[img src=\''+url+'\' border=0 width='+ancho+modo+' align='+alineasion+' style=padding:6px; height='+alto+modo+' title=\''+txtalt+'\' \]');
} else {
    _insertar(elEditor,'[img src=\''+url+'\' align='+alineasion+' style=padding:6px; border=0 title=\''+txtalt+'\' \]');
}

    cancelar('capaInsertarImagen');

}

function colorDeBorde(color) {

    document.getElementById("colorBorde").value=color;
    actualizarCreacionTabla();

}
function subirbajarcolumnas(que) {

    if(que=="subir") {

        var cuantoshay=document.getElementById("columnas").value;
        if(cuantoshay>=15) {
            document.getElementById("columnas").select();
        }
        else {
            cuantoshay=Number(cuantoshay);
            cuantoshay++;
            document.getElementById("columnas").value=cuantoshay;
            document.getElementById("columnas").select();
        }
    }
    if(que=="bajar") {

        var cuantoshay=document.getElementById("columnas").value;
        if(cuantoshay==1) {
            document.getElementById("columnas").select();
        }
        else {
            cuantoshay=Number(cuantoshay);
            cuantoshay=cuantoshay-1;
            document.getElementById("columnas").value=cuantoshay;
            document.getElementById("columnas").select();
        }
    }
    actualizarCreacionTabla();

}
function subirbajarfilas(que) {

    if(que=="subir") {

        var cuantoshay=document.getElementById("filas").value;
        if(cuantoshay>=90) {
            document.getElementById("filas").select();
        }
        else {
            cuantoshay=Number(cuantoshay);
            cuantoshay++;
            document.getElementById("filas").value=cuantoshay;
            document.getElementById("filas").select();
        }
    }
    if(que=="bajar") {

        var cuantoshay=document.getElementById("filas").value;
        if(cuantoshay==1) {
            document.getElementById("filas").select();
        }
        else {
            cuantoshay=Number(cuantoshay);
            cuantoshay=cuantoshay-1;
            document.getElementById("filas").value=cuantoshay;
            document.getElementById("filas").select();
        }
    }
    actualizarCreacionTabla();

}
function subirbajarborde(que) {

    if(que=="subir") {

        var cuantoshay=document.getElementById("borde").value;
        if(cuantoshay>=6) {
            document.getElementById("borde").select();
        }
        else {
            cuantoshay=Number(cuantoshay);
            cuantoshay++;
            document.getElementById("borde").value=cuantoshay;
            document.getElementById("borde").select();
        }
    }
    if(que=="bajar") {

        var cuantoshay=document.getElementById("borde").value;
        if(cuantoshay==0) {
            document.getElementById("borde").select();
        }
        else {
            cuantoshay=Number(cuantoshay);
            cuantoshay=cuantoshay-1;
            document.getElementById("borde").value=cuantoshay;
            document.getElementById("borde").select();
        }
    }
    actualizarCreacionTabla();

}

function cancelarEnviarMsg() {

	var id=document.getElementById("id_mensaje").value;
	document.getElementById("capaOscuraTotal").className="";
	document.getElementById("capaResponderMensaje").className="";
	document.getElementById("capaResponderMensaje").innerHTML="";

	parent.document.getElementById("iframeForo").scrolling="auto";
	parent.document.getElementById("iframeForo").src="foro/mensaje.php?id="+id+"&nuevo=modificado";

}

function cancelarEnviarMsg2(id) {


	document.getElementById("capaOscuraTotal").className="";
	document.getElementById("capaNuevoMensaje").className="";
	document.getElementById("capaNuevoMensaje").innerHTML="";

	parent.document.getElementById("iframeForo").scrolling="auto";
}

function vistaPreviaMsgForo() {

	document.formMensaje.action="vista-previa.php";
	document.formMensaje.method="POST";
	document.formMensaje.target="invisible";
	document.formMensaje.submit();

}

function subirImagen() {

	document.getElementById("capaBotonSubirImg").innerHTML="<font color=red><b>Subiendo....</b></font><br><font size=1>Por favor, espera</font>";

	document.formsubirimg.submit();

}

function cancelarVistaPreviaForo() {

	document.getElementById("capaVistaPrevia").className="";
	document.getElementById("capaVistaPrevia").innerHTML="";

	document.getElementById("texto").focus();

}

function enviarMsg() {


	var asunto=document.getElementById("asunto");
	var msg=document.getElementById("texto");

	if(asunto.value=="" || asunto.value==" ") { alert('Te falta el asunto!'); asunto.focus(); }
	else if(msg.value=="" || msg.value==" ") { alert('Te falta el mensaje!'); msg.focus(); }
	else {
		document.getElementById("capaResponderMensajeEnviando").className="capaResponderMensajeEnviando";
		document.getElementById("capaResponderMensajeEnviando").innerHTML="<table width=100% height=100% border=0><tr><td width=100% height=100% align=center valign=middle><font color=green size=4><b>Enviando....</b></font><br><br><a href=javascript:reintentar('resp');>Reintentar</a></td></tr></table>";
		
		document.formMensaje.action="enviarRespuesta.php";
		document.formMensaje.submit();
	}

}
function reintentar(cual) {
	if(cual=="resp") {
	document.getElementById("capaResponderMensajeEnviando").className="";
	document.getElementById("capaResponderMensajeEnviando").innerHTML="";
	} else {
	document.getElementById("capaNuevoMensajeEnviando").className="";
	document.getElementById("capaNuevoMensajeEnviando").innerHTML="";
	}

}
function nuevoMensaje(cat,subcat) {

	var user=top.document.getElementById("nombreUsuario").value;
	if(user=="Anónimo" || user=="An&oacute;nimo" || user=="Anonimo") { alert('No puedes enviar mensajes como anonimo') } else {

	document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

	parent.document.getElementById("iframeForo").scrolling="no";

	document.getElementById("invisible").src="rellenar-capa.php?cual=capaNuevoMensaje&categoria="+cat+"&subcategoria="+subcat+"&user="+user;
    }

}

function enviarMsg2() {

	var asunto=document.getElementById("asunto");
	var msg=document.getElementById("texto");

	if(asunto.value=="" || asunto.value==" ") { alert('Te falta el asunto!'); asunto.focus(); }
	else if(msg.value=="" || msg.value==" ") { alert('Te falta el mensaje!'); msg.focus(); }
	else {
		document.getElementById("capaNuevoMensajeEnviando").className="capaResponderMensajeEnviando";
		document.getElementById("capaNuevoMensajeEnviando").innerHTML="<table width=100% height=100% border=0><tr><td width=100% height=100% align=center valign=middle><font color=green size=4><b>Enviando....</b></font><br><br><a href=javascript:reintentar('nuevo');>Reintentar</a></td></tr></table>";
		
		document.formMensaje.action="enviarMensaje.php";
		document.formMensaje.submit();
	}

}

function editarResp(id) {

		document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

		parent.document.getElementById("iframeForo").scrolling="no";
	
		var user=top.document.getElementById("nombreUsuario").value;
		var pagina=document.getElementById("pagina").value;
	
		document.getElementById("invisible").src="rellenar-capa.php?cual=editarRespuesta&id="+id+"&pagina="+pagina+"&user="+user;

}

function editarRespYa() {


	var asunto=document.getElementById("asunto");
	var msg=document.getElementById("texto");

	if(asunto.value=="" || asunto.value==" ") { alert('Te falta el asunto!'); asunto.focus(); }
	else if(msg.value=="" || msg.value==" ") { alert('Te falta el mensaje!'); msg.focus(); }
	else {
		document.getElementById("capaNuevoMensajeEnviando").className="capaResponderMensajeEnviando";
		document.getElementById("capaNuevoMensajeEnviando").innerHTML="<table width=100% height=100% border=0><tr><td width=100% height=100% align=center valign=middle><font color=orange size=4><b>Editando....</b></font></td></tr></table>";
	
		document.formMensaje.action="editarRespuesta.php";
		document.formMensaje.submit();
	}
}
function editarMsg(id) {


	document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

	parent.document.getElementById("iframeForo").scrolling="no";

	var user=top.document.getElementById("nombreUsuario").value;

	document.getElementById("invisible").src="rellenar-capa.php?cual=editarMensaje&id="+id+"&user="+user;


}

function editarMsgYa() {
	var asunto=document.getElementById("asunto");
	var msg=document.getElementById("texto");

	if(asunto.value=="" || asunto.value==" ") { alert('Te falta el asunto!'); asunto.focus(); }
	else if(msg.value=="" || msg.value==" ") { alert('Te falta el mensaje!'); msg.focus(); }
	else {

		document.getElementById("capaNuevoMensajeEnviando").className="capaResponderMensajeEnviando";
		document.getElementById("capaNuevoMensajeEnviando").innerHTML="<table width=100% height=100% border=0><tr><td width=100% height=100% align=center valign=middle><font color=orange size=4><b>Editando....</b></font></td></tr></table>";
	
		document.formMensaje.action="editarMensaje.php";
		document.formMensaje.submit();
	}
}
function citarMsg(id) {


	var user=top.document.getElementById("nombreUsuario").value;
	if(user=="Anónimo" || user=="An&oacute;nimo" || user=="Anonimo") { alert('No puedes enviar como anonimo') } else {


	document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

	parent.document.getElementById("iframeForo").scrolling="no";

	document.getElementById("invisible").src="rellenar-capa.php?cual=citarMensaje&id="+id+"&user="+user;
  }

}
function citarResp(id) {

	var user=top.document.getElementById("nombreUsuario").value;
	if(user=="Anónimo" || user=="An&oacute;nimo" || user=="Anonimo") { alert('No puedes enviar como anonimo') } else {

	document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

	parent.document.getElementById("iframeForo").scrolling="no";

	document.getElementById("invisible").src="rellenar-capa.php?cual=citarRespuesta&id="+id+"&user="+user;
        }

}

function buscarMsgForo(cat,subcat) {

	document.getElementById("capaResponderMensaje").className="capaResponderMensaje";
	parent.document.getElementById("iframeForo").scrolling="no";

	var user=parent.document.getElementById("nombreUsuario").value;

	document.getElementById("invisible").src="rellenar-capa.php?cual=buscarMensajes&categoria="+cat+"&subcategoria="+subcat+"&user="+user;

}


function cancelarBuscarMensaje() {


	document.getElementById("capaResponderMensaje").className="";
	document.getElementById("capaResponderMensaje").innerHTML="";
	document.getElementById("capaOscuraTotal").className="";
	parent.document.getElementById("iframeForo").scrolling="auto";
}

function buscarMsgForo2() {


		//La categoría se selecciona una vez. Vendra en formato CAT,SUBCAT y hay que separarlo con split con filtro de coma (,)
	var categoriaBuscar=document.getElementById("categoriaBuscar").value;

	var catSeparadas=categoriaBuscar.split(",");

	var categoria=catSeparadas[0];
	var subcategoria=catSeparadas[1];

		document.getElementById("tablaBusQudas").className="tablaBusQudas2";
		document.getElementById("capaResponderMensaje").style.borderColor="blue";

		document.getElementById("invisible").src="buscar.php?accion=rellenarCuadroBusqueda&categoria="+categoria+"&subcategoria="+subcategoria;

}

function mostrarOpcionesAvanzadasBusquedaForo() {

var estado=document.getElementById("estadoOpAv").value;

	if(estado=="no") {

		document.getElementById("capaOpcionesAvanzadas").innerHTML="<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td width=50% valign=top><fieldset style=border-color:black;-moz-border-radius:8px;background-image:none;background-color:#DDE8FF;><legend style=color:blue;>Buscar mensajes por usuario</legend><div id=usuariosBusqueda></div></fieldset></td><td width=50% valign=top><fieldset style=border-color:black;-moz-border-radius:8px;background-image:none;background-color:#DDE8FF;><legend style=color:blue;>Buscar mensajes por fecha</legend><input type=text size=2 id=diaBusca value=DD onfocus=this.value=''; style=padding:5px;-moz-border-radius:9px;> - <input type=text size=2 id=mesBusca value=MM onfocus=this.value=''; style=padding:5px;-moz-border-radius:9px;> - <input type=text size=4 id=anoBusca value=AAAA onfocus=this.value=''; style=padding:5px;-moz-border-radius:9px;></fieldset></td></tr><tr><td width=100% colspan=2 style=font-size:6pt;>&nbsp;</td></tr><tr><td width=50% valign=top><fieldset style=border-color:black;-moz-border-radius:8px;background-image:none;background-color:#DDE8FF;><legend style=color:blue;>Buscar por</legend><select id=camposBuscar style=padding:5px;-moz-border-radius:9px;><option value=asunto>Asunto</option><option value=mensaje>Mensaje</option><option selected value=todo>Todos los campos</option></select></fieldset></td><td width=50% valign=top><fieldset style=border-color:black;-moz-border-radius:8px;background-image:none;background-color:#DDE8FF;><legend style=color:blue;>Ordenar resultados</legend><select id=ordenar style=padding:5px;font-size:7pt;-moz-border-radius:9px;><option value=asunto>Asunto</option><option value=lecturas>Lecturas</option><option value=fecha>Fecha</option><option value=fecha_mod>Fecha Ult Resp</option></select>&nbsp;<select id=orden style=padding:5px;font-size:7pt;-moz-border-radius:9px;><option value=ASC>Asc</option><option value=DESC>Desc</option></select></fieldset></td></tr></table>";

		document.getElementById("masOpciones").src="../img/menos10x10.png";

		document.getElementById("invisible").src="rellenar-campos.php?cual=usuariosBusqueda";

		document.getElementById("estadoOpAv").value="si";

	} else {

		document.getElementById("capaOpcionesAvanzadas").innerHTML="";
		document.getElementById("masOpciones").src="../img/mas10x10.png";
		document.getElementById("estadoOpAv").value="no";
	}
}

function buscarMsgForoYa() {

	parent.document.getElementById("iframeForo").scrolling="auto";
	var cadena=document.getElementById("cadena").value;
	var categoria=document.getElementById("categoria").value;
	var subcategoria=document.getElementById("subcategoria").value;

	if(cadena || !cadena==" ") {

		var estadoOpAv=document.getElementById("estadoOpAv").value;
		if(estadoOpAv=="si") {

			var usuarioBusc=document.getElementById("buscarporuser").value;
			var diaBusca=document.getElementById("diaBusca").value;
			var mesBusca=document.getElementById("mesBusca").value;
			var anoBusca=document.getElementById("anoBusca").value;
			var camposBuscar=document.getElementById("camposBuscar").value;
			var ordenar=document.getElementById("ordenar").value;
			var orden=document.getElementById("orden").value;

				document.getElementById("invisible").src="buscar.php?accion=buscar&cadena="+cadena+"&opav=si&buscarUser="+usuarioBusc+"&fechabuscar="+anoBusca+"-"+mesBusca+"-"+diaBusca+"&camposBuscar="+camposBuscar+"&ordenar="+ordenar+"&orden="+orden+"&categoria="+categoria+"&subcategoria="+subcategoria;
		} else {

				document.getElementById("invisible").src="buscar.php?accion=buscar&categoria="+categoria+"&subcategoria="+subcategoria+"&cadena="+cadena;
		}

			document.getElementById("centroBuscar").innerHTML="<table width=100% height=100% border=0 align=center><tr><td width=100% height=100% align=center valign=middle><b><font size=4 color=purple>Buscando....</font></b></td></tr></table>";
	} else {
		alert('Introduce una cadena de busqueda');
		document.getElementById("cadena").focus();
	}

}

function moderarMsg(id) {

	var user=top.document.getElementById("nombreUsuario").value;
	if(user=="Anónimo" || user=="An&oacute;nimo" || user=="Anonimo") { alert('No puedes moderar como anonimo') } else {

	document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

	parent.document.getElementById("iframeForo").scrolling="no";

	document.getElementById("invisible").src="rellenar-capa.php?cual=moderarMsg&id="+id+"&user="+user;
 }
}


function abrirCapaModeracion(accion) {

	var estado=document.getElementById("estado"+accion).value;

	if(accion=="Mover") {

		var catsSubcats="Mover a:<br><div id=capaCatSub></div>";

	} else if (accion=="Eliminar") {

		var catsSubcats="<b><font color=red>Atenci&oacute;n! Se borrar&aacute; el mensaje y todas sus respectivas respuestas permanentemente</b> </font><font color=blue>(para enviar a la papelera, mueve el mensaje)</font><br>";

	} else {

		var catsSubcats="";
	}


		if(estado=="no") {
			document.getElementById("botonMas"+accion).src="../img/menos10x10.png";
			document.getElementById("capa"+accion+"Msg").innerHTML="<font color=#989898>"+catsSubcats+"<br>Introduce la contrase&ntilde;a para continuar:</font><br><br><input type=password size=25 id=pass><input type=hidden id=accion value="+accion+"> &nbsp; <input type=button value='Confirmar "+accion+"' onclick=javascript:confirmarModerarMsg('"+accion+"');><br><br>";
			document.getElementById("estado"+accion).value="si";
				if(accion=="Mover") {
					document.getElementById("invisible").src="rellenar-campos.php?cual=capaCatSub";
				}
			document.getElementById("tabla10-1"+accion).className="tablaModMsg10-1";
			document.getElementById("tabla90-1"+accion).className="tablaModMsg90-1";
			document.getElementById("tabla10-2"+accion).className="tablaModMsg10-2";
			document.getElementById("tabla90-2"+accion).className="tablaModMsg90-2";
		} else {
			document.getElementById("botonMas"+accion).src="../img/mas10x10.png";
			document.getElementById("capa"+accion+"Msg").innerHTML="";
			document.getElementById("estado"+accion).value="no";
			document.getElementById("tabla10-1"+accion).className="";
			document.getElementById("tabla90-1"+accion).className="";
			document.getElementById("tabla10-2"+accion).className="";
			document.getElementById("tabla90-2"+accion).className="";

		}
}

function confirmarModerarMsg(accion) {

	var pass=document.getElementById("pass").value;
	var user=document.getElementById("user").value;
	var idmsg=document.getElementById("idmsg").value;

	if(accion=="Mover") {
		var categoria=document.getElementById("moverACat").value;

		categoria=categoria.split(",");

		document.getElementById("invisible").src="moderarMsg.php?accion="+accion+"&id="+idmsg+"&pass="+pass+"&user="+user+"&categoria="+categoria[0]+"&subcategoria="+categoria[1];
	} else {
		document.getElementById("invisible").src="moderarMsg.php?accion="+accion+"&id="+idmsg+"&pass="+pass+"&user="+user;
	}

}


function moderarResp(id) {


	var user=top.document.getElementById("nombreUsuario").value;
	if(user=="Anónimo" || user=="An&oacute;nimo" || user=="Anonimo") { alert('No puedes moderar como anonimo') } else {

	document.getElementById("capaNuevoMensaje").className="capaNuevoMensaje";

	parent.document.getElementById("iframeForo").scrolling="no";
	document.getElementById("invisible").src="rellenar-capa.php?cual=moderarResp&id="+id+"&user="+user;
     }

}


function abrirCapaModeracionResp(accion) {

	var estado=document.getElementById("estado"+accion).value;

	if(accion=="Mover") {

		var catsSubcats="Mover a:<br><div id=capaCatSub></div>";

	} else if (accion=="Eliminar") {

		var catsSubcats="<b><font color=red>Atenci&oacute;n! Se borrar&aacute; el mensaje permanentemente</b></font><br>";

	} else {

		var catsSubcats="";
	}


		if(estado=="no") {
			document.getElementById("botonMas"+accion).src="../img/menos10x10.png";
			document.getElementById("capa"+accion+"Msg").innerHTML="<font color=#989898>"+catsSubcats+"<br>Introduce la contrase&ntilde;a para continuar:</font><br><br><input type=password size=25 id=pass><input type=hidden id=accion value="+accion+"> &nbsp; <input type=button value='Confirmar "+accion+"' onclick=javascript:confirmarModerarResp('"+accion+"');><br><br>";
			document.getElementById("estado"+accion).value="si";
				if(accion=="Mover") {
					document.getElementById("invisible").src="rellenar-campos.php?cual=capaCatSub";
				}
			document.getElementById("tabla10-1"+accion).className="tablaModMsg10-1";
			document.getElementById("tabla90-1"+accion).className="tablaModMsg90-1";
			document.getElementById("tabla10-2"+accion).className="tablaModMsg10-2";
			document.getElementById("tabla90-2"+accion).className="tablaModMsg90-2";
		} else {
			document.getElementById("botonMas"+accion).src="../img/mas10x10.png";
			document.getElementById("capa"+accion+"Msg").innerHTML="";
			document.getElementById("estado"+accion).value="no";
			document.getElementById("tabla10-1"+accion).className="";
			document.getElementById("tabla90-1"+accion).className="";
			document.getElementById("tabla10-2"+accion).className="";
			document.getElementById("tabla90-2"+accion).className="";

		}
}

function confirmarModerarResp(accion) {

	var pass=document.getElementById("pass").value;
	var user=document.getElementById("user").value;
	var idmsg=document.getElementById("idmsg").value;

		document.getElementById("invisible").src="moderarResp.php?accion="+accion+"&id="+idmsg+"&pass="+pass+"&user="+user;


}
function previaYutu() {

	var codigo=document.getElementById("codigo").value;

	document.getElementById("previaYoutube").innerHTML="<object width=240 height=155><param name=movie value='http://www.youtube.com/v/"+codigo+"&hl=es_ES&fs=1&color1=0x402061&color2=0x9461ca'></param><param name=allowFullScreen value=true></param><param name=allowscriptaccess value=always></param><embed src='http://www.youtube.com/v/"+codigo+"&hl=es_ES&fs=1&color1=0x402061&color2=0x9461ca' type='application/x-shockwave-flash' allowscriptaccess=always allowfullscreen=true width=240 height=155></embed></object>";

}

function youtube() {

    var capaYoutube=document.getElementById("capaYoutube");
    var capaYoutubeS=document.getElementById("capaYoutubeS");

    capaYoutube.className="capaCrearTabla";
    capaYoutubeS.className="capaCrearTablaS";
    
    var tablaInterior="<table width=100% border=0 height=100% cellspacing=0 cellpadding=4><tr><td width=100% height=100% valign=top align=center><table width=100% border=0 cellspacing=0><tr><td width=50% align=center>Inserta el c&oacute;digo de youtube (<a href=javascript:; title='La URL del video que quieras meter, f&iacute;jate en el c&oacute;digo estilo http://www.youtube.com/watch?v=C5ZHwVfCcQ . El c&oacute;digo en cuesti&oacute;n es C5ZHwVfCcQ.'>ayuda</a>)<br><br><input type=text class=urlhipervinculo id=codigo value='"+_lector()+"'></td><td width=50% align=center>Alineaci&oacute;n<br><br><select id=alineacion class=urlhipervinculo><option selected value=center>Centro</option><option  value=left>Izquierda</option><option  value=right>Derecha</option></td></tr></table><br><button onclick=javascript:previaYutu();><table width=100% border=0 cellspacing=0 cellpadding=3><tr><td width=10%><img src=img/vistaprevia.png border=0></td><td width=90%>Previsualizar</td></tr></table></button></td></tr><tr><td width=100% height=90% align=center><div id=previaYoutube></div></td></tr></table>";
    
    var cosasyoutube="<table width=100% height=100% border=0 cellspacing=0 cellpadding=6><tr><td width=100% height=5% align=center><b><font size=4>Video de Youtube</font></b></td></tr><tr><td width=100% align=center height=85%>"+tablaInterior+"</td></tr><tr><td width=100% align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaYoutube');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:insertarYoutube();>Aceptar</td></tr></table></td></tr></table>";
    capaYoutube.innerHTML=cosasyoutube;
}


function insertarYoutube() {

	var codigo=document.getElementById("codigo").value;
	var alineacion=document.getElementById("alineacion").value;
    _insertar(elEditor,'[p align='+alineacion+' ][youtube]'+codigo+'[embed]'+codigo+'[/youtube][/p]');
cancelar('capaYoutube');
}


function goear() {

    var capaGoear=document.getElementById("capaGoear");
    var capaGoearS=document.getElementById("capaGoearS");

    capaGoear.className="capaCrearTabla";
    capaGoearS.className="capaCrearTablaS";
    
    var tablaInterior="<table width=100% border=0 height=100% cellspacing=0 cellpadding=4><tr><td width=100% height=100% valign=top align=center><table width=100% border=0 cellspacing=0><tr><td width=50% align=center>Inserta el c&oacute;digo de goear (<a href=javascript:; title='La URL de la canci&oacute;n que quieras meter, f&iacute;jate en el c&oacute;digo estilo http://www.goear.com/listen/784a702/to-france-mike-oldfield . El c&oacute;digo en cuesti&oacute;n es 784a702.'>ayuda</a>)<br><br><input type=text class=urlhipervinculo id=codigo value='"+_lector()+"'></td><td width=50% align=center>Alineaci&oacute;n<br><br><select id=alineacion class=urlhipervinculo><option selected value=center>Centro</option><option  value=left>Izquierda</option><option  value=right>Derecha</option></td></tr></table><br><button onclick=javascript:previaGouir();><table width=100% border=0 cellspacing=0 cellpadding=3><tr><td width=10%><img src=img/vistaprevia.png border=0></td><td width=90%>Previsualizar</td></tr></table></button></td></tr><tr><td width=100% height=90% align=center><div id=previaGouir></div></td></tr></table>";
    
    var cosasyoutube="<table width=100% height=100% border=0 cellspacing=0 cellpadding=6><tr><td width=100% height=5% align=center><b><font size=4>Canci&oacute;n de Goear.com</font></b></td></tr><tr><td width=100% align=center height=85%>"+tablaInterior+"</td></tr><tr><td width=100% align=right><table width=45% border=0 cellspacing=5 cellpadding=5 style=font-size:9pt;><tr><td width=50% align=center class=btnCnclr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:cancelar('capaGoear');>Cancelar</td><td width=50% align=center class=btnAcptr onmouseover='this.style.fontWeight=\"bold\";' onmouseout='this.style.fontWeight=\"normal\";' onclick=javascript:insertarGoear();>Aceptar</td></tr></table></td></tr></table>";
    capaGoear.innerHTML=cosasyoutube;
}

function previaGouir() {

	var codigo=document.getElementById("codigo").value;

	document.getElementById("previaGouir").innerHTML='<object width="240" height="155"><embed src="http://www.goear.com/files/external.swf?file='+codigo+'" type="application/x-shockwave-flash" wmode="transparent" quality="high" width="240" height="155"></embed></object>';

}

function superindice() {
    _insertar(elEditor,'[sup]'+_lector()+'[/sup]');
}
function subindice() {
    _insertar(elEditor,'[sub]'+_lector()+'[/sub]');

}
function insertarGoear() {

	var codigo=document.getElementById("codigo").value;
	var alineacion=document.getElementById("alineacion").value;
    _insertar(elEditor,'[p align='+alineacion+' ][goear]'+codigo+'[/goear][/p]');
cancelar('capaGoear');
}
