Moved dialog HTML code into javascript for better performance