function overlib(id,flagit) {
 if (document.layers) document.layers[''+id+''].visibility = "show"
 else if (document.all) document.all[''+id+''].style.visibility = "visible"
 else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}


function storeCaret(text){
 // Only bother if it will be useful.
 if (typeof(text.createTextRange) != 'undefined')
     text.caretPos = document.selection.createRange().duplicate();
}

function submitThisOnce(item){
 // Hateful, hateful fix for Safari 1.3 beta.
 if (navigator.userAgent.indexOf('AppleWebKit') != -1)
     return !smf_formSubmitted;
 for (var i = 0; i < item.form.length; i++)
      if (typeof(item.form[i]) != "undefined" && item.form[i].tagName.toLowerCase() == "textarea")
          item.form[i].readOnly = true;
 return !smf_formSubmitted;
}

function surroundText(text1, text2, textarea){
 // Can a text range be created?
 if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange){
     var caretPos = textarea.caretPos;
     caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
     caretPos.select();
 }
 // Mozilla text range wrap.
 else if (typeof(textarea.selectionStart) != "undefined"){
          var begin = textarea.value.substr(0, textarea.selectionStart);
          var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
          var end = textarea.value.substr(textarea.selectionEnd);
          var newCursorPos = textarea.selectionStart;
          var scrollPos = textarea.scrollTop;
          textarea.value = begin + text1 + selection + text2 + end;
          if (textarea.setSelectionRange){
              if (selection.length == 0)
                  textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
              else
                  textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
                  textarea.focus();
          }
          textarea.scrollTop = scrollPos;
 }
 // Just put them on the end, then.
 else {
      textarea.value += text1 + text2;
      textarea.focus(textarea.value.length - 1);
 }
}

function submitonce(theform){
 smf_formSubmitted = true;
 // if IE 4+ or NS 6+
 if (document.all || document.getElementById) {
     // hunt down "submit" and "reset"
     for (i=0;i<theform.length;i++) {
          var tempobj=theform.elements[i];
          if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
          //disable it
             tempobj.disabled=true;
          }
     }
 }
}

function replaceText(text, textarea) {
 // Attempt to create a text range (IE).
 if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange){
     var caretPos = textarea.caretPos;
     caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
     caretPos.select();
 }
 // Mozilla text range replace.
 else if (typeof(textarea.selectionStart) != "undefined") {
          var begin = textarea.value.substr(0, textarea.selectionStart);
          var end = textarea.value.substr(textarea.selectionEnd);
          var scrollPos = textarea.scrollTop;
          textarea.value = begin + text + end;
          if (textarea.setSelectionRange) {
              textarea.focus();
              textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
          }
          textarea.scrollTop = scrollPos;
 }
 // Just put it on the end.
 else {
     textarea.value += text;
      textarea.focus(textarea.value.length - 1);
 }
}
function bbc_highlight(something, mode)
{
        something.style.backgroundImage = "url(" + (mode ? "forum/images/bbcode/bbc_hoverbg.gif)" : "forum/images/bbcode/bbc_bg.gif)");
}