Fixing the positioning of the popup dialog

Instead of using hardcoded width, get the actual size of the div, then
add space for scrollbar.