function getOffsetPage(ref) {
  var x = ref.offsetLeft, y = ref.offsetTop, node = ref.offsetParent;
  do {
    if (node.offsetLeft)
      x += node.offsetLeft;
    if (node.offsetTop)
      y += node.offsetTop;
  } while (node = node.offsetParent);

  return {
    x: x,
    y: y,
    left: x,
    top: y,
    toString: function() { return '[' + this.x + ',' + this.y + ']'; }
  };
} 
