A generic javascript onbeforeunload handler. Will check a list of supplied conditions to determine if it is safe to unload.