function domakefck(name,toolbar,hoogte, basepath, customconfpath) {
	var oFCKeditor = new FCKeditor( name );
	oFCKeditor.BasePath = basepath;
	oFCKeditor.Config['CustomConfigurationsPath'] = customconfpath;
	oFCKeditor.ToolbarSet = toolbar;
	oFCKeditor.Height = hoogte ;
	oFCKeditor.EnableSafari = true ;
	oFCKeditor.ReplaceTextarea();
	FCKeditorAPI = null;
	__FCKeditorNS = null;
}
var FCKeditorLoaded = false;
function FCKeditor_OnComplete(editorInstance) {
	FCKeditorLoaded = true;
}
function switchEditors(ID) {
	if(!document.all){
		if(!FCKeditorLoaded) {
	    	setTimeout('switchEditors(\'' + ID + '\')', 500);
	    	return;
	  	}
	 	DoSwitchEditors(document.getElementById(ID));
	}
}
function DoSwitchEditors(oNode) {
	var i;
	for (i = 0; i < oNode.childNodes.length;i++) {
		childNode = oNode.childNodes.item(i);
		editor = FCKeditorAPI.GetInstance(childNode.name);
		if (editor && editor.EditorDocument && editor.EditMode == FCK_EDITMODE_WYSIWYG) {
			editor.SwitchEditMode();
			editor.SwitchEditMode();
		}
		DoSwitchEditors(childNode);
	}
}
var postLoadedScripts = new Array();
/**
 * Met deze methode wordt getest of een javascript geladen is of niet, indien niet dan wordt hij geladen.
 * Deze methode kan oa gebruikt worden als je een js library wil gebruiken maar je wil hem niet in
 * standardheader.vm van ContentFrame stoppen omdat hij niet vaak gebruikt wordt.
 */
function ensureJSLoad(src, onLoad){
	var scripts = document.getElementsByTagName("script");
	for(i=0; i<scripts.length; i++){
		if(scripts[i].src.match(src)){
			return;
		}
	}
	for(i=0; i<postLoadedScripts.length; i++){
		if(postLoadedScripts[i].match(src)){
			return;
		}
	}
	postLoadedScripts.push(src);
   	jQuery.ajax({
   		url: src,
   		dataType: 'script',
   		async: false,
   		cache: true
   	});
}

/**
 * Met deze methode wordt getest of een css geladen is of niet, indien niet dan wordt hij geladen.
 * Deze methode kan oa gebruikt worden als je een css bestand wil gebruiken maar je wil hem niet in
 * standardheader.vm van ContentFrame stoppen omdat hij niet vaak gebruikt wordt.
 */
function ensureCSSLoad(src){
	var links = document.getElementsByTagName("link");
	for(i=0; i<links.length; i++){
		if(links[i].href.match(src)){
			return;
		}
	}
	var head = document.getElementsByTagName("head")[0];
	var cssNode = document.createElement('link');
   	cssNode.type = 'text/css';
   	cssNode.rel = 'stylesheet';
   	cssNode.href = src;
   	cssNode.media = 'screen';
   	head.appendChild(cssNode);
}

function showNotice(txt) {
	if (document.getElementById('notificationareafix').innerHTML.indexOf(txt) < 0) {
		jQuery("#notificationareafix").append('<div>' + txt + '</div>');
	}
	jQuery("#notificationareafix").show('slow');
}

var dialogWindow = new function(){
	var dialogQueue = new Array();
	var isShowing = false;
	var mainDiv = null;
	var initDone = false;
	var defaultOptions = {
		message: 'Do you want to close this box?',
		buttons:{
			'Cancel': function(){alert('you pressed Cancel')},
			'OK': function(){alert('you pressed OK')}
		}
	};
	this.show = function(options) {
		var options = jQuery.extend(defaultOptions, options);
		if(isShowing){
			dialogQueue.push(options);
		} else {
			isShowing = true;
			internalShow(options);
		}
	};
	this.close = function(){
		mainDiv.hide(); //TODO remove mainDiv from body
		mainDiv = null;
		var options = dialogQueue.pop();
		if(options){
			internalShow(options);
		} else {
			isShowing = false;
		}
	}
	internalReCenter = function(){
		if(mainDiv){
			jQuery(mainDiv).css (
				{
					top: jQuery(window).height()/2 - mainDiv.height()/2 + jQuery(document).scrollTop() + 'px',
					left: jQuery(window).width()/2 - mainDiv.width()/2 + jQuery(document).scrollLeft() + 'px'
				}
			);
		}
	}
	var internalShow = function(options){
		if(!initDone){
			jQuery(window).scroll( function() {
				internalReCenter();
			});
			jQuery(window).resize( function() {
				internalReCenter();
			});
			initDone = true;
		}
		mainDiv = jQuery('<div>').attr({ id: 'dialogWindow' });
		mainDiv.append(jQuery('<p>').append(options.message));
		var buttonDiv = jQuery('<div>').attr({ id: 'dialogWindowButtonRow' });
		jQuery.each(options.buttons, function(name, func){
			button = jQuery('<button>').append(name);
			button.click(function(){
				func();
				dialogWindow.close();
			})
			buttonDiv.append(button);
		});
		mainDiv.append(buttonDiv);
		jQuery('body').append(mainDiv);
		internalReCenter();
	}
}