
//Funzione 1 per le email no spam
function jemail(user, domain, suffix){
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}

//Funzione 2 per le email no spam
function email(name, domain)
{
   window.location = 'mailto:' + name + '@' + domain;
}

// swap img
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.0
  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 && document.getElementById) x=document.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 pop2(str) { 
	larg=500; 
	alt=360; //628 
	toptop=(screen.height/2)-(alt/2); 
	leftleft=(screen.width/2)-(larg/2); 
	searchWin = window. open(str,'Contatti','top='+toptop+',left='+leftleft+',scrollbars=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function pop3(str) { 
	larg=650; 
	alt=700; //628 
	toptop=(screen.height/2)-(alt/2); 
	leftleft=(screen.width/2)-(larg/2); 
	searchWin = window.open(str,'Contatti','top='+toptop+',left='+leftleft+',scrollbars=yes,directories=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no,menubar=no'); 
} 

// funzione cambia immagine banner ITA
function image() {
};
	
image = new image();
number = 0;
// array di immagini
image[number++] = "<img src='../img/banner1.jpg'>"
image[number++] = "<img src='../img/banner2.jpg'>"
image[number++] = "<img src='../img/banner3.jpg'>"
image[number++] = "<img src='../img/banner4.jpg'>"

incremento = Math.floor(Math.random() * number);


// funzione cambia immagine banner	ENG
function image2() {
};
	
image2 = new image2();
number2 = 0;
// array di immagini
image2[number2++] = "<img src='../img/banner1eng.jpg'>"
image2[number2++] = "<img src='../img/banner2eng.jpg'>"
image2[number2++] = "<img src='../img/banner3eng.jpg'>"
image2[number2++] = "<img src='../img/banner4eng.jpg'>"

incremento2 = Math.floor(Math.random() * number2);


// controllo form Contatti
function check1() { 
	var text1 = document.form1.nome.value;
	var text2 = document.form1.cognome.value; 	 
	var text3 = document.form1.azienda.value; 
	var text4 = document.form1.email.value; 
	var text5 = document.form1.messaggio.value; 
	
	var validity = true;
	
	if(!check_text2(text1) && (validity == true)) 
	{validity=false; alert('Il campo Nome è obbligatorio'); document.form1.nome.value="";  
		       	    document.form1.nome.focus();} 
	
	if(!check_text(text2) && (validity == true))
	{validity=false; alert('Il campo Cognome è obbligatorio'); 
					document.form1.cognome.focus();   }		
					
	if(!check_text(text3) && (validity == true))
	{validity=false; alert('Il campo Azienda è obbligatorio'); 
					document.form1.cognome.focus();   }		
		
	if(!check_text(text4) && (validity == true)) 
	{validity=false; alert('Il campo "Email" è obbligatorio, inserire i dati');  
		           document.form1.email.focus();}  
				   
	if((validity == true) && !checkMail(text4) ) 
	{validity=false; }
		
	if(!check_text(text5) && (validity == true))
	{validity=false; alert('Il campo Messaggio è obbligatorio, inserire i dati');
		document.form1.messaggio.focus();  }
		
	if ((!document.form1.privacy.checked) && (validity == true)) {
		alert('Attenzione: è necessario autorizzare il trattamento dei dati personali!');
		return false;
	  }else{
		//alert('ok, eseguo');
		//return true;
	  }
		
	if (validity != false){
		document.form1.submit();
		}
} 

// controllo esattezza formale mail
// controllo esattezza formale mail
function checkMail(x)
{
	//var x = document.form1.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
	//else alert('Attenzione: indirizzo E-mail errato. Controllare e Reinserire!');
	//	document.form1.email.value=""; document.form1.email.focus(); 
}


// controllo formale per form contatti
function check_text3(text) { 
	return (text.length<401); 
} 

// controllo formale per form contatti
function check_text(text) { 
	return (text.length>0); 
} 
  
// controllo formale per form contatti
function check_text2(text) { 
	 return (text.match(/^[A-Za-z0-9\s\']+$/)); 
}

// controllo formale per form contatti
function check_text_cap(text) { 
	return (text.length != 5); 
} 

// controllo formale per form contatti
function check_number(text) { 
	var isnum=/(^\d+$)|(^\d+\.\d+$)/ 
	return(isnum.test(text)); 
} 

// apre link in nuova finestra 
function TargetBlank()
{
  var i = 0;
  var collegamenti = document.links;
  for (i=0; i<collegamenti.length; i++)
  {
    if (collegamenti[i].title == "Nuova finestra")
    {
      collegamenti[i].target = "_blank";
    }
  }
}
window.onload = TargetBlank;



