function setshoagr()
{if(document.getElementById("agr").checked)
{document.getElementById("shoagr").style.display='none';
document.getElementById("hidagr").style.display='inline';
}else{
document.getElementById("shoagr").style.display='inline';
document.getElementById("hidagr").style.display='none'}}

function setshoagr1()
{if(document.getElementById("agr").checked)
{document.getElementById("shoagr").style.display='inline'}}

function getonetag(tag)
{intval=0;
switch(tag)
{case '[b]':
intval=gbb;
gbb=1-intval;
break;
case '[i]':
intval=gbi;
gbi=1-intval;
break;
case '[u]':
intval=gbu;
gbu=1-intval;
break;
case '[j]':
intval=gbj;
gbj=1-intval;
break;
case '[c]':
intval=gbc;
gbc=1-intval;
break;
case '[r]':
intval=gbr;
gbr=1-intval;
break;
default:
intval=0;}
if(!intval){return tag}else{return clotag}}

function instagbod(tag)
{clotag='';
mainwin=0;
switch(tag)
{case '[b]':
clotag='[/b]';
break;
case '[i]':
clotag='[/i]';
break;
case '[u]':
clotag='[/u]';
break;
case '[j]':
clotag='[/j]';
break;
case '[c]':
clotag='[/c]';
break;
case '[r]':
clotag='[/r]';
break;
case '[a':
strval=prompt("Пожалуйста, введите адрес ссылки.\r\nНапример, http://www.putj.ru/gb/.","http://www.");
if(!strval){return}
tag=' '+tag+' href='+strval;
strval=prompt("Пожалуйста, введите текст, который желаете сделать ссылкой.\r\nНапример, Книга отзывов и предложений.","здесь");
if(!strval){return}
strval1=prompt("Пожалуйста, введите необязательное всплывающее описание ссылки.\r\nНапример, Здесь вы можете разместить свои отзывы и предложения.",strval);
if(strval1==null){return}
if(strval1){tag=tag+" title='"+strval1+"'";}
tag=tag+']'+strval+'[/a]';
clotag=tag;
break;
default:
clotag=tag;
try{if(window.opener.name){mainwin=window.opener}else{mainwin=window.top}}
catch(err){mainwin=window.top}}
if(!mainwin){mainwin=window.top}
if(!mainwin){mainwin=window.self}
/* if(window.opener.name==location.hostname){mainwin=window.opener}else{mainwin=window.self} */
var message=mainwin.document.getElementById("messbody");
if(!message)
{mainwin=this;
message=document.getElementById("messbody")}
if(!message)
{alert('Невозможно найти сообщение, куда вы хотели бы вставить данный элемент. Попробуйте закрыть данное окно и открыть его еще раз из основного окна пути к другим.');
return}
var navtype=navigator.userAgent.toLowerCase();
if((parseInt(navigator.appVersion)>=4) && ((navtype.indexOf("msie")!=-1) && (navtype.indexOf("opera")==-1)) && ((navtype.indexOf("win")!=-1) || (navtype.indexOf("16bit")!=-1)))
{seltxt=mainwin.document.selection.createRange().text;
if(!seltxt)
{message.focus();
setcur(message);
var caretPos=message.caretPos;
onetag=getonetag(tag);
caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==' '?onetag+' ':onetag;
message.focus();
return}
mainwin.document.selection.createRange().text=tag+seltxt+clotag;
message.focus();
return
}else{
var sellen=message.textLength;
var selsta=message.selectionStart;
var selend=message.selectionEnd;
if(selend && (selend-selsta>0))
{if(selend==1 || selend==2){selend=sellen}
message.value=(message.value).substring(0,selsta)+tag+(message.value).substring(selsta, selend)+clotag+(message.value).substring(selend,sellen);
return
}else{
message.value=(message.value).substring(0,selsta)+getonetag(tag)+(message.value).substring(selsta,sellen);
message.focus()}
setcur(message)}} 

function setcur(obj){if(obj.createTextRange){obj.caretPos=mainwin.document.selection.createRange().duplicate()}}

function delmess(name){if(confirm(wishto()+"удалить указанное сообщение?")){document.getElementById(name).value=name}}

function delcm(name){if(confirm(wishto()+"удалить указанный комментарий?")){document.getElementById("c"+name).value=name}}

function delacm(){if(confirm(wishto()+"удалить все комментарии?")){document.getElementById("delac").value=1}}

gbb=0;
gbi=0;
gbu=0;
gbj=0;
gbc=0;
gbr=0;
