fixed a bug in calcuration of offset values
changed to use requirejs and added node object definition