// Heatmap über die Seite legen, hierbei wird die Heatmap in einem
// 250x250-Raster gekachelt
function hm_loadHeatmap()
{
    // URL ermitteln, wie in hc.php
    var url = location.href;
    
    // Fenstergröße ermitteln
    /* from: http://www.quirksmode.org/viewport/compatibility.html#link2 */
    var width, height;
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight
    if (test1 > test2)
    {
        width = document.body.scrollWidth;
        height = document.body.scrollHeight;
    }
    else
    {
        width = document.body.offsetWidth;
        height = document.body.offsetHeight;
    }
    /* --- */
    
    // Body finden
    var body = document.getElementsByTagName('body')[0];
    // Kacheln erzeugen
    for (var x = 0; x < width; x += 250)
    {
        for (var y = 0; y < height; y += 250)
        {
            // Kachel durch ein absolut positioniertes <div> mit
            // Hintergrundgrafik darstellen
            var div = document.createElement('div');
            div.style.backgroundImage = 'url(http://t.heatmap.de/hiexternal.php?offsetX=' + x + '&offsetY=' + y + '&url=' + url + ')';
            div.style.position = 'absolute';
            div.style.width = '250px';
            div.style.height = '250px';
            div.style.left = x + 'px';
            div.style.top = y + 'px';
            body.appendChild(div);
        }
    }
}
// Optional: Heatmap direkt beim Laden der Seite anzeigen
//window.onload = hm_loadHeatmap;

