Refactored popup login in jQuery