JavaScript functions to get dimensions of objects and to set scroll positions