{
this.editor_document.selectionStart = open;
this.editor_document.selectionEnd   = open + text.length;
this.editor_document.scrollTop      = st;
}
}
else if ( ( document.selection && document.selection.createRange ) || this._ie_cache )
{
var sel  = this._ie_cache ? this._ie_cache : document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.select();
}
else
{
this.editor_document.value += text;
}
this._ie_cache = null;
};
this.show_all_emoticons = function()
{
if ( typeof( this.emoticon_window_id ) != null )
{
this.emoticon_window_id = window.open( ipb_var_base_url + "act=legends&CODE=emoticons&_lite=1&editor_id=" + editor_id,"Legends","width=250,height=500,resizable=yes,scrollbars=yes");
}
else
{
this.emoticon_window_id.focus();
}
return false;
};
this.insert_emoticon = function( emo_id, emo_image, emo_code, event )
{
emo_code = ipsclass.un_htmlspecialchars( emo_code );
this.wrap_tags_lite( " " + emo_code, " ");
if ( this.is_ie )
{
if ( IPS_Lite_Editor[ this.editor_id ].emoticon_window_id != '' && typeof( IPS_Lite_Editor[ this.editor_id ].emoticon_window_id ) != 'undefined' )
{
IPS_Lite_Editor[ this.editor_id ].emoticon_window_id.focus();
}
}
};
this.resize_editorbox = function( direction )
{
var inc_value	   = 100;
var current_height = parseInt( this.text_obj.style.height );
var new_height     = 0;
current_height     = current_height ? current_height : 200;
if ( current_height >= 50 )
{
if ( direction == 'up' )
{
new_height = current_height - inc_value;
}
else
{
new_height = current_height + inc_value;
}
if ( new_height > 149 )
{
this.text_obj.style.height = new_height + 'px';
}
}
};
};
function ips_editor_events()
{
}
ips_editor_events.prototype.button_onmouse_event = function(e)
{
if ( is_ie )
{
e = ipsclass.cancel_bubble(e, true);
}
if ( e.type == 'click' )
{
IPS_Lite_Editor[this.editor_id].format_text(e, this.cmd, false, true);
}
IPS_Lite_Editor[this.editor_id].set_button_context(this, e.type);
};
ips_editor_events.prototype.editor_window_onfocus = function(e)
{
this.has_focus = true;
};
ips_editor_events.prototype.editor_window_onblur = function(e)
{
this.has_focus = false;
};
ips_editor_events.prototype.editor_document_onkeypress = function(e)
{	
if ( e.ctrlKey )
{
switch (String.fromCharCode(e.charCode).toLowerCase())
{
case 'b': cmd = 'bold';      break;
case 'i': cmd = 'italic';    break;
case 'u': cmd = 'underline'; break;
default: return;
}
e.preventDefault();
IPS_Lite_Editor[this.editor_id].apply_formatting(cmd, false, null);
return false;
}
};

