What is wrong with this code? (it scrolls a div)?

What is wrong with this code? (it scrolls a div)?

Here is the code, the idea is that you have a div on your page with id of "content6", and it takes up only a part of your page.  The div has a scrollbar because it has enough text content so that many scrolls are needed to get to the bottom.  Given a "fraction" like .3, you want to scroll it down to 30%.  Or a fraction of .5, you want it to go to 50%.  The following does not work.

function tp_setScrollFraction(fraction) {

var bod = document.getElementById("content6");

var iNewHeight = bod.scrollHeight;

var pageSize = bod.offsetHeight - 60; // 60 is the height that we gave the footer

bod.scrollTop = Math.floor((iNewHeight-pageSize) * fraction; }
 
Another question that would help to know the answer to is: suppose the person is looking at a long poem in the DIV, and he is on verse #55 that starts with
"Lost in the mist of time...."
Is there any way for jquery to know that the first visible sentence in the Div is:
"Lost in the mist of time..."?