function textview(header, body) {
  body = body.replace(/\</g, '&lt;');
  body = body.replace(/\>/g, '&gt;');
  body = body.replace(/\r\n/g, '<BR>');
  body = body.replace(/\[b\]/gi, '<B>');
  body = body.replace(/\[\/b\]/gi, '</B>');
  body = body.replace(/\[i\]/gi, '<I>');
  body = body.replace(/\[\/i\]/gi, '</I>');
  body = body.replace(/\[u\]/gi, '<U>');
  body = body.replace(/\[\/u\]/gi, '</U>');
  body = body.replace(/\[s\]/gi, '<S>');
  body = body.replace(/\[\/s\]/gi, '</S>');
  body = body.replace(/\[url=[\'|\']?([\w|\.|\/|\&|\?|\=|\:]*)[\'|\']?\](.*)\[\/url\]/gi, '<A href=\'$1\' target=\'_blank\'>$2</A>');
  body = body.replace(/\[url\]([\w|\.|\/|\&|\?|\=|\:]*)\[\/url\]/gi, '<A href=\'$1\' target=\'_blank\'>$1</A>');
  body = body.replace(/\[img=[\'|\']?([\w|\.|\/|\:]*)[\'|\']?\](.*)\[\/img\]/gi, '<IMG alt=\'$2\' border=\'0\' src=\'$1\'>');
  body = body.replace(/\[color=[\'|\']?([\w|\#]*)[\'|\']?\]/gi, '<FONT color=\'$1\' border=\'0\'>');
  body = body.replace(/\[\/color\]/gi, '</FONT>');
  body = body.replace(/\[img\]([\w|\.|\/|\:]*)\[\/img\]/gi, '<IMG src=\'$1\'>');
  body = body.replace(/\[quote\]/gi, '<DIV class=\'quote\'>');
  body = body.replace(/\[\/quote\]/gi, '</DIV>');
  preview.innerHTML = '<B>' + header + '</B><BR><BR>' + body;
}
function BBInsertTag(Tag) {
  var Sel = document.selection.createRange();
  if((Sel.parentElement().type === "textarea") || (Sel.parentElement().type === "text")) {
    Sel.text = '[' + Tag + ']' + Sel.text + '[/' + Tag + ']';
  }
}
function BBInsertLongTag(Tag) {
  var Sel = document.selection.createRange();
  var Input = prompt('Ââåäèòå àäðåñ', 'http://');
  if(Input) {
    if((Sel.parentElement().type === "textarea") || (Sel.parentElement().type === "text")) {
      if(Sel) { Sel.text = '[' + Tag + '=' + Input + ']' + Sel.text + '[/' + Tag + ']'; } 
      else { Sel.text = '[' + Tag + ']' + Input + '[/' + Tag + ']'; }
    }
  }
}

