if you have only one document open in photoshop, app.activeDocument
is the "activeDocument"
if you want the "active document" to be a different document you have to reference it as follows
consider you have two documents already open "picture1.jpg" and picture2.jpg"
you would set each one to be the active document as follows
app.activeDocument = app.documents[0] // set to picture1.jpg
app.activeDocument = app.documents[1] // set to picture2.jpg
the indexing (the numbers) refer to the open documents and start from the left most document tab([0]) and the end document tab ([n]) n being the document relative to the first counting from 0
need any more help just ask
sorry i am assuming your are new to programming.