Hi - I need to amend the script below so that when the title of each accordion block is clicked on the block will close again. Currently each accordion block only closes when the title of another accordion block is clicked on. I think it's missing a slideToggle somewhere but not sure where to put it! I'm a JS newbie so would really appreciate any help! Many thanks.

/*Accordion*/
$('.accordion ul').hide();
$('.accordion li:first').find('a.title').addClass('tab-active');
$('.accordion ul:first').hide();
$('.accordion li a.title').click(

function() {
var checkElement = $(this).next();
if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
$('accordion').find('a.title').removeClass('tab-active');
return false;
}
if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('.accordion ul:visible').slideUp(500);
checkElement.slideDown(500);
$('.accordion').find('a.title').removeClass('tab-active');
$(this).addClass('tab-active');
return false;
}
});