var forum_error_5001 ='De editor staat niet in de goede modus,<br/>Het is niet mogelijk een qoute in te voegen. ';
var forum_error_5002 ='Er is geen title ingevuld!';
var forum_error_5003 ='Er is een ongeldige categorie geselecteerd!';
var forum_error_5004 ='Je bent vergeten een reden op te geven!';
var forum_error_5005 ='Er is geen bericht in gevoerd!';

function toggleforum(forumid){
	var toggleinprogress;
	if(toggleinprogress != 1){
		toggleinprogress =1;
		Effect.toggle($('forum_body_'+forumid), 'blind',{afterFinish:function(){toggleinprogress=0;}});
	}
	//alert(forumid);
}

function DisplayError(errorid){
		if($('thread_reply_status')!=null){ var statusdiv = $('thread_reply_status')}
		if($('new_topic_form_status')!=null){ var statusdiv = $('new_topic_form_status')}
		statusdiv.className = 'err';
		statusdiv.innerHTML= errorid;
		new Effect.Highlight(statusdiv.id, {startcolor:'#ff99ff', endcolor:'#999999'})
		return false;
}

function insert_quote(postid)
{
	var oEditor = FCKeditorAPI.GetInstance('thread_reply_message') ;
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ){

		var handlerFunc = function(t) {
    			oEditor.InsertHtml(t.responseText);
		}

		var errFunc = function(t) {
		alert('Error ' + t.status + ' -- ' + t.statusText);
		}
		new Ajax.Request('/modules/module_forum.php', {parameters:'forum_is_ajax=true&action=getquote&postid='+postid, onSuccess:handlerFunc, onFailure:errFunc});
		
	}
	else{
		alert(forum_error_5001) ;

	}
}
function clearbox(){
	var oEditor = FCKeditorAPI.GetInstance('thread_reply_message') ;
	oEditor.EditorDocument.body.innerHTML = '';
}
function PostThreadMessage(){
	if($('title')!=null){
		if($('title').value==0){
			return DisplayError(forum_error_5002);
			return false;
		}
	}
	if($('topic_title')!=null){
		if($('topic_title').value==0){
			return DisplayError(forum_error_5002);
			return false;
		}
	}
	if($('categoryid')!=null){
		if($('categoryid').value==0){
			return DisplayError(forum_error_5003);
			return false;
		}
	}
	if($('reason')!=null){
		if($('reason').value == 0){
			return DisplayError(forum_error_5004);
			return false;
		}
	}
	if($('topic_message')!=null){
	var oEditor = FCKeditorAPI.GetInstance('topic_message') ;
		if(oEditor.EditorDocument.body.innerHTML.replace(/<br>/g, "").length ==0){
			return DisplayError(forum_error_5005);
			}
	}
	if($('thread_reply_message')!=null){
	var oEditor = FCKeditorAPI.GetInstance('thread_reply_message') ;
		if(oEditor.EditorDocument.body.innerHTML.replace(/<br>/g, "").length ==0){
			return DisplayError(forum_error_5005);
			}
	}
	if($('thread_message')!=null){
		var oEditor = FCKeditorAPI.GetInstance('thread_message') ;
		if(oEditor.EditorDocument.body.innerHTML.replace(/<br>/g, "").length ==0){
			return DisplayError(forum_error_5005);
			}
	}
	
	return true;
}

var forumupdater = new Ajax.PeriodicalUpdater('forum_stats_container', '/modules/module_forum.php',
  {
    method: 'post',parameters:"forum_is_ajax=true&action=getstats",
    frequency: 1,
    decay: 2
  });
forumupdater.stop();
