
function insertTXT(event,str)
{
  var doc = ws_get_editor();
      var agent = navigator.userAgent.toUpperCase();
    if(navigator.appName.charAt(0)=="M")
    {
        window.editorWindow.focus();
        var o = doc.selection.createRange();
        o.pasteHTML(str);
        window.emojihelp.focus();

    } else 
    if(navigator.appName.charAt(0)=="O")
    {
       ws_exe(event, 'InsertHTML', false, str);

    }  else if (agent.indexOf("SAFARI")>-1)
    {
        ws_exe(event, 'InsertText', false, str);
    } else {
        window.editorWindow.getSelection().getRangeAt(0).insertNode(document.createTextNode(str));
    }
    return ;
}



function ws_exe( event ,command, param1, param2)
{
  var doc = ws_get_editor();
    busy = false;
if (!busy)
    {

        doc.execCommand(command, param1, param2);
        
        event.preventDefault();
        event.returnValue = false;
        
        //theDiv.contentEditable = 'true';
        
    }
    
    return false;
}


function ws_get_editor()
{
    var agent = navigator.userAgent.toUpperCase();
    iframe = document.getElementById('editorWindow');
    if(agent.indexOf("SAFARI") == -1)
    doc = iframe.contentWindow.document;
    else doc = iframe.contentDocument;
    return doc;
}
    function ws_edit_getIFrameDocument(aID){
      if (document.getElementById(aID).contentDocument){  
        return document.getElementById(aID).contentDocument;
      } else {
        //alert('here');
        iframe = document.getElementById(aID);
        return iframe.contentWindow.document;
       }
     }
    function ws_edit_doPost(form,vname)
    {
        html = ws_edit_getIFrameDocument("editorWindow").body.innerHTML;
         for(var i=0; i<form.length; i++){
          if (form[i].name == vname){
            form[i].value = html;
            }
        }
    }
    function ws_pretend_href(url)
    {
        window.open(url,'_blank');
        return false;
    }