function bncWizard(id,actionUrl,layoutUrl,title,onDone,onLoadPanels,onValidate,onClose,onShowList,translations) {
	if (typeof(id) == 'object') {
		// Er zijn geen losse parameters aan de functie meegegeven maar 1 config
		// de 1ste parameter noemen we nu config en alle attribuut worden nu hernoemd naar dezelfde 
		// namen als bij de losse parameters
		var config = id;
		var id = config.id;
		var actionUrl = config.actionUrl;
		var layoutUrl = config.layoutUrl;
		var title = config.title;
		var onDone = config.onDone;
		var onLoadPanels = config.onLoadPanels;
		var onValidate = config.onValidate;
		var onClose = config.onClose;
		var onShowList = config.onShowList;
		var translations = config.translations;
	} else {
		// Als er geen config is meegegeven een leeg object aanmaken zodat er wel kan worden 
		// gecheckt op het attribuut van het object
		var config = {};
	}
	this.initWizard = function(mode,keynr) {
		var now = new Date();
		this.dialog.mode = mode;
		switch(mode) {
			case 0: // add
				document.getElementById(this.dialog.id+"form").action = this.dialog.actionUrl+"&fn=update&noCache="+now.getTime();
				this.dialog.canComplete = false;
				this.dialog.hasList = false;
				this.dialog.canComplete = false;
				this.dialog.setHeader(this.transtabel["AddTitle"].replace(/%p1%/gi,this.dialog.mytitle));
				if(this.dialog.onValidate!=null) {
					this.dialog.validate = this.validator;
				} else {
					this.dialog.validate = function() { return true; };
				}
				this.loadUrl(this,this.dialog.layoutUrl+"?HttpProxy_fn=setedit&HttpProxy_nieuw=1",this.dialog.id+"container",true,true);		
				break;
			case 1: // edit
				document.getElementById(this.dialog.id+"container").innerHTML = "";
				document.getElementById(this.dialog.id+"form").action = this.dialog.actionUrl+"&fn=update&noCache="+now.getTime();			
				if(keynr==null) {
					this.dialog.hasList = true;
					this.dialog.showList = true;
					this.dialog.canComplete = true;
					this.dialog.cfg.queueProperty("buttons", this.dialog.wizardButtons1);
					this.dialog.setHeader(this.transtabel["EditTitle"].replace(/%p1%/gi,this.dialog.mytitle));
					if(this.dialog.onValidate!=null) {
						this.dialog.validate = this.validator;
					} else {
						this.dialog.validate = function() { return true; };
					}
					this.removeSelectlist();
					this.loadUrl(this,this.dialog.layoutUrl+"?HttpProxy_fn=showlist&HttpProxy_fntarget=edit",this.dialog.id+"list",true,false);
				} else {
					this.dialog.hasList = false;
					this.dialog.showList = false;
					this.dialog.canComplete = true;
					this.dialog.cfg.queueProperty("buttons", this.dialog.wizardButtons6);
					this.dialog.setHeader(this.transtabel["EditTitle"].replace(/%p1%/gi,this.dialog.mytitle));
					if(this.dialog.onValidate!=null) {
						this.dialog.validate = this.validator;
					} else {
						this.dialog.validate = function() { return true; };
					}
					this.loadUrl(this,this.dialog.layoutUrl+"?HttpProxy_fn=setedit&HttpProxy_keynr="+keynr,this.dialog.id+"container",true,true);
				}		
				break;
			case 2: // delete
				document.getElementById(this.dialog.id+"container").innerHTML = "";
				document.getElementById(this.dialog.id+"form").action = this.dialog.actionUrl+"&fn=delete&noCache="+now.getTime();			
				this.dialog.hasList = true;
				this.dialog.showList = true;
				this.dialog.canComplete = true;
				this.dialog.cfg.queueProperty("buttons", this.dialog.wizardButtons7);
				this.dialog.setHeader(this.transtabel["DeleteTitle"].replace(/%p1%/gi,this.dialog.mytitle));
				this.dialog.validate = function() {
					var radioGrp = document.forms[this.id+"form"].selectlist;
					if(radioGrp!=null&&((radioGrp.length!=null&&radioGrp.length>0)||radioGrp.value!=null)) {
						var keynr = -1;
						if(radioGrp.value!=null&&radioGrp.checked) {
							keynr = radioGrp.value;
						} else {
							for(i=0; i<radioGrp.length; i++) {
								if(radioGrp[i].checked) {
									keynr = radioGrp[i].value;
									break;
								}
							}
						}
						if(keynr!=-1) {
							return confirm(this.parent.transtabel["AskDelete"]);
						} else {
							alert(this.parent.transtabel["WarnSelect"]);
							return false;
						}
					}
					return false;
				};
				this.removeSelectlist();
				this.loadUrl(this,this.dialog.layoutUrl+"?HttpProxy_fn=showlist&HttpProxy_fntarget=delete",this.dialog.id+"list",true,false);		
				break;
		}
	}
	this.removeSelectlist = function() {
		/*
		 * als er nog een radiolist van de vorige keer bestaat, zetten we de waarden op -1
		 * want in het geval er nu geen radiolist wordt aangemaakt blijft de oude bestaan(!)
		 */
		var frmObj = document.forms[this.dialog.id+"form"];
		if(frmObj!=null) {
			var radioGrp = frmObj.selectlist;
			if(radioGrp!=null) {
				if(radioGrp.length!=null) {
					for(var i=0; i<radioGrp.length; i++) {
						radioGrp[i].value = "-1";
					}
				} else {
					radioGrp.value = "-1";
				}
			}
		}
	}
	this.loadUrl = function(wizardobj,url,id,show,initpanels) {
		var now = new Date();
		url += "&noCache="+now.getTime();
		var callback = {
			success:this.onLoadPanelsUrl,
			failure:this.onFailure,
			argument: {wizardobj:wizardobj, id:id, show:show, initpanels:initpanels}
		}
		var wizform = document.getElementById(wizardobj.dialog.id+"form");
		if(wizform.length!=0) {
			/*
			 * alleen POST als er iets te posten valt, anders krijg je respons error 411
			 */
			YAHOO.util.Connect.setForm(wizform);
			YAHOO.util.Connect.asyncRequest("POST", url, callback, "");
		} else {
			YAHOO.util.Connect.asyncRequest("GET", url, callback, "");
		}
	}
	this.onLoadPanelsUrl = function(o) {
		YAHOO.util.Connect.resetFormState;
		var wizardobj = o.argument.wizardobj;
		document.getElementById(o.argument.id).innerHTML = o.responseText;
		if(wizardobj.dialog.hasList&&wizardobj.dialog.showList) {
			document.getElementById(wizardobj.dialog.id+"list").style.display = "block";			
			document.getElementById(wizardobj.dialog.id+"container").style.display = "none";	
			if(wizardobj.dialog.onShowList!=null) {
				wizardobj.dialog.onShowList();
			}
		} else {
			document.getElementById(wizardobj.dialog.id+"list").style.display = "none";			
			document.getElementById(wizardobj.dialog.id+"container").style.display = "block";	
		}
		if(o.argument.initpanels) {
			wizardobj.initPanels(wizardobj);
			if(wizardobj.dialog.onLoadPanels!=null) {
				wizardobj.dialog.onLoadPanels();
			}
		} else {
			wizardobj.setButtons(wizardobj);
		}
		if(o.argument.show) {
			wizardobj.dialog.render();
			wizardobj.dialog.show();
		}
	}
	this.initPanels = function(wizardobj) {
		wizardobj.dialog.nofPanels = 0;
		wizardobj.dialog.firstPanel = 1;
		if(document.getElementById(wizardobj.dialog.id+"0")!=null) {
			wizardobj.dialog.firstPanel = 0;
		}
		wizardobj.dialog.curPanel = wizardobj.dialog.firstPanel;
		
		while(true) {
			panel = document.getElementById(wizardobj.dialog.id+(wizardobj.dialog.nofPanels+wizardobj.dialog.firstPanel));
			if(panel!=null) {
				panel.style.display = "none";
				wizardobj.dialog.nofPanels++;
			} else {
				break;
			}
		}
		if(wizardobj.dialog.nofPanels==0) {
			alert("Geen wizardpanelen gedefinieerd!");
			return;
		}
		document.getElementById(wizardobj.dialog.id+wizardobj.dialog.curPanel).style.display="block";

		if(!wizardobj.dialog.canComplete) {
			if(wizardobj.dialog.nofPanels==1) {
				wizardobj.dialog.canComplete = true;
			}
		}
		wizardobj.setButtons(wizardobj);
	}
	this.validator = function(dialog) {
		if(this.hasList && this.showList) {
			return false;
		} else {
			return this.onValidate(this.submitting?null:this.curPanel);
		}
	}
	this.setButtons = function(wizardobj) {
		if(!wizardobj.dialog.canComplete) {
			// alleen bij toevoegen, dus geen rekening houden met listpanel
			if(wizardobj.dialog.curPanel==wizardobj.dialog.firstPanel) {
				// volgende, annuleren
				wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons1);
			} else {
				// vorige, volgende, annuleren
				wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons2);
			}
		} else {
			if(wizardobj.dialog.hasList&&wizardobj.dialog.showList) {
				if(wizardobj.dialog.mode==1) {
					// volgende, annuleren
					wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons1);
				} else {
					// verwijderen, annuleren
					wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons7);
				}
			} else {
				if(wizardobj.dialog.curPanel==wizardobj.dialog.firstPanel) {
					// als we op het eerste panel staan en hasList is true, dan toch 'vorige' laten zien
					if(wizardobj.dialog.hasList) {
						if(wizardobj.dialog.nofPanels==1) {
							// vorige, volgende (disabled), voltooien, annuleren
							wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons5);
						} else {
							// vorige, volgende, voltooien, annuleren
							wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons4);
						}
					} else {
						if(wizardobj.dialog.nofPanels==1) {
							// voltooien, annuleren
							wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons6);
						} else {
							// volgende, voltooien, annuleren
							wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons3);
						}
					}
				} else {
					// we staan niet op het eerste panel, dus altijd een 'vorige'; staan we op het laatste
					// panel, dan geen vorige
					if(wizardobj.dialog.curPanel!=(wizardobj.dialog.nofPanels-1+wizardobj.dialog.firstPanel)) {
						// vorige, volgende, voltooien, annuleren
						wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons4);
					} else {
						// vorige, volgende (disabled), voltooien, annuleren
						wizardobj.dialog.cfg.queueProperty("buttons", wizardobj.dialog.wizardButtons5);
					}
	
				}
			}
		}
		wizardobj.dialog.render();
		var abuttons = wizardobj.dialog.getButtons();
		if(abuttons!=null) {
			for(var i=0; i<abuttons.length; i++) {
				if(abuttons[i]._onclickAttributeValue==null) {
					abuttons[i]._button.className="button-disabled"
				}
			}
		}
	}
	this.handleCancel = function(evt,obj) {
		this.cancel();
	}
	this.handleSubmit = function(evt,obj) {
		this.submitting = true;
		this.submit();
		this.submitting = false;
	}
	this.handlePrevious = function(evt,obj) {
		// binnen de handlers slaat this op het dialog object!
		if(this.curPanel>this.firstPanel) {
			if(this.validate==null||this.validate(this)) {
				document.getElementById(this.id+this.curPanel).style.display="none";
				this.curPanel--;
				document.getElementById(this.id+this.curPanel).style.display="block";
				this.parent.setButtons(this.parent);
			}
		} else {
			if(this.hasList) {
				this.showList = true;
				this.parent.loadUrl(this.parent,this.layoutUrl+"?HttpProxy_fn=showlist",this.id+"list",false,false);		
			}
		}
	}
	this.handleNext = function(evt,obj) {
		if(this.hasList&&this.showList) {
			var radioGrp = document.forms[this.id+"form"].selectlist;
			if(radioGrp == null) {
				/*
				 *  als we in een speciaal geval meerdere selects willen doen, gebruiken we
				 *  HttpProxy_selectlist, deze wordt ook gepost
				 */
				radioGrp = document.forms[this.id+"form"].HttpProxy_selectlist;
			}
			if(radioGrp!=null&&((radioGrp.length!=null&&radioGrp.length>0)||radioGrp.value!=null)) {
				var keynr = -1;
				if(radioGrp.value!=null&&radioGrp.checked) {
					keynr = radioGrp.value;
				} else {
					for(i=0; i<radioGrp.length; i++) {
						if(radioGrp[i].checked) {
							keynr = radioGrp[i].value;
							break;
						}
					}
				}
				if(keynr!=-1) {
					this.showList = false;
					this.parent.loadUrl(this.parent,this.layoutUrl+"?HttpProxy_fn=setedit&HttpProxy_keynr="+keynr,this.id+"container",false,true);
				} else {
					alert(this.parent.transtabel["WarnSelect"]);
				}
			}		
		} else {
			if(this.curPanel<(this.nofPanels-1+this.firstPanel)) {
				if(this.validate==null||this.validate(this)) {
					document.getElementById(this.id+this.curPanel).style.display="none";
					this.curPanel++;
					document.getElementById(this.id+this.curPanel).style.display="block";
					// als we alle panels hebben gehad bij nieuwe invoer dan kunnen we ook voltooien klikken
					if(this.canComplete==false&&this.curPanel==(this.nofPanels-1+this.firstPanel)) {
						this.canComplete = true;
					}
					this.parent.setButtons(this.parent);
				}
			}
		}
	}
	this.onSuccess = function(o) {
		YAHOO.util.Connect.resetFormState();
		var obj = eval("("+o.responseText+")");
		if(obj["xml.error"]!=null) {
			o.argument.wizardobj.dialog.show();
			alert(obj["xml.error"]);
		} else {
			if(o.argument.wizardobj.dialog.onDone!=null) {
				o.argument.wizardobj.dialog.onDone(o);
			}
		}
	}
	this.onUpload = function(o) {
		// the response is embedded in <pre> tags, so remove them...
		var response = o.responseText.replace(/<pre>/gi,"").replace(/<\/pre>/gi,"");
		var obj=eval("("+response+")");
		if(obj["xml.error"]!=null) {
			o.argument.wizardobj.dialog.show();
			alert(obj["xml.error"]);
		} else {
			if(o.argument.wizardobj.dialog.onDone!=null) {
				o.argument.wizardobj.dialog.onDone(o);
			}
		}
	}
	this.onFailure = function(o) {
		YAHOO.util.Connect.resetFormState;
		alert(o.statusText);
	}
	this.onHide = function() {
		if(this.onClose!=null) {
			this.onClose(this);
		}
	}
	this.transtabel = new Array();
	this.transtabel["Previous"] = (translations==null||translations["Previous"]==null)?"Vorige":translations["Previous"];
	this.transtabel["Next"] = (translations==null||translations["Next"]==null)?"Volgende":translations["Next"];
	this.transtabel["Cancel"] = (translations==null||translations["Cancel"]==null)?"Annuleren":translations["Cancel"];
	this.transtabel["Finish"] = (translations==null||translations["Finish"]==null)?"Voltooien":translations["Finish"];
	this.transtabel["Delete"] = (translations==null||translations["Delete"]==null)?"Verwijderen":translations["Delete"];
	this.transtabel["WarnSelect"] = (translations==null||translations["WarnSelect"]==null)?"Maak eerst een keuze":translations["WarnSelect"];
	this.transtabel["AskDelete"] = (translations==null||translations["AskDelete"]==null)?"Weet je zeker dat je deze wilt verwijderen?":translations["AskDelete"];
	this.transtabel["EditTitle"] = (translations==null||translations["EditTitle"]==null)?"%p1% wijzigen":translations["EditTitle"];
	this.transtabel["AddTitle"] = (translations==null||translations["AddTitle"]==null)?"%p1% toevoegen":translations["AddTitle"];
	this.transtabel["DeleteTitle"] = (translations==null||translations["DeleteTitle"]==null)?"%p1% verwijderen":translations["DeleteTitle"];
	/*
	 * check of div al bestaat
	 */
	if(document.getElementById(id)!=null) {
		alert("Wizard is al geinstantieerd: "+id);
		return;
	}
	/*
	 * create divs
	 */
	wizdiv = document.createElement("div");
	wizdiv.id = id;
	wizform = document.createElement("form");
	wizform.name = id+"form";
	wizform.id = id+"form";
	wizform.method = "POST";
	wizform.action = "";
	wizform.enctype = "application/x-www-form-urlencoded; charset=UTF-8";
	wizdiv.appendChild(wizform);

	wizlistdiv = document.createElement("div");
	wizlistdiv.id = id+"list";
	wizlistdiv.className = "bncwizardlist";
	wizform.appendChild(wizlistdiv);
	wizcontainerdiv = document.createElement("div");
	wizcontainerdiv.id = id+"container";
	wizcontainerdiv.className = "bncwizardcontainer";
	wizform.appendChild(wizcontainerdiv);
	document.body.appendChild(wizdiv);
	if(config.width == undefined) {
		config.width = "600px";
	}
	this.dialog = new YAHOO.widget.Dialog(	id, 
											{ width : config.width,
											  fixedcenter : true,
											  visible : false,
											  modal:true,
											  constraintoviewport : true,
											  zindex: 100000
											 } );

	// zonder Voltooien
	this.dialog.wizardButtons1 = [ { text:this.transtabel["Next"], handler:this.handleNext }, { text:this.transtabel["Finish"], handler:null }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	this.dialog.wizardButtons2 = [ { text:this.transtabel["Previous"], handler:this.handlePrevious }, { text:this.transtabel["Next"], handler:this.handleNext }, { text:this.transtabel["Finish"], handler:null }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	// met Voltooien
	this.dialog.wizardButtons3 = [ { text:this.transtabel["Next"], handler:this.handleNext }, { text:this.transtabel["Finish"], handler:this.handleSubmit }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	this.dialog.wizardButtons4 = [ { text:this.transtabel["Previous"], handler:this.handlePrevious }, { text:this.transtabel["Next"], handler:this.handleNext }, { text:this.transtabel["Finish"], handler:this.handleSubmit }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	this.dialog.wizardButtons5 = [ { text:this.transtabel["Previous"], handler:this.handlePrevious }, { text:this.transtabel["Next"], handler:null }, { text:this.transtabel["Finish"], handler:this.handleSubmit }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	this.dialog.wizardButtons6 = [ { text:this.transtabel["Finish"], handler:this.handleSubmit }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	// met Verwijderen
	this.dialog.wizardButtons7 = [ { text:this.transtabel["Delete"], handler:this.handleSubmit }, { text:this.transtabel["Cancel"], handler:this.handleCancel } ];
	
	this.dialog.onDone = onDone;
	this.dialog.onLoadPanels = onLoadPanels;
	this.dialog.actionUrl = actionUrl;
	this.dialog.layoutUrl = layoutUrl;
	this.dialog.callback = {success: this.onSuccess, failure: this.onFailure, upload: this.onUpload, argument: {wizardobj:this}};
	if(onValidate!=null) {
		this.dialog.onValidate = onValidate;
	}
	this.dialog.onClose = onClose;
	this.dialog.onShowList = onShowList;
	
	this.dialog.hideEvent.subscribe(this.onHide);
	
	this.dialog.id = id;
	this.dialog.mytitle = title;
	this.dialog.nofPanels = 0;
	this.dialog.curPanel = 0;
	this.dialog.firstPanel = 1;
	this.dialog.parent = this;
	this.dialog.submitting = false;
}

bncWizard.prototype.addItem = function() {
	this.initWizard(0);
}
bncWizard.prototype.editItem = function(keynr) {
	this.initWizard(1,keynr);
}
bncWizard.prototype.deleteItem = function() {
	this.initWizard(2);
}