updated version. Popup now automatically centered, templates added and dynamic popups implemented