function insertTag(frmElm,startTag,endTag) {
   if (typeof frmElm.selectionStart == "number") {
         selectedtext = startTag+frmElm.value.substring(frmElm.selectionStart,frmElm.selectionEnd)+endTag;
         frmElm.value = frmElm.value.substring(0,frmElm.selectionStart)+selectedtext+frmElm.value.substr(frmElm.selectionEnd);
   }
   else if (document.selection) {
           frmElm.focus();
           r = document.selection.createRange();
           r.text = startTag+r.text+endTag;}
   else frmElm.value += startTag+endTag;
}

function quoteText(qid,qname){
	var text = document.getElementById('quote'+qid).innerHTML;
	var string = "[quote="+qname+"]"+text+"[/quote]";
	tinyMCE.get('content_text_forum').execCommand('mceSetContent',false, string );
	location.href = '#reply';
}

tinyMCE.init({
        // General options
        mode : "exact",
        elements : "content_text_forum",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,hr,bullist,numlist,image,media,|,link,unlink,emotions,|,print,|,formatselect",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_disable : "cut,paste,help,code,fontselect,         fontsizeselect,styleselect,visualaid,anchor,newdocument,separator,sub,sup,indent,outdent",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false

});

tinyMCE.init({
        // General options
        mode : "exact",
        elements : "content_text_comment",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,hr,emotions,bullist,numlist,|,formatselect,|,print,|,",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_disable : "cut,paste,image,help,code,fontselect,         fontsizeselect,styleselect,visualaid,anchor,newdocument,separator,sub,sup,indent,outdent",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false

});

tinyMCE.init({
        // General options
        mode : "exact",
        elements : "content_text_signatur",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,hr,emotions,bullist,numlist,|,formatselect,|,print,|,link,unlink",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_disable : "cut,paste,image,help,code,fontselect,         fontsizeselect,styleselect,visualaid,anchor,newdocument,separator,sub,sup,indent,outdent",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false

});

tinyMCE.init({
        // General options
        mode : "exact",
        elements : "content_text_profile",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,hr,emotions,link,unlink,|,image,media,bullist,numlist,|,formatselect,|,print,|,",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_disable : "cut,paste,help,code,fontselect,         fontsizeselect,styleselect,visualaid,anchor,newdocument,separator,sub,sup,indent,outdent",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false

});

document.onclick = check2;

function check(e){
	var tagName = e.srcElement.tagName;
	if(tagName != "IMG"){
		document.getElementById('notifications_mail').style.display = 'none';
		document.getElementById('notifications_invites').style.display = 'none';
		document.getElementById('notifications_replies').style.display = 'none';
		document.getElementById('profilemenu').style.display = 'none';
	}
}

function check2(e){
	var tagName = e.target.nodeName;
	if(tagName != "IMG"){
		document.getElementById('notifications_mail').style.display = 'none';
		document.getElementById('notifications_invites').style.display = 'none';
		document.getElementById('notifications_replies').style.display = 'none';
		document.getElementById('profilemenu').style.display = 'none';
	}
}
