adding javascript on show and hide