using $_SERVER['DOCUMENT_ROOT'] is a good idea for includes and internal file paths, but to a visitor, the path doesnt exists
you can just use a slash in front of the img paths to mimic the effect
for example:
visitor is on this page:
example.org/dir/subdir/page.php
and there is the following img tag:
<img src="image.gif">
the browser will look for the image at:
example.org/dir/subdir/image.gif
we all know that...
but change the img tag to this:
<img src="/image.gif">
and now the browser will look for the image at:
example.org/image.gif
the leading slash means a file path is relative to the root. in the case of urls, the root is the domain itself.
i almost ALWAYS specify all img paths like that. it will save you a lot of headaches.