$(function() {
    // når en klikker på "les mer":
    $('a.aftermath-item').click(function() {
	var thisPop = '#aftermath-item-pop-' + $(this).attr('id').slice(-3); // tresiffret "idnr" legges til i xsl-filen for å få unike id's
	$('#page_margins').before('<div id="aftermath-bg-opac"></div>');
	$(thisPop).animate({ height: 'toggle' }, 300);
    });
    // når en klikker på "Lukk":
    $('.aftermath-item-close').click(function() {
	var thisPop = '#aftermath-item-pop-' + $(this).attr('id').slice(-3);
	$(thisPop).animate({ height: 'toggle' }, 200);
	$('#aftermath-bg-opac').remove();
    });
    // når en klikker på krysset:
    $('.aftermath-item-cross-close').click(function() {
	var thisPop = '#aftermath-item-pop-' + $(this).attr('id').slice(-3);
	$(thisPop).animate({ height: 'toggle' }, 200);
	$('#aftermath-bg-opac').remove();
    });
    // hovereffekt på det hvite krysset øverst til høyre i popup-boksen:
    $('.aftermath-item-cross-close').hover(
	function () {
	    $(this).attr('src', 'http://www.kvalitetogprioritering.no/_public/images/cross-red.png');
	}, 
	function () {
	    $(this).attr('src', 'http://www.kvalitetogprioritering.no/_public/images/cross-white.png');
	}
    );
});
