not sure about a general solution, though i suppose you could store the name of the first field on a page in a database and retrieve the appropriate name at runtime. you could then pass this value into your function.
re your template issue, i remember a link i found a while ago about making the body tag editable.
i haven't tried it but here is a link...
1454.htm