I recommend using strophe.js. For communicating directly with a different server and bypassing the same origin policy of javascript you could use strophe with flxhr plugin, which is a neat flash based workaround. So no connection manager setup (webserver proxy to punjab and so on) is required on your server.
I also recommend the book "Professional XMPP Programming with JavaScript and jQuery". It comes with a whole lot of sample javascript/html applications code.