﻿//Redirige alla pagina di autenticazione per gli utenti anonimi
function authenticateUser()
{
	var currentLocation = window.top.location.toString();
	var trimLocation = currentLocation.indexOf('/',9)
	var trimmedSource = currentLocation.substring(trimLocation);
	window.top.location.replace("/_layouts/authenticate.aspx?source=" + trimmedSource);
}

// THIS OVERRIDES THE OOTB SHAREPOINT FUNCTION WHICH CAUSES ACTIVEX INSTALL ISSUES
//
// Essentially it overrides the ootb sharepoint function which calls the activex object
// See http://support.microsoft.com/default.aspx/kb/931509 for info on the issue
//
function ProcessDefaultOnLoad(onLoadFunctionNames)
{
	//** Uncomment this to see when this runs
	//alert('Fixing the Issue');
	ProcessPNGImages();
	UpdateAccessibilityUI();
	
	//** We comment out the offending ootb function
	//** and leave the rest of the functions as they were
	//ProcessImn();
	for (var i=0; i < onLoadFunctionNames.length; i++)
	{
		var expr="if(typeof("+onLoadFunctionNames[i]+")=='function'){"+onLoadFunctionNames[i]+"();}";
		eval(expr);
	}
	if (typeof(_spUseDefaultFocus)!="undefined")
		DefaultFocus();
}

// Aumenta e riduce le dimensioni del testo
function resizeText(multiplier) {
  var currfontsize = parseFloat($('#testo-resize').css('font-size'));
  var newFontSize = currfontsize+multiplier;
  $('#testo-resize').css('font-size', newFontSize);
} 

//Controlla che il div ultimora in home page sia pieno e lo rende visibile
function CheckDivInnerText()
{
	$('#ultimora').removeClass('invisibile');
	if ($('#ultimora-testo').text() == ""){
		$('#ultimora').hide();
	} 
}

//Funzione che mostra il pulsante webslice se il browser è IE8
function showslice(){
	if ($.browser.msie && $.browser.version == 8.0){
		$('#slice').css({ display:"block"});
	}
}

//Funzione che recupera il titolo della categoria attualità
function getTitle(){
	var urlarray = location.href.split("/");
	if (urlarray.length > 5){
		var page_name = urlarray[5];
		if (page_name.indexOf("filter.aspx") != -1){
			var catArray = page_name.split("=");
			var category = catArray[1];
			category = category.replace("a'","à");
			document.title = document.title.replace("-", "- "+category+" -");
			$('#catTitle > h2').text(category + ", Attualità");
		} 	
	}
}

//Eseguo gli script 
$(document).ready(function(){
	CheckDivInnerText();
	showslice();
	getTitle();
	//Stampa il numero delle pagine del div della paginazione
	$('#page_tot').text($('#max_rows').text());
	//Apre il popup di stampa
	$('.stampa > a').click(function(){window.open("/print.aspx","_blank","height=500,width=700,resizable=no,status=no,toolbar=no,menubar=yes,location=no,scrollbars=yes");return false;});
});
