Recieving Error: 'theForm' is undefined

I have an ASP.NET application which is giving the following JavaScript

'theForm' is undefined

However, when I did a View Source I noticed that ASP.NET added the following

<script type="text/javascript">
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
// -->

I was told in a previous posting that the reason for the error is that the
script containing the declaration and assigning of a value to it occur
before the

Nathan Sokalski