reverted template and element id name changes.
tweaked code and markup for handling dialog visibility.