"Object expected" is pretty much equivalent to "Null pointer exception" in java. Something is null.
There is way too much code there to give any reasonable answer. If you could get a line number, or approximate region from where the error is coming, post that segment of code, but this is too much. Particularly with scriptlet code mixed in as well.
This is a really great suite of tools and I use it every single day. (No, I do not work for Mozilla)
<a href="http://labryssystems.net/pblog/index.php" target="_blank" rel="nofollow">Javaville Gazette</a><br />Non-cooperation with evil is a duty. -- Mahatma Gandhi