function confirmLink(msg, url){
okno=window.confirm(msg);
if(okno) location.replace(url);
}

function showdown(id){
  el=document.getElementById(id).style; 
  el.display=(el.display == 'block')?'none':'block';
}

function Expand(id, id2) {
  var d = document.getElementById(id);
  var d2 = document.getElementById(id2);
  if (d2.style.display=="") {
    d2.style.display="none"; }
  if (id != "") {
    if (d.style.display=="none") {
      d.style.display=""; }
    else { d.style.display="none"; } }
}

function wrapSelection(h, strFore, strAft) { h.focus();
  if (h.setSelectionRange) {
    var selStart = h.selectionStart, selEnd = h.selectionEnd;
    h.value = h.value.substring(0, selStart) + strFore + h.value.substring(selStart, selEnd) + strAft + h.value.substring(selEnd);
    h.setSelectionRange(selStart + strFore.length, selEnd + strFore.length); }
  else if (document.selection) {
    var oRange = document.selection.createRange();
    var numLen = oRange.text.length;
    oRange.text = strFore + oRange.text + strAft; }
  else { h.value += strFore + strAft; }
}


function bbcode(strFore, strAft) { 
  wrapSelection(document.bb.content, strFore, strAft); Expand('','bbc'); 
}

function bbemotions(strFore, strAft) { 
  wrapSelection(document.bb.content, strFore, strAft); Expand('','emotion'); 
}

