function domakefck(name,toolbar,hoogte, basepath, customconfpath) {
	CKEDITOR.replace( name,
		{
		    customConfig : customconfpath,
		    toolbar: toolbar,
		    height:hoogte,
		    baseHref: basepath,
	        on :
	        {
	            instanceReady : function( ev )
	            {
	                // Output paragraphs as <p>Text</p>.
	                this.dataProcessor.writer.setRules( 'p',
	                    {
	                        indent : false,
	                        breakBeforeOpen : true,
	                        breakAfterOpen : false,
	                        breakBeforeClose : false,
	                        breakAfterClose : true
	                    });
	            }
	        }		    
		});
}

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 (typeof(document.getElementById('notifications')) != "undefined" && document.getElementById('notifications').innerHTML.indexOf(txt) < 0) {
		jQuery("#notifications").append('<div class="notice">' + txt + '</div>');
	}
	jQuery("#notifications").fadeIn();
}

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(){
				var onComplete = options.onComplete; //option.onComplete can change in func();
				func();
				if(typeof(onComplete)=='function'){
					onComplete();
				}
				dialogWindow.close();
			})
			buttonDiv.append(button);
		});
		mainDiv.append(buttonDiv);
		jQuery('body').append(mainDiv);
		internalReCenter();
	}
}
