window.onerror = ShowError;

function ShowError(){
return true;
}

function InitEditor(){
for (i=0; i<document.all.length; i++) {
//if (document.all(i).unselectable!="off") document.all(i).unselectable = "on";
if (document.all(i).editor=="true") document.all(i).contentEditable="true";
}
}

function doCommand(cmd,n) {
editor=document.all['editor'+n];
editor.document.execCommand(cmd);
editor.focus();
}

function doCommand2(cmd,p1,p2,n) {
editor=document.all['editor'+n];
editor.document.execCommand(cmd,p1,p2);
editor.focus();
}

function button_over(eButton){
if(eButton.alternar==undefined) eButton.alternar=0;
if (eButton.alternar<2){
eButton.style.borderBottom = "buttonshadow solid 1px";
eButton.style.borderLeft = "buttonhighlight solid 1px";
eButton.style.borderRight = "buttonshadow solid 1px";
eButton.style.borderTop = "buttonhighlight solid 1px";
}
}

function button_out(eButton){
if(eButton.alternar==undefined) eButton.alternar=0;
if (eButton.alternar<2) eButton.style.borderColor = "threedface";
}

function button_down(eButton){
eButton.style.borderBottom = "buttonhighlight solid 1px";
eButton.style.borderLeft = "buttonshadow solid 1px";
eButton.style.borderRight = "buttonhighlight solid 1px";
eButton.style.borderTop = "buttonshadow solid 1px";
}

function button_up(eButton){
if(eButton.alternar==undefined) eButton.alternar=0;
if (eButton.alternar!=1){
eButton.style.borderBottom = "buttonshadow solid 1px";
eButton.style.borderLeft = "buttonhighlight solid 1px";
eButton.style.borderRight = "buttonshadow solid 1px";
eButton.style.borderTop = "buttonhighlight solid 1px";
if (eButton.alternar==2) eButton.alternar=1;
} else eButton.alternar=2;
}


function doFont(oFont,n) {
doCommand2('FontName',false,oFont,n);
}

function doSize(oSize,n) {
doCommand2('FontSize',false,oSize,n);
}

function actualizar(n){
if(event.keyCode == 13) {
sel=document.selection.createRange();
sel.pasteHTML('<br><x>');
return false;
}
}

function guardarEditor(){
for (i=0; i<document.all.length; i++) {
if (document.all(i).editor=="true") {
nombre=document.all(i).id;
resultStr=document.all(i).innerText;
resultStr=resultStr.replace(' ','');
if(resultStr) document.all['texto'+nombre].value=document.all(i).innerHTML;
else document.all['texto'+nombre].value='';
}
}
}

