$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'facebook',slideshow:3000});
	
	$("#invia").click(function(){
		var nome = $("#nome").val();
		var citta = $("#citta").val();
		var mail = $("#mail").val();
		var testo = $("#testo").val();
		
		if(nome.length <1){
			$("#response").css("display","block");
			$("#response").html("Inserire il nome completo");
			return false;
		}
		
		if(citta.length <1){
			$("#response").css("display","block");
			$("#response").html("Inserire la citt&agrave;");
			return false;
		}
		
		if(!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)){
			$("#response").css("display","block");	
			$("#response").html("Inserire una mail corretta");
			return false;
		}
		
		if(testo.length <1){
			$("#response").css("display","block");
			$("#response").html("Inserire il testo");
			return false;
		}
		
				// scroll to top web wedsignerwall.com  http://webdesignerwall.com/tutorials/animated-scroll-to-top
		
		
		
	});

	// hide #back-top first
	$("#back-top").hide();
	
	// fade in #back-top
	$(function () {
		$(window).scroll(function () {
			if ($(this).scrollTop() > 800) {
				$('#back-top').fadeIn();
			} else {
				$('#back-top').fadeOut();
			}
		});

		// scroll body to 0px on click
		$('#back-top a').click(function () {
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});
	
	$("a#print").attr("target", "_BLANK");

});

