Index: trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js
===================================================================
--- trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js	(revision 1069)
+++ trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js	(revision 1073)
@@ -72,11 +72,8 @@
     //{ "tag": "bdo", "actions": [  ] },
     //{ "tag": "blockquote", "actions": [  ] },
-    { "tag": "body", "actions": [ "onbeforeunload",
-                                  "onload",
-                                  "onunload",
-                                  //"onerror",
-                                  "onscroll",
+    { "tag": "body", "actions": [ "onclick",
                                   "onpagehide",
                                   "onpageshow",
+                                  "onscroll",
                                   "onundo" ] },
     { "tag": "button", "actions": [ "onclick",
@@ -206,15 +203,4 @@
 var autoquestDoLog = false;
 
-/*var matchedTags = ["A", "ABBR", "ACRONYM", "ADDRESS", "AREA", "B", "BIG", "BLOCKQUOTE", "BODY",
-                   "BUTTON", "CAPTION", "CENTER", "CITE", "CODE", "COL", "COLGROUP", "DD", "DEL",
-                   "DFN", "DIR", "DIV", "DL", "DT", "EM", "FIELDSET", "FORM", "H1", "H2", "H3",
-                   "H4", "H5", "H6", "HR", "I", "IMG", "INPUT", "INS", "KBD", "LABEL", "LEGEND",
-                   "LI", "LINK", "MAP", "MENU", "NOFRAMES", "NOSCRIPT", "OBJECT", "OL",
-                   "OPTGROUP", "OPTION", "P", "PRE", "Q", "S", "SAMP", "SELECT", "SMALL", "SPAN",
-                   "STRIKE", "STRONG", "SUB", "SUP", "TABLE", "TBODY", "TD", "TEXTAREA", "TFOOT",
-                   "TH", "THEAD", "TR", "TT", "U", "UL", "VAR"];*/
-/*var actions = ['onclick', 'ondblclick', 'onkeypress', 'onkeydown', 'onkeyup',
-'onmouseout' , 'onmousemove' ,'onfocus','onscroll'];  // edit*/
-
 /**
  * stores the structure of the GUI of the current page
@@ -254,4 +240,6 @@
             autoquestGUIModel =
                 addEventHandlingAndGetJSONRepresentation(document.documentElement, "");
+            
+            addDefaultEventHandling();
             
             // recall sending data each 100 seconds to ensure, that for browser windows staying
@@ -394,5 +382,4 @@
     var tagName = getTagName(node);
     var action;
-    var parameters;
     var i;
     var k;
@@ -408,11 +395,5 @@
                 }
                 else {
-                    parameters = { action : action, path : nodePath};
-                    if (jQuery(node).on) {
-                        jQuery(node).on(action.substring(2), parameters, handleJQueryEvent);
-                    }
-                    else {
-                        jQuery(node).bind(action.substring(2), parameters, handleJQueryEvent);
-                    }
+                    registerEventHandler(node, nodePath, action);
                 }
             }
@@ -423,10 +404,10 @@
 /**
  * adapts the event handling attributed provided by the action parameter so that it calls
- * the {@link #handleEvent(node, action, path, even)} function in the case the event occurs.
+ * the {@link #handleEvent(node, action, path, event)} function in the case the event occurs.
  * Either the method creates an appropriate onxxx attribute on the node if there is none, or it
  * adds a call to the function as first thing called by the onxxx attribute.
  * 
  * @param node     the node of the DOM structure that shall be equipped with event handling
- * @param nodePath the path to node within the DOM-structure of the HTML-site
+ * @param nodePath the path to the node within the DOM-structure of the HTML-site
  * @param action   the event for which event handling shall be enabled
  */
@@ -443,4 +424,46 @@
             node.setAttribute(action, value + ' ' + oldValue);
         }
+    }
+}
+
+/**
+ * registers an event handler using jQuery for the provided action on the given object so that it
+ * calls the {@link #handleJQueryEvent(event)} function in the case the event occurs.
+ * 
+ * @param node     the node of the DOM structure that shall be equipped with event handling
+ * @param nodePath the path to the node within the DOM-structure of the HTML-site
+ * @param action   the event for which event handling shall be enabled
+ */
+function registerEventHandler(node, nodePath, action) {
+    var parameters = { action : action, path : nodePath};
+    if (jQuery(node).on) {
+        jQuery(node).on(action.substring(2), parameters, handleJQueryEvent);
+    }
+    else {
+        jQuery(node).bind(action.substring(2), parameters, handleJQueryEvent);
+    }
+}
+
+/**
+ * adds default event handling functionality for receiving load, unload, and other document
+ * relevant events. The registration for events is done depending on the availability of jQuery.
+ * If jQuery is available and must therefore be used, then the registration is done on the window
+ * object. Otherwise, the appropriate attributes of the document's body tag are changed
+ */
+function addDefaultEventHandling() {
+    var body;
+
+    if (typeof jQuery === 'undefined') {
+        body = document.getElementsByTagName("body").item(0);
+        adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onbeforeunload");
+        adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onload");
+        adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onunload");
+        //adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onerror");
+    }
+    else {
+        registerEventHandler(window, "/html[0]/body[0]", "onbeforeunload");
+        registerEventHandler(window, "/html[0]/body[0]", "onload");
+        registerEventHandler(window, "/html[0]/body[0]", "onunload");
+        //registerEventHandler(body, "/html[0]/body[0]", "onerror");
     }
 }
@@ -626,5 +649,4 @@
         for (i = 0; i < node.parentNode.childNodes.length; i++) {
             if (node.parentNode.childNodes[i].tagName === node.tagName) {
-                index++;
                 // if === also returns true if the nodes are not identical but only equal,
                 // this may fail.
@@ -632,4 +654,5 @@
                     break;
                 }
+                index++;
             }
         }
