function insert_emo(txtarea,emo) {
  txtarea.value += emo+" "
  txtarea.focus()
}

function open_custom_emo(url) {
if (window.custom_emo) window.custom_emo.close();
custom_emo = window.open(url, 'win_ref', 'width=505,height=400,resizable=yes,scrollbars=yes');
}
function close_cemo() {
if (window.custom_emo) window.custom_emo.close();
}
function open_emos(url) {
if (window.emos) window.emos.close();
emos = window.open(url, 'win_ref', 'width=505,height=400,resizable=yes,scrollbars=yes');
}
function close_nemo() {
if (window.emos) window.emos.close();
}

function openSpellChecker(txtarea) {

        var message = txtarea;
        var speller = new spellChecker(message);
        speller.openChecker();

}

function getMozSelection(txtarea) {
        var selLength = txtarea.textLength;
        var selStart = txtarea.selectionStart;
        var selEnd = txtarea.selectionEnd;
        if (selEnd==1 || selEnd==2) selEnd=selLength;
        return (txtarea.value).substring(selStart, selEnd);
}
function mozWrap(txtarea, lft, rgt) {
        var selLength = txtarea.textLength;
        var selStart = txtarea.selectionStart;
        var selEnd = txtarea.selectionEnd;
        if (selEnd==1 || selEnd==2) selEnd=selLength;
        var s1 = (txtarea.value).substring(0,selStart);
        var s2 = (txtarea.value).substring(selStart, selEnd)
        var s3 = (txtarea.value).substring(selEnd, selLength);
        txtarea.value = s1 + lft + s2 + rgt + s3;
}

function IEWrap(lft, rgt) {
        strSelection = document.selection.createRange().text;
        if (strSelection!="") {
        document.selection.createRange().text = lft + strSelection + rgt;
        }
}

function wrapSelection(txtarea, lft, rgt) {
        if (document.all) {IEWrap(lft, rgt);}
        else if (document.getElementById) {mozWrap(txtarea, lft, rgt);}
}
function wrapSelectionWithLink(txtarea) {
        var my_link = prompt("Enter URL:","http://");
        if (my_link != null) {
                lft="[url=" + my_link + "]";
                rgt="[/url]";
                wrapSelection(txtarea, lft, rgt);
        }
        return;
}
function wrapSelectionWithImg(txtarea) {
        var my_link = prompt("Enter URL For Image:","http://");
        if (my_link != null ) {
        var my_size = prompt("Image Width (max: 500px), leave empty to get size automatic:","0");
          if ( my_size > 0 )
            {
            if ( my_size > 500 ) { my_size = 500; }
            lft="[img:" + my_size +"]" + my_link + "[/img]";
            }
          else {
            lft="[img]" + my_link + "[/img]";
          }
                txtarea.value += lft+" "
                txtarea.value.focus()
        }
        return;
}


function overIcon(iconItem){
        iconItem.style.border='1px solid #000000';
        iconItem.style.backgroundColor='#CCCCCC';
}

//Function to moving off button icon
function outIcon(iconItem){
        iconItem.style.border='1px solid #E6E7F2';
        iconItem.style.backgroundColor='#E6E7F2';
}


function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}

function expandit(curobj, hide) {
  if(document.getElementById(curobj)) {
      folder=document.getElementById(curobj).style;
  } else {
    if(ns6==1||operaaa==true) {
      folder=curobj.nextSibling.nextSibling.style;
    } else {
      folder=document.all[curobj.sourceIndex+1].style;
    }
   }
  if(folder.display=="none")
  {
    folder.display="";
  } else {
    folder.display="none";
  }
  if(hide) {
    var hide_objects = hide.split(",");
    for(i=0; i<hide_objects.length; i++) {
      hide_objects[i]=hide_objects[i].replace(/^\s*(.*)/, "$1");
      hide_objects[i]=hide_objects[i].replace(/(.*?)\s*$/, "$1");
      if(document.getElementById(hide_objects[i])) {
        hidden=document.getElementById(hide_objects[i]).style;
        if(hidden.display=="") {
          hidden.display="none";
        }
      }
    }
  }
}
