Strange attraction in Javascript