var shorten = {
	byId : function(id, length, closure) {
		shorten.truncate(jQuery('#' + id), length, closure);
	},
	byClass : function(className, length, closure) {
		jQuery('.' + className).each(function() {
			shorten.truncate(jQuery(this), length, closure);
		});
	},
	truncate : function(obj, length, closure) {
		if(obj.text().length > length) {
			var value = obj.text().slice(0, length);
			if(value.substring(length - 1, length) == ' ')
				value = value.substring(0, length - 1);
			if(closure)
				value += closure;
		};
		obj.html(value);
	}
};
var news = {
	check : function(id) {
		var container = jQuery('#' + id);
		var title = container.children('.title');
		var contents = container.children('.contents');
		if(contents.children().size() == 0)
			title.hide();
	}
};

$(function() {
	jQuery('#workfield_list li, #workfields li, .sitemap_level1 #element3 .sitemap_level3 li').reverseOrder();
	// netbook - beamer class switcher
	$('input.class-switch-to').each(function(){
		$(this).click(function(){
			//$('div.wing').attr('id',$(this).attr('value'));
			$('div.wing').removeClass('highres netbook').addClass($(this).attr('value'));
			$('div.content').removeClass('highres netbook').addClass($(this).attr('value'));
		})
	});

	// Navigation
	$('#navigation-meetings li.main').menu({
		dropdown : '.subelements',
		effect : 'slideDown',
		swapTarget : 'a'
	});
	
	showWingAdditionalResults('.showWingAdditionalResults');
	
});

function showWingAdditionalResults(selector){
	$(selector).toggle(
		function(){
			$(this).parent().children('ul.WingAdditionalResults').slideDown();
			$(this).text('Verberg resultaten');
		},
		function(){
			$(this).parent().children('ul.WingAdditionalResults').slideUp();
			$(this).text('Toon resultaten');
		}
	)
}


