It seems like you could probably replace this with [jquery's toggle](http://api.jquery.com/toggle/).