Although it makes no sense to use legacy javascript, when there are several prototype libraries available, this is a good starting point:
http://net.tutsplus.com/tutorials/javascript-ajax/from-jquery-to-javascript-a-reference/[
^]. You will see, that legacy javascript gives you nothing in exchange for the plenty of time you spend for nothing.
And if this is a learning task, than try to understand the code, and write it on your own.