dialog window opens or closes upon refresh depending on session variables