$(function() {

	/* equalize sidebar and content heights */
	//$.equalHeights($("#content").height() + $("#content").offset().top + 40);

	/* keyword placeholder text */
	$("fieldset.aandoeningoptrefwoord input.autocomplete").addClass("empty").val("type een trefwoord").focus(function() {
		$(this).removeClass("empty");
		if ($(this).val() == "type een trefwoord") {
			$(this).val("");
		}
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).addClass("empty").val("type een trefwoord");
		}
	});

	$("fieldset.aandoeningoptrefwoord input.autocomplete").keypress(function(e) {
		if (e.keyCode == 13) {
			e.preventDefault();
			$("input.next").click();
		}
	});

	$("fieldset.aandoeningoplichaamsdeel input:radio").click(function(e) {
		$("fieldset.aandoeningoptrefwoord input.autocomplete").val("");
	});

	/* aandoeningen tree */
	$("fieldset.aandoeningoplichaamsdeel ul ul, fieldset.aandoeningoplichaamsdeel ul div.column").hide();

	$("fieldset.aandoeningoplichaamsdeel h2, fieldset.aandoeningoplichaamsdeel h3").each(function(i, obj) {
		var text = $(obj).text();
		var button = $("<button id='button" + i + "'>toon " + text + "</button>").toggle(function(e) {
			$(this)
				.addClass("open")
				.text("verberg " + text)
				.parent()
				.nextAll("ul, div.column")
				.show();
		}, function(e) {
			$(this)
				.removeClass("open")
				.text("toon " + text)
				.parent()
				.nextAll("ul, div.column")
				.hide();
		});
		$(obj).wrapInner("<label for='button" + i + "'></label>").append(button);
	});

});

