﻿$(document).ready(function () {
	var maxitems = 5;
	var more = true;

	if ($(".category_list") == null) {
		return;
	}

	$(".category_list").each(function () {
		var thiscatList = $(this);
		var i = 0;

		$(this).children().each(function () {
			if (i >= maxitems) {
				$(this).hide();
			}
			i++;
		});

		if (i > maxitems) {
			thiscatList.parent().append('<a class="showmorerel" href="#" >Meer...</a>');
		}

		thiscatList.parent().children('.showmorerel').click(function () {
			if (more) {
				thiscatList.children().each(function () {
					$(this).slideDown();
				});

				thiscatList.parent().children('.showmorerel').html('<a class="showmorerel" href="#">Minder...</a>');
				more = false;
			} else {
				i = 1;
				thiscatList.children().each(function () {
					if (i > maxitems) {
						$(this).slideUp();
					}
					i++;
				});

				thiscatList.parent().children('.showmorerel').html('<a class="showmorerel" href="#">Meer...</a>');
				more = true;
			}
			return false;
		});
	});
});
