
var absTop = null;
var startTop = null;
var stopTop = findPosY( document.getElementById( "footer_pag" ) ) - parseInt( getStyle( "floatLayer", "height" ) );
		

function clearAbsTop()
{
	absTop = null;
}


function setMenuOffset() 
{
	
	var header = document.getElementById( "floatLayer" );
	
	if( !header ) return;
	
	var currentOffset = document.documentElement.scrollTop || document.body.scrollTop;
	
	
	if( currentOffset > header.offsetTop )
	{
		
		if( absTop == null )
		{
			absTop = header.offsetTop - startTop;
		}
		
		if( currentOffset <= stopTop )
		{
			header.style.top = ( currentOffset - absTop ) + "px";
		}
		else
		{
			header.style.top = ( stopTop - absTop )  + "px";
		}
		
	}
	else if( absTop != null && header.offsetTop > currentOffset )
	{
		if( currentOffset > absTop )
		{
			header.style.top = currentOffset - absTop + "px";
		}
		else
		{
			header.style.top = startTop + "px";
		}
		 
	}
	
	window.setTimeout( "setMenuOffset()", 10 );
		
}

function getStyle( el, styleProp ) 
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

window.onload = function () 
{
	startTop = parseInt( getStyle( "floatLayer", "top" ) );
	setMenuOffset();
}

function findPosY(obj) 
{
	var curtop = 0;
	
	if(obj.offsetParent)
		while(1)
		{
			curtop += obj.offsetTop;
			if(!obj.offsetParent)
			break;
			obj = obj.offsetParent;
		}
		else if(obj.y)
			curtop += obj.y;

	return curtop;
}
