	function scrivimail(indirizzo,dominio,livello) {
		$('#'+livello).html('<a href="mailto:'+indirizzo+'@'+dominio+'.it">'+indirizzo+'@'+dominio+'.it</a>');
	}

$.fn.slideshow = function(options) {
	var settings = {
		timeout: '1500',
		type: 'sequence'
	}
	if(options)
		$.extend(settings, options);
	
	this.css('position', 'relative');
	var slides = this.find('img').get();
	for ( var i = 0; i < slides.length; i++ ) {
		$(slides[i]).css('zIndex', slides.length - i).css('position', 'absolute').css('top', '0').css('left', '0');
	}
	if ( settings.type == 'sequence' ) {
		setTimeout(function(){
			$.slideshow.next(slides, settings, 1, 0);
		}, settings.timeout);
	}
	else if ( settings.type == 'random' ) {
		setTimeout(function(){
			do { current = Math.floor ( Math.random ( ) * ( slides.length ) ); } while ( current == 0 )
			$.slideshow.next(slides, settings, current, 0);
		}, settings.timeout);
	}
	else {
		alert('type must either be \'sequence\' or \'random\'');
	}
};
$.slideshow = function() {}
$.slideshow.next = function (slides, settings, current, last) {
	for (var i = 0; i < slides.length; i++) {
		$(slides[i]).css('display', 'none');
	}
	$(slides[last]).css('display', 'block').css('zIndex', '0');
	$(slides[current]).css('zIndex', '1').fadeIn('slow');
	
	if ( settings.type == 'sequence' ) {
		if ( ( current + 1 ) < slides.length ) {
			current = current + 1;
			last = current - 1;
		}
		else {
			current = 0;
			last = slides.length - 1;
		}
	}
	else if ( settings.type == 'random' ) {
		last = current;
		while (	current == last ) {
			current = Math.floor ( Math.random ( ) * ( slides.length ) );
		}
	}
	else {
		alert('type must either be \'sequence\' or \'random\'');
	}
	setTimeout((function(){$.slideshow.next(slides, settings, current, last);}), settings.timeout);
}

	function iterateList(node)
{	var ul, toggleLink;
	// get list items
	$("li",node).each(
		function()
		{
			if(this.parentNode != node) return;
			// if item contains a sub list
			ul = $("ul",this).get(0);
			if(ul)
			{
				$("ul",this).hide();
				
				toggleLink = document.createElement("a");
				toggleLink.href = "#";
				$(toggleLink).addClass("toggle");
				$(ul.parentNode.childNodes[0]).wrap(toggleLink);
				$("a.toggle", ul.parentNode).click(
					function()
					{
						$("ul",node).hide();
						$(">ul",this.parentNode).toggle();
						return false;
					}
				);
				iterateList(ul);
			}
		}
	);
}

function ridimensionasidebar(){ if ($("#content").height() >= 400) {altezza=$("#content").height()+72;$("#sidebar").height(altezza+"px"); }}


function mostrafiltri() {$("#filtriricerca").toggle();}

function myPopUp(url, myname, wd, ht, mytop, myleft, mn, to, lo, dr, st, sc, re, pos, siz) {
var mdbPopUp;
if(siz == "full") { 
 wd = screen.width;
 ht = screen.height;
}
if(siz == "qtr") { 
 wd = screen.width/2;
 ht = screen.height/2;
}
if(siz == "half") { 
 wd = (screen.width/4)*3;
 ht = (screen.height/4)*3;
}
if(siz == "3qtr") { 
 wd= (screen.width/8)*7;
 ht = (screen.height/8)*7;
}
if(pos == "cen") { 
 myleft = ((screen.width-wd)/2);
 mytop = ((screen.height-ht)/2);
}
if(pos == "tprt") { 
 myleft = ((screen.width-wd)-10);
 mytop = 0;
}
if(pos == "tplf") { 
 myleft = 0;
 mytop = 0;
}
if(pos == "tpctr") { 
 myleft = ((screen.width-wd)/2);
 mytop = 0;
}

settings="width=" + wd + ",height=" + ht + ",top=" + mytop + ",left=" + myleft + ",menubar=" + mn + ",toolbar=" + to + ",location=" + lo + ",directories=" + dr + ",status=" + st + ",scrollbars=" + sc + ",resizable=" + re;

mdbPopUp = window.open(url, myname, settings);
mdbPopUp.focus();
}
