t_pageWidth = 949;
          t_id = 4;
          t_pb = 40;
          t_url = "http://heat.4fresh.pl";
          function HeatTracker() {
  this.options = 0;
  this.list = [];
  this.mouseCount = 0;
  this.mouseX = 0;
  this.mouseY = 0;
  this.offset = 0;
  this.halfPageWidth = 0;
  this.init = function(options) {
    this.options = options;
    this.halfPageWidth = Math.round(this.options.pageWidth / 2);
  }
  this.getX = function(x) {
    return Math.round(x
        - ((document.body.clientWidth / 2) - this.halfPageWidth));
  };
  this.setPosition = function(x, y) {
    this.mouseX = x;
    this.mouseY = y;
  };
  this.setCookie = function(c_name, value) {
    document.cookie = c_name + "=" + escape(value) + '; path=/';
  };
  this.getUrl = function() {
    return encodeURIComponent(window.location);
  };
  this.getCookie = function(c_name) {
    if (document.cookie.length > 0) {
      c_start = document.cookie.indexOf(c_name + "=");
      if (c_start != -1) {
        c_start = c_start + c_name.length + 1;
        c_end = document.cookie.indexOf(";", c_start);
        if (c_end == -1) {
          c_end = document.cookie.length;
        }
        return unescape(document.cookie.substring(c_start, c_end));
      }
    }
    return "";
  }
  this.sendLastPosition = function() {
    var str = this.getCookie('track_er');
    var location = mtr.getCookie('li_htt');
    if (str && location) {
      var jsonpScript = document.createElement('script');
      jsonpScript.src = this.options.url + '/heat/m/?id=' + this.options.id
          + '&str=' + str + '&url=' + encodeURIComponent(location);
      document.body.appendChild(jsonpScript);
    }
    this.setCookie('track_er', '');
    this.setCookie('li_htt', '');
  }
  this.sendPosition = function() {
    if (Math.random() * 100 < this.options.pb) {
      x = this.getX(this.mouseX);
      if (this.list[this.list.length - 1] == x) {
        this.offset++;
      } else {
        this.offset = 0;
      }

      if (x < 0 || x > this.options.pageWidth || this.mouseX == NaN
          || this.mouseX == undefined || this.offset > 4) {
        return;
      }

      this.list.push(x);
      this.setCookie('li_htt', window.location);
      var str = this.getCookie('track_er');
      str += x + ',' + this.mouseY + ';';
      this.mouseCount++;
      if (this.mouseCount >= 30) {
        this.offset = 0;
        this.list = [];
        this.mouseCount = 0;
        var jsonpScript = document.createElement('script');
        jsonpScript.src = this.options.url + '/heat/m/?id=' + this.options.id
            + '&str=' + str + '&url=' + this.getUrl();
        document.body.appendChild(jsonpScript);
        this.setCookie('track_er', '');
      } else {
        this.setCookie('track_er', str);
      }

    }
  };
  this.sendClick = function(x, y) {
    x = this.getX(x);
    if (x < 0 || x > this.options.pageWidth) {
      return;
    }

    var jsonpScript = document.createElement('script');
    jsonpScript.src = this.options.url + '/heat/c/' + '?id=' + this.options.id
        + '&url=' + this.getUrl() + '&x=' + x + '&y=' + y;
    document.body.appendChild(jsonpScript);
  };
  this.timer = function() {
    mtr.sendPosition();
    setTimeout("mtr.timer()", this.options.tim_off);
  };
}

mtr = new HeatTracker();
mtr.init( {
  pageWidth : t_pageWidth,
  id : t_id,
  pb : t_pb,
  url : t_url,
  tim_off : 100
});
mtr.sendLastPosition();
document.onclick = function(e) {
      
            if (!document.all) {
                mtr.sendClick(e.pageX, e.pageY);
              }else{
                mtr.sendClick(event.x, event.y);
              }
            };
     document.onmousemove = function(e) {
            if (!document.all) {
                mtr.setPosition(e.pageX, e.pageY);
              }else{
                mtr.setPosition(event.x, event.y);
              }
        };
      mtr.timer();