
function ScrollTo(O, Where, NoFocus){
//Where={top, bottom, middle}
var Pos, Y, ObjH=O.offsetHeight, WinH=D.body.clientHeight;

Pos=AbsPos(O); Y=Pos[1];
if (Where==null){
	if (Y<D.body.scrollTop) Where='top';
	else if (Y+ObjH>D.body.scrollTop+WinH) Where='bottom';
	}

if (Where=='middle'){
	if (ObjH>WinH) Where='top';
	else W.scrollTo(0, Y-Math.round((WinH-ObjH)/2));
	}
if (Where=='top') W.scrollTo(0, Y-1);
else if (Where=='bottom') W.scrollTo(0, Y+ObjH-WinH);

if (NoFocus!=true) W.focus(); return false;
}
