The DOCTYPE declaration informs the browser which particular "code flavor" your page uses. You can read about DOCTYPE's here:
http://htmlhelp.com/tools/validator/doctype.html
If you don't specify a DOCTYPE, the the browser will use it's defaults. In some cases, with IE for example, this means that you can get away with code that isn't strictly "correct". IE won't complain.
XHTML is very strict, intentionally. I prefer it because it forces me to write clean, tight code.
I don't see anything about your script that XHTML wouldn't like, at first glance. So there is probably something else on the page that isn't XHTML-friendly. You can use the following validator to troubleshoot your page:
http://validator.w3.org/
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37