Based on answers from a previous question, both refer to mouse positions (x and y coordinates).
- relative to the document and
- relative to the viewport.
I have read through an article on QuirksMode, however I think I may be missing something. I have put together these two diagrams to help me in my understanding. Is my analysis correct?

Now scroll the document 250px…

Your analysis is correct (and those are very nice diagrams!)
However regarding your other post, they’re a bit more information than is necessary.
You just need to understand that there is a document and viewport. The document is stationary and the viewport moves with you (and has a scroll offset).
In principle, you could place your dialog window relative to either of these. Let’s pretend the dialog is a simple division element:
And let’s say you want to position that element relative to your button when clicked. You could use the document:
Or you could use the viewport:
You could even use the button itself. This has the added benefit of giving you a consistent position, regardless of where exactly the user clicked:
To apply that last method when you’re using jQuery’s dialog class, you can simply do this: