
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function library(){ 



		$(".a").show();
		$(".b").hide();
		$("#img4").hide();			
		$(".c").hide();
		$("#img6").hide();			
		$(".d").hide();
		$("#img8").hide();			
		
			$("#img1").click(function()
			{	
			
			$("#box2").animate({height: "30px", backgroundColor: "#3B4A59"});
			$("#box2").uncorner();
			$("#img3").show();
			$("#img4").hide();					
			$(".b").hide();	
			
			$("#box3").animate({height: "30px", backgroundColor: "#3B4A59"});
			$("#box3").uncorner();
			$("#img5").show();
			$("#img6").hide();					
			$(".c").hide();
			
			$("#img2").show();
			$("#img1").hide();
			$("#box1").animate({height: "240px", backgroundColor: "#EEF0EB"});
			$("#box1").corner("bottom");
			$(".a").show();
			
			});
			
			$("#img2,.a").click(function()
			{		
		
							$("#box1").animate({height: "30px", backgroundColor: "#3B4A59"});
							$("#box1").uncorner();
							$("#img1").show();
							$("#img2").hide();					
							$(".a").hide();	
							$.scrollTo('#inizio',1000);
			});
			
			
			$("#img3").click(function()
			{

			$("#box1").animate({height: "30px", backgroundColor: "#3B4A59"});
			$("#box1").uncorner();
			$("#img1").show();
			$("#img2").hide();					
			$(".a").hide();	
			
			$("#box3").animate({height: "30px", backgroundColor: "#3B4A59"});
			$("#box3").uncorner();
			$("#img5").show();
			$("#img6").hide();					
			$(".c").hide();		

			$("#img4").show();
			$("#img3").hide();
			$("#box2").animate({height: "600px", backgroundColor: "#EEF0EB"});
			$("#box2").corner("bottom");
			$(".b").show();	
			$.scrollTo('.a',1000);
		
			});
			
			$("#img4,.b").click(function()
			{		
		
							$("#box2").animate({height: "30px", backgroundColor: "#3B4A59"});
							$("#box2").uncorner();
							$("#img3").show();
							$("#img4").hide();					
							$(".b").hide();	
							$.scrollTo('#inizio',1000);
			});		
			
			
			$("#img5").click(function()
			{
				
			$("#box1").animate({height: "30px", backgroundColor: "#3B4A59"});
			$("#box1").uncorner();
			$("#img1").show();
			$("#img2").hide();					
			$(".a").hide();	
			
			$("#box2").animate({height: "30px", backgroundColor: "#3B4A59"});
			$("#box2").uncorner();
			$("#img3").show();
			$("#img4").hide();					
			$(".b").hide();	
			
			$("#img6").show();
			$("#img5").hide();
			$("#box3").animate({height: "400px", backgroundColor: "#EEF0EB"});
			$("#box3").corner("bottom");
			$(".c").show();	
			$.scrollTo('#inizio',1000);

			});

			$("#img6,.c").click(function()
			{		
		
							$("#box3").animate({height: "30px", backgroundColor: "#3B4A59"});
							$("#box3").uncorner();
							$("#img5").show();
							$("#img6").hide();					
							$(".c").hide();	
							$.scrollTo('#inizio',1000);
			});	
			
			
			
			
					$("input[name='richiesta_info']").click(function() {
							
					if (trim($("input[name='nome']").val()) == ''){		
					$("#messaggio").text("Il nome non può essere vuoto");	
					return false;				
					};	
					
					if (trim($("input[name='cognome']").val()) == ''){		
					$("#messaggio").text("Il cognome non può essere vuoto");	
					return false;				
					};			

					if (trim($("input[name='citta']").val()) == ''){		
					$("#messaggio").text("Il campo città non può essere vuoto");	
					return false;				
					};						

					if (trim($("input[name='email']").val()) == ''){		
					$("#messaggio").text("La mail non può essere vuota");	
					return false;}
					else{
						
						if (controlmail(trim($("input[name='email']").val())) == false){
								$("#messaggio").text("La mail non è corretta");
								return false;
						}
						
						if (trim($("input[name='email']").val()) != trim($("input[name='conferma']").val())){
									$("#messaggio").text("I due indirizzi di posta specificati non coincidono");	
									return false;
						}
					}
									
					if($("input[name='rd1']").attr('checked')===false) {  
					$("#messaggio").text("Serve il consenso al trattamento dei dati personali");	
					return false;				
					};
				
					return true;
							
					});	
					
} 


function trim(stringa){
		while (stringa.substring(0,1) == ' '){
		stringa = stringa.substring(1, stringa.length);
		}
		while (stringa.substring(stringa.length-1, stringa.length) == ' '){
		stringa = stringa.substring(0,stringa.length-1);
		}
		return stringa;
}	



function controlmail (emailStr) {
			
			if(emailStr=="")
			return true;
			var checkTLD=1;
			var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
			var emailPat=/^(.+)@(.+)$/;
			var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
			var validChars="\[^\\s" + specialChars + "\]";
			var quotedUser="(\"[^\"]*\")";
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
			var atom=validChars + '+';
			var word="(" + atom + "|" + quotedUser + ")";
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
			var matchArray=emailStr.match(emailPat);
			
			if (matchArray==null) {
				return false;
			}
			
			var user=matchArray[1];
			var domain=matchArray[2];

			for (i=0; i<user.length; i++) {
			
				if (user.charCodeAt(i)>127) {
						return false;
				}
			}
			
			for (i=0; i<domain.length; i++) {
				
				if (domain.charCodeAt(i)>127) {
						return false;
				}
			}
}

