added BeforeHide and BeforeShow events