$(document).ready(function()
{
	var version = getVersion();
	if(version >= 0 && version <= 6)
		document.getElementById('layer_opacity').style.height= (document.body.clientHeight + 50);
	//if(window.addEventListener) document.addEventListener('DOMMouseScroll', setTopInfoSocietarie, false);
  	//document.onmousewheel = setTopInfoSocietarie;
});

function getVersion()
{
	var dataString = navigator.appVersion;
    var versionSearchString = "MSIE";
	var index = dataString.indexOf(versionSearchString);
	if (index == -1) return -1;
	return parseFloat(dataString.substring(index+versionSearchString.length+1));	
}

var isOpen = 0;
function getScrollXY() 
{
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	//return [ scrOfX, scrOfY ];
	return scrOfY;
}

function openInfoSocietarie()
{
	if(isOpen == 0)
	{
		setTopInfoSocietarie();
		document.getElementById('layer_opacity').style.display = 'inline';	
		document.getElementById('info_societarie').style.display = 'inline';	
		isOpen = 1;
	}
}

function setTopInfoSocietarie()
{
	var Y = getScrollXY();
	var pannello_y_default = -147;
	document.getElementById('info_societarie').style.marginTop = pannello_y_default+'px';
	if(Y > 0)
	{
		var newTop = pannello_y_default + Y;
		pannello_y_default = newTop;
		document.getElementById('info_societarie').style.marginTop = pannello_y_default+'px';
	}
}

function closeInfoSocietarie()
{
	document.getElementById('layer_opacity').style.display = 'none';	
	document.getElementById('info_societarie').style.display = 'none';
	isOpen = 0;
}

/*document.onkeydown = function()
{
	setTopInfoSocietarie();
}*/