There is one obvious problem here: You are comparing the typeof your counter variable with the name of your stamp - these two things have nothing to do with each other. In the original script, the line
if(typeof(oDoc.stampCounter) == "undefined")
is trying to determine if the variable has been created. If it does not exist yet, then the next line
oDoc.stampCounter = 0;
will initialize it to zero.
You need to go back to the dynamic stamp basics to get a better understanding of how dynamic stamps work. The best way to learn is Thom's book: http://www.pdfscripting.com/public/All-About-PDF-Stamps-in-Acrobat-and-Paperless-Workflows-The-Book.cfm
Is the JavaScript you've posted your whole script? If so, there is a lot missing that is necessary to create a dynamic stamp.
Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com