I finally found something that seems to work as I want it to. In the following code (after all "other" subitems have slid up) a check is made whether the current menu-item contains a sub-item that is visible. If not it is slid up, else down.
$(function() {
$('ul.dropdown > li > a').click(function () {
var $el = $('ul', this);
$('.dropdown > li > ul').not($el).slideUp();
if( $(this).parent().find('.sub-menu ').is(":visible"))
{$(this).parent().find('.sub-menu ').slideUp();}
else
{$(this).parent().find('.sub-menu ').slideDown();}
});
$(".dropdown > li > a").click(function (e) {
e.preventDefault();
});
});
Because it explicitly targets the a element of class "dropdown" (i.e. the main-menu-items), the default behaviour of the subitems is untouched. (Because of that, the this.parent() is needed to look for sub-menu-items.)