document.write only works on an "open" document. When the end of the file is reached, the document is closed for writing (at least through those outdated means). I believe most browsers will just ignore an attempt to write to a closed document, but some may throw an error.
Other issues at hand here are that you are not calling document.write() but trying to access yet another field (or child) of that function, getElementById, which doesn't exist.
Finally, in your last bit of code, you are attempting to write the value of v which is a local variable to the calculate() function so it doesn't really exist outside that scope.
A few other people have already pointed out remedies to this, namely document.getElementById('total').innerHTML = <your value>. Accessing innerHTML is not the cleanest way to do things, but it works in all major browsers and is easy to understand.
Hope that a little bit of explanation about what was going is helpful. Good luck! (Think about learning one of the many javascript frameworks if you get much further into it -- they can be a great help. Prototype.js, jQuery, Dojo, MooTools, etc., are all good.)