Check http://jsfiddle.net/XRYLk/3/
I added mouseleave so in case the mouse was over it when first function fires up, it will set timer on mouseleave.
jQuery:
$("button").click(function() {
$("div").slideToggle("slow");
});
setTimeout(hidepanel, 4000);
function hidepanel(){
if($('div').is(':hover') === false){ $('div').slideToggle(); }
}
$('div').mouseleave(function(){ setTimeout(hidepanel, 4000); });