//funzione che si occupa dell'effetto over
function IniPulsanti(valore){
	/*
	$(".btn").each(function() {
			var percorso = $(this).attr("src").split(".");
		$(this).hover(	
			function () {
				$(this).fadeTo(300,0.2).queue(function(){
					$(this).attr({src: "." + percorso[1] + "up." + percorso[2]}).fadeTo(300,1).dequeue();
				});
				
			}, 
            function () {
            	$(this).fadeTo(300,0.2).queue(function(){
					$(this).attr({src: "." + percorso[1] + "." + percorso[2]}).fadeTo(300,1.0).dequeue();
				});
			}
        );
	});
	*/
	$(".stn").each(function() { 
		$(this).hover(	
			function () {						}, 
            function () {	$('#Logo').hide();	}
        );
        $(this).click(function(){
        	$(".stn").removeClass("bold");
        	$(this).addClass("bold");
        	$(".secondi").slideUp(10);
        	$("#"+$(this).attr("title")).slideDown("slow");
        	if($(this).attr("title")=="Informazioni") $("#tbinfo").slideDown("slow");
        	$('.sottomenu').css("background", "#fff url(./immagini/"+$(this).attr("title")+".jpg) top right no-repeat");
        	return false;
        });
	});
	
	$(".stn2").each(function() { 

		$(this).hover(	
			function () {			}, 
            function () {			}
        );
        $(this).click(function(){
        	$(".stn2").removeClass("bold");
        	$(this).addClass("bold");
        	$(".primi").slideUp(1);
        	$("#"+$(this).attr("alt")).slideDown("slow");
        	return false;
        });
	});
	$(".secondi:not(:first)").hide();
	$(".ltn").each(function() { 
        $(this).click(function(){
        	$(".ltn").removeClass("bold");
        	$(this).addClass("bold");
        	$(".secondi").slideUp(10);
        	$("#"+$(this).attr("title")).slideDown("slow");
        	return false;
        });
	});
}

//funzione che si occupa delle png per IE6
function IniPng(){
	$('img[@src$=.png], div').ifixpng();
}

function IniBody(){
	var tempo = setInterval( ResizeBody, 1);
}

function ResizeBody(){
	var H = $('.top').height()+135;
	if ($(window).height()> H)
		$('div.inferiore').addClass('fisso');
	else
		$('div.inferiore').removeClass('fisso');
	//$('#altezza1').text($(window).height());
	//$('#altezza2').text(H);	
}


// Funzione che richiama la creazione della validazione
function IniForm(){
	$("#commentForm").validate();
}

function IniMessaggio(valore){
	$("#"+valore).slideDown('slow');
}

function IniGallery(valore){
	$(".foto:not(:first)").hide();
	var numero = $(".foto").size();
	var attuale = 0;
	$("#btnfoto").click(function(){
		var prima = attuale;
		attuale++;
		if (attuale >= numero) attuale = 0;
		var seconda = attuale;
		$(".foto").eq(prima).fadeOut(300, function(){$(".foto").eq(seconda).fadeIn(300);});
		$("#nomefoto").text($(".foto").eq(attuale).attr('alt'));
		return false;
	});
	$(".miniature").click(function(){
		var prima = attuale;
		attuale=$(this).attr('id');
		if (attuale >= numero) attuale = 0;
		var seconda = attuale;
		$(".foto").eq(prima).fadeOut(300, function(){$(".foto").eq(seconda).fadeIn(300);});
		$("#nomefoto").text($(".foto").eq(attuale).attr('alt'));
		return false;
	});	
	var numero2 = $("#prova").children().size()-3;
	var attuale2 = 0;
	$("#destra").click(function(){
		//alert(stato);
		if (attuale2 <= numero2){
			$("#prova").children(":eq("+attuale2+")").fadeOut("slow");attuale2++;		
		}
		return false;
	});	
	$("#sinistra").click(function(){
		//alert(stato);
		if (attuale2 >= 0){
			$("#prova").children(":eq("+attuale2+")").fadeIn("slow");attuale2--;
		}
		return false;
	});	
}

function IniBanner(valore){
	$(".banner").hover(
		function () {
				clearInterval(timer);
			}, 
        function () {
				timer = setInterval('ScorriBanner()',5000);
			}
	);
	timer = setInterval('ScorriBanner()',5000);
}

function ScorriBanner(){
	//alert($("#destro").children(":last").attr("src"));
	$(".banner").append($(".banner").children(":first").clone());
	$(".banner").children(":first").fadeOut(1500, function(){
		$(".banner").children(":first").remove();
	});
	
}