(function() {

  this.AriadneJS = function() {

    var defaults = {
      live:  false,
      delay: 600
    }

    this.options = extendDefaults(defaults, arguments[0]);

  }

  // Public Methods
  AriadneJS.prototype.init = function() {

    document.onmousemove = handleMouseMove;
    var eventDoc, doc, body, pageX, pageY;

    function handleMouseMove(event) {

      event = event || window.event; // IE

      // Calculate pageX/Y if missing and clientX/Y available
      if (event.pageX == null && event.clientX != null) {
        eventDoc = (event.target && event.target.ownerDocument) || document;
        doc      = eventDoc.documentElement;
        body     = eventDoc.body;

        event.pageX = event.clientX +
          (doc && doc.scrollLeft || body && body.scrollLeft || 0) -
          (doc && doc.clientLeft || body && body.clientLeft || 0);
        event.pageY = event.clientY +
          (doc && doc.scrollTop  || body && body.scrollTop  || 0) -
          (doc && doc.clientTop  || body && body.clientTop  || 0 );
      }
      pageX = event.pageX
      pageY = event.pageY

    }

    document.onmousedown = handleMouseDown;

    function handleMouseDown(event) {
      console.log({e: event.toElement, X: event.x, Y: event.y});
    }

    window.onbeforeunload = handleBeforeUnload;

    var logger = setInterval(function() { console.log({cX: document.documentElement.clientWidth, cY: document.documentElement.clientHeight, X: pageX, Y: pageY}) }, this.options.delay);

    function handleBeforeUnload(event) { clearInterval(logger); }
  }

  // Private Methods
  function extendDefaults(source, properties) {

    var property;

    for (property in properties) {
      if (properties.hasOwnProperty(property)) {
        source[property] = properties[property];
      }
    }

    return source;

  }

  log = new AriadneJS();
  log.init();

}());
var AriadnesThread = [];

(function() {

  this.AriadneJS = function() {

    var defaults = {
      delay: 600
    }

    this.options = extendDefaults(defaults, arguments[0]);

  }

  AriadneJS.prototype.init = function() {

    var eventDoc, doc, body, pageX, pageY;
    var cX = document.documentElement.clientWidth;
    var cY = document.documentElement.clientHeight;

    // Mouse move
    document.onmousemove = handleMouseMove;

    function handleMouseMove(event) {

      event = event || window.event; // IE

      // Calculate pageX/Y if missing and clientX/Y available
      if (event.pageX == null && event.clientX != null) {
        eventDoc = (event.target && event.target.ownerDocument) || document;
        doc      = eventDoc.documentElement;
        body     = eventDoc.body;

        event.pageX = event.clientX +
          (doc && doc.scrollLeft || body && body.scrollLeft || 0) -
          (doc && doc.clientLeft || body && body.clientLeft || 0);
        event.pageY = event.clientY +
          (doc && doc.scrollTop  || body && body.scrollTop  || 0) -
          (doc && doc.clientTop  || body && body.clientTop  || 0 );
      }

      pageX = event.pageX
      pageY = event.pageY

    }

    // Mouse click
    document.onmousedown = handleMouseDown;

    function handleMouseDown(event) {
      AriadnesThread.push(event.toElement + ':' + event.x + ':' + event.y);
      // _logger( '/api/ariadnes_threads', { thread: AriadnesThread });
    }

    var i = setInterval(function() {
      AriadnesThread.push(serializer(cX, cY, pageX, pageY));
    }, this.options.delay);

    // Window status
    window.onbeforeunload = handleBeforeUnload;

    function handleBeforeUnload(event) { clearInterval(i); }
  }

  function extendDefaults(source, properties) {

    var property;

    for (property in properties) {
      if (properties.hasOwnProperty(property)) {
        source[property] = properties[property];
      }
    }

    return source;

  }

  function serializer(cX, cY, X, Y) {
    return (cX + ':' + cY + ':' + X + ':' + Y);
  }

  function _logger(url, params) {
    $.ajax({
      url: url,
      type: 'POST',
      dataType: 'script',
      data: params,
      error: function(jqXHR, testStatus, errorThrown) { },
      success: function(data) { }
    });
  }

  log = new AriadneJS();

  log.init();

}());
Remove console's log