
	window.addEvent("domready", function() {
		var links = $$(".hiddenform");
		links.each(function(link) {
			if (link.tagName.toLowerCase() == "a")
				var id = link.get("href");
			else
				var id = link.get("rel");
			var div = $$(id)[0];
			div.addClass("form-hiddenform");
			link.addEvent("click", function(e) {
				e.stop();
				this.blur();
				var div = $$(this.get("href"))[0];
				showHiddenForm(div);
			});
		});
		$$(".form-hiddenform").each(function(f) { 
			f.setStyle("display", "none"); 
			var submitP = f.getElements(".hiddenform-submit");
			if (submitP.length > 0) {
				submitP = submitP[0];
				var cancel = new Element("input", {type: "button", value: 'Sluiten'});
				cancel.addEvent("click", function() {
					hideHiddenForm(f);
				});
				cancel.inject(submitP);
			}
		});
	});
	
	function showHiddenForm(div) {
		if (div.getStyle("display") == "none") {
			div.setStyle("display", "block");
			$$("#content > *").each(function(e) {
				if (e.className.indexOf("hiddenform") == -1)
					e.setOpacity(0.5);
			});
			var height = div.getSize().y;
			div.setStyles({
				overflow: "hidden",
				height: 0,
				opacity: 1
			});
			var fx = new Fx.Morph(div, {duration: 400, transition: Fx.Transitions.Circ.easeOut});
			fx.start({
				height: height,
				opacity: 1
			}).chain(function() {
				div.setStyles({
					overflow: "visible",
					height: "auto"
				});
				var input = div.getElements("input");
				if (input.length > 0) {
					input[0].focus();
				}
			});
		}
	}
	
	function hideHiddenForm(div) {
		if (div.getStyle("display") == "block") {
			$$("#content > *").each(function(e) {
				if (e.className.indexOf("hiddenform") == -1)
					e.setOpacity(1);
			});
			div.setStyles({
				height: div.getSize().y,
				overflow: "hidden"
			});
			var fx = new Fx.Morph(div, {duration: 400, transition: Fx.Transitions.Circ.easeOut});
			fx.start({
				height: 0,
				opacity: 0
			}).chain(function() {
				div.setStyles({
					height: "auto",
					display: "none",
					overflow: "visible"
				});
			});
		}
	}
	
	function hideHiddenForms() {
		var forms = $$(".form-hiddenform");
		forms.each(function(form) {
			hideHiddenForm(form);
		});
	}