Electromagnetic form factors of the nucleon in spacelike and timelike regions