// JavaScript Document

function randOrd() {
	return (Math.round(Math.random())-0.5);
} 

function slideShow(num) {
	$("#slide"+num).fadeIn(3000);
	$("#dida").fadeIn(3000);
	var autore=$("#slide"+num).attr("title");
	var id_autore=$("#slide"+num).attr("class");
	var len=$("#slide"+num).css("height").replace("px","");
	var step=235-parseInt(len);
	if ($.browser.msie) step=-218;
	$("#linkFoto").html(autore);
	$("#linkFoto").attr("href","soci.php?id="+id_autore);
	$("#slide"+num).animate({top:step+'px'},{queue: false, duration:10000, easing: 'linear',complete: function(){
		$("#dida").fadeOut(1000);																										  
		$(this).fadeOut(1000,function(){
			if ((num)==10) next=1; else next=num+1;
			$("#slide"+next).css("top","0");
			slideShow(next);
		});
	}});
}

		
function switchTab(tab) {
	if (tab==1) {
		$('#tab1').show();
		$('#tab2').hide();
		$('#tab3').hide();
		$('#titleTab1').removeClass("off");
		$('#titleTab2').addClass("off");
		$('#titleTab3').addClass("off");
	}
	if (tab==2) {
		$('#tab1').hide();
		$('#tab2').show();
		$('#tab3').hide();
		$('#titleTab1').addClass("off");
		$('#titleTab2').removeClass("off");
		$('#titleTab3').addClass("off");
	}
	if (tab==3) {
		$('#tab1').hide();
		$('#tab2').hide();
		$('#tab3').show();
		$('#titleTab1').addClass("off");
		$('#titleTab2').addClass("off");
		$('#titleTab3').removeClass("off");
	}
	$("#linkUtili").css("height",$("#secondary").height()+"px");
}

$(document).ready(function(){
	setTimeout("slideShow(1);",1000);
	if ($("#news").height()<$("#primary").height()) $("#news").css("height",$("#primary").height()+"px");
	if ($("#linkUtili").height()<$("#secondary").height()) $("#linkUtili").css("height",$("#secondary").height()+"px");
	$("a.fancy").fancybox({
		'titlePosition': 'inside'
	});

	$("a.video").fancybox({
        'autoScale'     	: false,
		'width': 500,
		'height': 400,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});


	$('a.email').nospam({
	  replaceText: true,    // BOOLEAN, optional default false. If set to true, replaces matched elements' text with the e-mail address
	  filterLevel: 'normal' // STRING, optional accepts 'low' or 'normal', default 'normal'.
							// low: email/domain/tld
							// normal: dlt/niamod/liame (email/domain/tld reversed)
	});
});
