Here is a list of sample codes to show different ways to create windows and dialogs. You can view source of each example, even edit it and test your modification immediatly in your browser. Just click again on the link to open a new window/dialog with the modified code. Each window uses a javascript function to get a new id and DO NOT call setDestroyOnClose().
You can open the debug window if you want to see some debug outputs.

This sample opens a window with green div on the right as content. It will keep the same size and position. Close the window to restore the div in the page.
It also uses a window observer to restore the div after closing the window.

This sample opens a confirm dialog with the default alert theme (alert.css). width/okLabel are specified and also ok/cancel callback function.
Height is not set so the dialog will fit content's height. It also change ok/cancel button class (CSS above).

This advanced sample opens a login window with a nice effect if login fails. The window update also its height to display an error message to avoid scrollbars.
The login window design is done in the HTML file with display:none.
Here is the login HTML code (see also login CSS file):