Index: trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js
===================================================================
--- trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js	(revision 880)
+++ trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js	(revision 881)
@@ -26,4 +26,9 @@
  */
 var autoquestDestination;
+
+/**
+ * an ID that is more or less unique for the client
+ */
+var autoquestClientId;
 
 /**
@@ -287,5 +292,5 @@
         
         log("reading client id");
-        clientId = readClientId();
+        clientId = getClientId();
         if ((clientId) && (clientId !== "")) {
             message += "\"clientId\":\"" + clientId + "\",";
@@ -320,6 +325,6 @@
         }
         
-        log("sending message");
-        request.open("POST", autoquestDestination, true);
+        request.open("POST", autoquestDestination, false);
+        request.setRequestHeader("Content-Type", "application/json");
 
         log("sending " + message);
@@ -368,100 +373,32 @@
 
 /**
- * reads the id of the client from the cookies.
- * 
- * @returns the client id or null, if none is found in the cookies
- */
-function readClientId() {
-    var cookie = document.cookie;
-    
-    var expectedCookieName = getClientIdCookieName();
-    
-    var cookiename = null;
-    var startIndex = 0;
-    
-    var clientId = null;
-
-    do {
-        cookie = cookie.substring(startIndex, cookie.length);
-        cookiename = cookie.substr(0, cookie.search('='));
-        startIndex = cookie.search(';') + 1;
-        
-        while (cookie.charAt(startIndex) === ' ') {
-            startIndex++;
-        }
-    }
-    while ((startIndex > 0) && (cookiename !== expectedCookieName));
-    
-    if (cookiename === expectedCookieName) {
-        clientId = cookie.substr(cookie.search('=') + 1, cookie.search(';'));
-        if (clientId === "") {
-            clientId = cookie.substr(cookie.search('=') + 1, cookie.length);
-        }
-    }
-    
-    if ((!clientId) || (clientId === "") || (clientId.search(getClientIdPrefix()) !== 0)) {
-        clientId = generateClientId();
-        storeClientId(clientId);
-    }
-    
-    return clientId;
-}
-
-
-/**
- * stores the provided client id in the cookies
- * 
- * @param clientId the client id to be stored
- */
-function storeClientId(clientId) {
-    if ((clientId) && (clientId !== "")) {
-        var expiry = new Date();
-        // 10 years should be sufficient :-)
-        expiry = new Date(expiry.getTime() + 1000*60*60*24*365*10);
-        document.cookie = getClientIdCookieName() + '=' + clientId +
-            '; expires=' + expiry.toGMTString()+';';
-    }
-}
-
-/**
- * returns the name of the cookie used to store the client id
- * 
- * @returns as described
- */
-function getClientIdCookieName() {
-    return document.URL + "/quest-htmlmonitor/quest-client-id";
-}
-
-/**
- * generates a client id based on the result of {@link #getClientIdPrefix()} and the current time
- * stamp
+ * generates a client id based on several information retrieved from the environment. The client
+ * id is not always unique
  * 
  * @returns the client id
  */
-function generateClientId() {
-    return getClientIdPrefix() + new Date().getTime();
-}
-
-/**
- * generates a client id prefix based on the user agent and the navigators platform. The prefix
- * is a simple checksum of the concatenation of both strings
- * 
- * @returns the client id prefix
- */
-function getClientIdPrefix() {
-    // create something like a more or less unique checksum. It is sufficient, if it differs
-    // only often, but not always, because it is concatenated with a time stamp, which differs
-    // much more often.
-    var prefixStr = navigator.userAgent + "_" + navigator.platform;
-    var prefixId = prefixStr.length;
+function getClientId() {
+    var clientIdStr;
+    var clientId;
     var i = 0;
     
-    for (i = 0; i < prefixStr.length; i++) {
-        prefixId += prefixStr.charCodeAt(i);
-    }
-    
-    // ensure, that a string is created and not a long. Otherwise, it can not be checked, if an
-    // existing client id starts with the client id prefix and can therefore be reused.
-    return prefixId.toString();
+    if (!autoquestClientId) {
+        // create something like a more or less unique checksum.
+        clientIdStr =
+            navigator.appCodeName + navigator.appName + navigator.appVersion +
+            navigator.cookieEnabled + navigator.language + navigator.platform +
+            navigator.userAgent + navigator.javaEnabled() + window.location.protocol +
+            window.location.host + new Date().getTimezoneOffset();
+
+        clientId = clientIdStr.length;
+
+        for (i = 0; i < clientIdStr.length; i++) {
+            clientId += clientIdStr.charCodeAt(i);
+        }
+        
+        autoquestClientId = clientId;
+    }
+
+    return autoquestClientId;
 }
 
