function triggerChangeEvents()
{
   for ( var i = 0; i < window.document.forms.length; ++i )
   {
      var curForm = window.document.forms[ i ];
      if ( ! curForm.triggeredChangeEvents )
      {
	      for ( var j = 0; j < curForm.elements.length; ++j )
	      {
	         var curElement = curForm.elements[ j ];
	         invokeChangeEvents( curElement );
	      }
	      curForm.triggeredChangeEvents = true;
	  }
   }
}

function copyEventFunction( fn )
{
   //window.alert( fn );
   
   if ( ! fn ) return function() {};   

   var code = new String( fn );
   var firstBracePos = code.indexOf( '{' );
   var lastBracePos = code.lastIndexOf( '}' );
   code = code.substring( firstBracePos + 1, lastBracePos );
      
   return new Function( "", code );
}

function invokeChangeEvents( theInput )
{
   if ( ! theInput.type ) return;
   
   var type = theInput.type.toLowerCase();
   if ( type == 'submit' || type == 'button' ) return;
   
   if ( ! theInput.myOnChange )
   {      
      theInput.myOnChange = copyEventFunction( theInput.onchange );
   }   
   theInput.myOnChange();
   
   if ( ! theInput.myOnClick )
   {
      theInput.myOnClick = copyEventFunction( theInput.onclick );
   }
   theInput.myOnClick();
}

function disableSubmits( curForm )
{
	  for ( var j = 0; j < curForm.elements.length; ++j )
      {
         var curElement = curForm.elements[ j ];
         if( curElement.type )
         {
           var type = curElement.type.toLowerCase();
   		  if ( type == 'submit' || type == 'button' )
   		  {
   		 	 curElement.disabled = true;
   		  }
         }
      }
}