function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

/*
function f_documentHeight()
{
        return document.body.offsetHeight;
}
*/

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

/* get URL Parameters */
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function recargar(url)
{
	location.href = url + "&scroll=" + f_scrollTop() + "&height=" + getDocHeight();
}

function establecerScroll()
{
	
	if (window.pageYOffset)
		window.pageYOffset = gup("scroll"); 
	if (document.body)
		document.body.scrollTop = gup("scroll"); 
	if (document.documentElement)
		document.documentElement.scrollTop = gup("scroll"); 
}

function scrollForm()
{
	document.theform.action = document.theform.action + "?scroll=" + f_scrollTop() + "&height=" + getDocHeight();
}

//window.onload = establecerScroll;



