// 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(path + "_ScrollLeft", scrollX);
	SetCookie(path + "_ScrollTop", scrollY);

	//document.getElementById('scrollLeft').value = scrollX;  
	//document.getElementById('scrollTop').value = scrollY; 
	//document.forms[0].scrollLeft.value = scrollX;  
	//document.forms[0].scrollTop.value = scrollY; 
}  
   
function SmartScroller_RestoreScroll() 
{   
	if (sys_SmartScrollMode == "None") { return; }

	if (sys_SmartScrollMode == "Universal" ||
		(sys_SmartScrollMode == "PostBack" && sys_PageIsPostBack == true) )
	{
		//var x = document.getElementById('scrollLeft').value;  
		//var y = document.getElementById('scrollTop').value;   
		//var x = document.forms[0].scrollLeft.value;  
		//var y = document.forms[0].scrollTop.value; 

		var path = encodeURIComponent(location.href);
		var x = GetCookie(path + "_ScrollLeft")
		var y = GetCookie(path + "_ScrollTop");
		window.scrollTo(x, y); 
	}
} 