// For description, see ]

mw.loader.using( , function() {
	
	if ((mw.config.get('wgPageName').indexOf('Wikipedia:Articles_for_deletion/Log/') != -1) && (mw.config.get('wgAction') == 'view')) {
		$(document).ready( function () {
			mw.util.addPortletLink( 'p-cactions', '#', 'Hide closed', 'ca-hideClosed', "Hide closed discussions" );
			mw.util.addPortletLink( 'p-cactions', '#', 'Show closed', 'ca-showClosed', "Show closed discussions" );
			$('#ca-showClosed').hide();
			
			$('#ca-hideClosed').on('click', function() {
				$(".boilerplate.afd.xfd-closed").hide();
				$('#ca-showClosed').show();
				$('#ca-hideClosed').hide();
				return false;
			});
			
			$('#ca-showClosed').on('click', function() {
				$(".boilerplate.afd.xfd-closed").show();
				$('#ca-showClosed').hide();
				$('#ca-hideClosed').show();
				return false;
			});
			
		} );
	}	
});