http://parentnode.org/javascript/working-with-the-cursor-position/