JS handling of flash messages - first working version