I could be the code is rather extensive so i think it would be better to explain with a screenshot:

nr. 1 shows an active "Page 1" link, which is incorrect. Because it is page 2 we are looking at.
<- IMPR
nr. 2 shows the output as a result of nr 1
nr 3. show the correct active link (Page 2). But this is achieved but scrolling up the page.
You can see IMPR in the background.
So, what i need is a situation shown on nr 1. but with #page2 active.