Implementing dynamic autoresize for popups.