// saving and restoring the scroll amount of a page

/* This section is only valid for IE. Deprecated. Reserved for backward compatibility.  */
function SaveScroll()
{
	var path = encodeURIComponent(location.pathname);
	SetCookie(path + "_ScrollTop", document.body.scrollTop);
	SetCookie(path + "_ScrollLeft", document.body.scrollLeft);
	return true;
}

function RestoreScroll()
{
	var path = encodeURIComponent(location.pathname);
	var t = GetCookie(path + "_ScrollTop");
	var l = GetCookie(path + "_ScrollLeft")
	if (t != null) {document.body.scrollTop = parseInt(t);}
	if (l != null) {document.body.scrollLeft = parseInt(l);}
	return true;
}
/* ------------ IE-only section ends. ------------ */

/* The following methods are good for both IE and Firefox/Netscape.  */
function SmartScroller_SaveScroll() 
{   
	if (sys_SmartScrollMode == "None") { return; }
	
	// if sys_SmartScrollMode is "PostBack" or "Universal", 
	// then record the current scroll positions.
	var scrollX, scrollY;   
	if (document.all) {   
		if (!document.documentElement.scrollLeft) {
			scrollX = document.body.scrollLeft;   
		} else { 
			scrollX = document.documentElement.scrollLeft; 
		}
		
		if (!document.documentElement.scrollTop) { 
			scrollY = document.body.scrollTop;  
		} else {
			scrollY = document.documentElement.scrollTop; 
		}
		
	} else {   
		scrollX = window.pageXOffset;
		scrollY = window.pageYOffset; 
	}   
	
	var path = encodeURIComponent(location.href);
	SetCookie("sys_ScrollModule", path);
	SetCookie("sys_ScrollLeft", scrollX);
	SetCookie("sys_ScrollTop", scrollY);

}  
   
function SmartScroller_RestoreScroll() 
{   
	if (sys_SmartScrollMode == "None") { return; }

	if (sys_SmartScrollMode == "Universal" ||
		(sys_SmartScrollMode == "PostBack" && sys_PageIsPostBack == true) )
	{

		var path = encodeURIComponent(location.href);
		if (path == GetCookie("sys_ScrollModule"))
		{
		    var x = GetCookie("sys_ScrollLeft")
		    var y = GetCookie("sys_ScrollTop");
		    window.scrollTo(x, y);
		}
	}
} 