/* ScrollScript - javascript functions which restore the user's screen position
   on a page refresh.  To use:
   1) include this script in the page
      eg <script language="javascript" src="../zIncludes/scrollscript.js"></script>
   2) add onload="scroll_init()" to the <BODY> element
   3) add a hidden form field called ScrollPos with ViewState=True and Width=0px)
	eg <asp:textbox id="ScrollPos" runat="server" Width="0px"></asp:textbox>
   Assumption: Form is called Form1
*/

var ScrollPosTB;
function scroll_init()
{
	// Restore last scroll position (if postback)
	ScrollPosTB = document.getElementById("ScrollPos");
	if(ScrollPosTB == null)
		ScrollPosTB = document.getElementById("ctl00_ScrollPos");
	if(ScrollPosTB == null)
	{
		alert("ERROR: Could not find ScrollPos texbox");
		return;
	}

	var sScrollTop = ScrollPosTB.value;
	if (sScrollTop != "")
		document.documentElement.scrollTop = sScrollTop;
	
	// Start recording scroll position
	timerID = setTimeout("scroll_record()",1000)
}
function scroll_record()
{
	// Store current scroll position in ScrollPos field
	ScrollPosTB.value = document.documentElement.scrollTop;
	//alert(document.documentElement.scrollTop);
	// Do another restore in half a sec
	timerID = setTimeout("scroll_record()",500)
}
