**Note**

This is just copied (with some mods) from Alertify. Let's treat this as an external library and not code review.