function getPageSizeWithScroll(){
	if( window.innerHeight && window.scrollMaxY ) // Firefox 
		{
			pageWidth = window.innerWidth + window.scrollMaxX;
			pageHeight = window.innerHeight + window.scrollMaxY;
		}
	else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
		{
			pageWidth = document.body.scrollWidth;
			pageHeight = document.body.scrollHeight;
		}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		{ 
			pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
			pageHeight = document.body.offsetHeight + document.body.offsetTop; 
		}
	arrayPageSizeWithScroll = new Array(pageWidth,pageHeight);
	//alert( 'The height is ' + pageWidth + ' and the width is ' + pageHeight );
	return arrayPageSizeWithScroll;
}

function openpopup(datasch)
{
	var arrdata = datasch.split("|")
	var altezza = getPageSizeWithScroll();
	//ricavo l'altezza
	$('div.overlay').css("height", altezza[1]+"px");
	$('div.overlay').css("display", "block");
	$('div.schedapop').css("display", "block");
	//inserisco i dati
	//
	$('span.data').html(arrdata[0]);
	$('p.schedapop_titolo').text(arrdata[1]);
	$('p.schedapop_dettagli').html(arrdata[2]);
	$('a.pls-pdf').href = arrdata[3];

	//Fa sparire il link allegato se non c'è 
	//alert(arrdata[3]);
	
	if (arrdata[3]=='uploads/news/allegati/') 
		$('a.pls-pdf').css("display", "none");

	//istruzioni di chiusura
	$('a.popchiudi').click(function(){   
		$('div.overlay').css("display", "none");
		$('div.schedapop').css("display", "none");

	});
}


$(document).ready(function()   
{   
    $('a.pls-vai').click(function(){   
    openpopup (this.rel);
	});
});