Code cleanup & added clickToClose to jQuery dialog