The page top is located by an anchor
and then whereever you want the image (top.gif) to appear
<p><a href="#Pagetop"><img src="top.gif" alt ="Go to top of page" title ="Go to top of page" width="54" height="29" border = "0" ></a></p>
You can if you wish refine this by placing the image within a <div> which is styled "display:none" which changes to style.display="" on some event, say onmouseover another <div>.
It is very difficult to reliably capture the scrollbar position cross-browser and that is hence not recommended.
BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the green "Thank User For This Post" button.
"Remember that there is nothing stable in human affairs; therefore avoid undue elation in prosperity, or undue depression in adversity". Socrates - Greek philosopher in Athens (469 BC - 399 BC)