Hi - I'm using this script for an accordion on a website. I'd like to know if it's possible to amend the script so that when the title of each accordion block is clicked on the block will closed again? Currently each accordion block only closes when the title of another accordion block is clicked on.

/*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;
}
});


I'm new to JS so would really appreciate any help! Many thanks.