$().animateIntoView() will no longer scroll if the element is in viewport. Scroll can be forced by setting 4th argument to true.
Added some cached variables for better performance.
Converted indentation to spaces.