// This script downloaded on the internet and written by
// (i need to look this up!) and slightly modified by me

// This javascript is similar to window.onload except
// it executes once the DOM has loaded, not once the page has 
// loaded. This is faster than waiting for the page and images to
// load. If the browser does not support these methods, it defaults
// to using window.onload. Because of the problems with only being
// able to use window.onload once on a page, i have included another
// javascript function that overcomes this, also downloaded from
// the internet, called makeDoubleDelegate().

// The rest of this file is the javascript just as I grabbed it, 
// except I replaced the 
// window.onload=onDomContentLoaded;
// within the scripting to reflect the other function...
// makeDoubleDelegate(window.onload,onDOMContentLoaded);
// and I inserted the call to the function that starts the heat map,
// initHeatMap; at the bottom


//
//


// Create event 'ondomload' which runs once when the dom of the document
// has loaded. This is before images and other long downloads start.
// If the browser does not support this, falls back to window.onload.
// (Firefox and Opera)
if(document.addEventListener) {
    document.addEventListener("DOMContentLoaded", onDOMContentLoaded, false);
}

// (Safari)
if(/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            onDOMContentLoaded(); // call the onload handler
        }
    }, 10);
}
// (Internet Explorer(using conditional comments))
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        onDOMContentLoaded(); // call the onload handler
    }
};
/*@end @*/
window.onload = makeDoubleDelegate(window.onload,onDOMContentLoaded);
function onDOMContentLoaded(){
    // quit if this function has already been called
    if (arguments.callee.done) return;
    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;
    ondomload();
}

window.ondomload = initHeatMap;


