Don't use onclick use the accordion's activate event.
$( "#accordion" ).accordion({
autoHeight: false, collapsible: true, active: false,
activate:function(event, ui ){
if ($(ui.newPanel).find('.highlight').length>0)
$('html, body').animate({
scrollTop: $(ui.newPanel).find('.highlight').offset().top
}, 2000);
},
beforeActivate:function(e,ui)
{
//if statement to check if you want to stop the accordion from opening
e.preventDefault();
}
});
Used the scrolling code from jQuery scroll to element