method for calculating selected index based on position in page