tinyMCE.init({ 
mode : "textareas",
theme : "advanced",
language : "nl",
plugins : "bbcode,paste",
height : "220",
editor_selector : /mcebody/,
theme_advanced_buttons1 : "bold,italic,undo,redo,pastetext,selectall", 
theme_advanced_buttons2 : "", 
theme_advanced_buttons3 : "", 
theme_advanced_toolbar_location : "top", 
theme_advanced_toolbar_align : "left", 
theme_advanced_statusbar_location : "bottom", 
theme_advanced_styles : 'Quote=quoteStyle',
content_css : "/css/bbcode.css", 
remove_linebreaks : false,
force_br_newlines : true,
force_p_newlines : false,
entity_encoding : "raw",
init_instance_callback : "tinyMceLoaded",
paste_use_dialog : false,
paste_auto_cleanup_on_paste : true,
paste_text_sticky : true,
forced_root_block : '',
        paste_preprocess : function(pl, o) {
            // Content string containing the HTML from the clipboard
            o.content = o.content;
        },
        paste_postprocess : function(pl, o) {
            // Content DOM node containing the DOM structure of the clipboard
             o.node.innerHTML = o.node.innerHTML + "\n";
        },
setup : function(ed) 
        {    ed.onInit.add(function(ed)
            {    ed.pasteAsPlainText = true;
                ed.controlManager.setActive("pastetext", true);
            });
           }
}); 

tinyMCE.init({ 
mode : "textareas",
theme : "advanced",
language : "nl",
editor_selector : /mcemodbody/,
content_css : "/css/bbcode.css", 
height : "480",
plugins : "pagebreak,paste,style,advimage,advlink,inlinepopups,media,imagemanager",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,link,unlink,anchor,cleanup,image,insertimage,media,|,bullist,numlist,|,undo,redo,|,selectall,cut,copy,paste,pastetext,|,help,code", 
theme_advanced_buttons2 : "", 
theme_advanced_buttons3 : "", 
paste_auto_cleanup_on_paste : true,
theme_advanced_toolbar_location : "top", 
theme_advanced_toolbar_align : "left", 
theme_advanced_statusbar_location : "bottom", 
remove_linebreaks : false,
forced_root_block : '',
entity_encoding : "raw",
paste_text_sticky : true,
forced_root_block : '',
        paste_preprocess : function(pl, o) {
            // Content string containing the HTML from the clipboard
            o.content = o.content;
        },
        paste_postprocess : function(pl, o) {
            // Content DOM node containing the DOM structure of the clipboard
             o.node.innerHTML = o.node.innerHTML + "\n";
        },
setup : function(ed) 
        {    ed.onInit.add(function(ed)
            {    ed.pasteAsPlainText = true;
                ed.controlManager.setActive("pastetext", true);
            });
           }
}); 

function do_select_images(uri) {
	window.open(uri,'imageSelector','width=610,height=620,scrollbars=yes,toolbar=no,location=no,resizable=yes'); 
}

function doSubmit() 
{	
	aForm	=	document.forms[0];
	bForm	=	document.forms[2];

	/* Valideer de inscreen form submit: */
	if( bForm != undefined && bForm.name == 'loginform' ) 
	{
		if( bForm.login_username.value != '' && bForm.login_password.value != '' ) {
			bForm.submit();
		} else {
			aForm.submit();
		}
	} 
	else 
	{
		aForm.submit();
	}
}
function validateDelete(confirmMessage) 
{
	return confirm( confirmMessage );
}
function LoginButton() {
	document.write('<div class="login_button"><a href="javascript:doSubmit();" title="Login op Leefwijzer">Login</a></div>');
}
function ActivateButton() {
	document.write('<div class="activateButton"><a href="javascript:document.activation.submit();" title="Activeer Profiel">Activeer</a></div>');
}

function showQuickReply() 
{
	qrActivate	= document.getElementById('qr_activate');
	qcForm		= document.getElementById('qr_form');
	
	qrActivate.style.display = 'none';
	qcForm.style.display = 'block';
	setTimeout("tinyMCE.execCommand('mceFocus', false, 'body');", 1000);
}
function tinyMceLoaded() {
	//tinyMCE.execCommand('mceFocus', false, 'body');
}

function checkAll(name) {
	var chks = document.getElementsByName( name );
	for (var i = 0; i < chks.length; i++)
	{
		chks[i].checked = true;
	}
}

function uncheckAll(name) {
	var chks = document.getElementsByName( name );
	for (var i = 0; i < chks.length; i++)
	{
		chks[i].checked = false;
	}
}
function rowOver(row) 
{
	row.style.backgroundColor='#FAFAFA';
}
function rowOut(row) 
{
	row.style.backgroundColor='#ffffff';
}
function rowDown(row) 
{
	row.style.backgroundColor='#F6F6F6';
}
function rowDown(row) 
{
	row.style.backgroundColor='#F6F6F6';
}

// Is the content set in the editor? Will be called from tinyMCE, see config above
var initComplete = false;
var contentOk = false; 
function setContentOk(editor_id, body, doc) {
    contentOk=editor_id;
}

// This is the function that moves the cursor to the end of content
function moveCursorToEnd(editor_id) {
    inst = tinyMCE.getInstanceById(editor_id);
    tinyMCE.execInstanceCommand(editor_id,"selectall", false, null);
    if (tinyMCE.isMSIE) {
        rng = inst.getRng();
        rng.collapse(false);
        rng.select();
    } 
    else {
        sel = inst.getSel();
        sel.collapseToEnd();
    }
}

// This function allows a delay for FF
// This is a bit ugly: The editor's id was set in the var contentOk in setContentOk()
function move() { 
    if(contentOk==false) {
        window.setTimeout("move()",100);
        return null;
    }
    moveCursorToEnd(contentOk);
	initComplete = true;
} 

function emailDummy( type )
{
	if( type == 'in' )
	{
		document.getElementById('nieuwsbrief').style.color = "#000";
		if( document.getElementById('nieuwsbrief').value == 'je email adres' )
		{
			document.getElementById('nieuwsbrief').value = '';
		}
	} 
	else if( type == 'out' && document.getElementById('nieuwsbrief').value == 'je email adres' ) 
	{
		document.getElementById('nieuwsbrief').style.color = "#666";
	}
	else if(  type == 'out' && document.getElementById('nieuwsbrief').value == '' ) 
	{
		document.getElementById('nieuwsbrief').value = 'je email adres';
		document.getElementById('nieuwsbrief').style.color = "#666";	
	}
}

function socialMedia( width, height )
{
	window.open ('', "socialmedia","location=0,status=0,scrollbars=1,width="+width+",height="+height); 	
}

function printSubmitButton(class_name,title,text,formname) {
	document.write('<div class="'+class_name+'"><a href="javascript:void(0)" onclick="document.forms[\''+formname+'\'].submit();" title="'+title+'">'+text+'</a></div>');
}

function printRegQuestionButton(class_name,title,text,formname) {
	document.write('<div class="'+class_name+'"><a href="javascript:void(0)" onclick="document.getElementById(\'hidden_action\').value = \'reload_question\';document.forms[\''+formname+'\'].submit();" title="'+title+'">'+text+'</a></div>');
}

function printSuggestionQuestionButton(class_name,title,text,formname) {
	document.write('<div class="'+class_name+'"><a href="javascript:void(0)" onclick="document.getElementById(\'hidden_action\').value = \'reload_question\';document.forms[\''+formname+'\'].submit();" title="'+title+'">'+text+'</a></div>');
}

var currentView = '';
function rebuildDropdown(selectform) {
	if( currentView != '' && currentView != 'x' )
	{
		document.getElementById('TR_link_sub_category_'+currentView).style.display = 'none';	
	}
	currentView = selectform[selectform.selectedIndex].value;	
	if( selectform[selectform.selectedIndex].value != 'x' )
	{
		document.getElementById('TR_link_sub_category_'+currentView).style.display = '';
		document.getElementById('TR_link_sub_category_'+currentView).className='';

	}
}

