// JavaScript Document
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];}
}

// VERIFICA EMAIL
function isEmail(what, language)
{
   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
   if(!i.test(what.value)) { 
		if (language == "en"){
			alert("Invalid EMAIL address."); 
		}else{
			alert("Il campo EMAIL non è valido."); 
		}
		what.focus(); 
	return false}   
  return true;
}

function controllaFormRichiestaInfo(theForm)
{
	
if (theForm.privacy.checked == false)
	{
		alert("Attenzione: negando il trattamento dei dati personali non sarà possibile inviare il modulo.");
		theForm.privacy.focus();
		return (false);
	}		
	
if (theForm.nome.value == "")
	{
		alert("Inserire un valore per il campo \"NOME E COGNOME\".");
		theForm.nome.focus();
		return (false);
	}

if (theForm.localita.value == "")
	{
		alert("Inserire un valore per il campo \"LOCALITA'\".");
		theForm.localita.focus();
		return (false);
	}	
	
if (theForm.provincia.value == "")
	{
		alert("Inserire un valore per il campo \"PROVINCIA\".");
		theForm.provincia.focus();
		return (false);
	}	
	
if (theForm.telefono.value == "")
	{
		alert("Inserire un valore per il campo \"NR. DI TELEFONO\".");
		theForm.telefono.focus();
		return (false);
	}	
	
if (theForm.mail.value == "")
	{
		alert("Inserire un valore per il campo \"INDIRIZZO E-MAIL\".");
		theForm.mail.focus();
		return (false);
	}

if(!isEmail(theForm.mail)) return false;

if (theForm.messaggio.value == "")
	{
		alert("Inserire un valore per il campo \"MESSAGGIO\".");
		theForm.messaggio.focus();
		return (false);
	}	
	


}


function controllaFormLavoraConNoi(theForm, language)
{
	
if (theForm.privacy.checked == false)
	{
		if (language == "en"){
			alert("Checkbox \"PRIVACY\" is Required.");
		}else{
			alert("Attenzione: negando il trattamento dei dati personali non sarà possibile inviare il modulo.");		}
		theForm.privacy.focus();
		return (false);
	}		
		
	
if (theForm.nome.value == "")
	{
		if (language == "en"){
			alert("Field \"FIRST NAME\" is Required.");
		}else{
			alert("Inserire un valore per il campo \"NOME\".");
		}
		theForm.nome.focus();
		return (false);
	}

if (theForm.cognome.value == "")
	{
		if (language == "en"){
			alert("Field \"LAST NAME\" is Required.");
		}else{		
		alert("Inserire un valore per il campo \"COGNOME\".");
		}
		theForm.cognome.focus();
		return (false);
	}

if (theForm.comune.value == "")
	{
		if (language == "en"){
			alert("Field \"CITY/TOWN\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"COMUNE DI RESIDENZA'\".");
		}
		theForm.comune.focus();
		return (false);
	}	
	
if (theForm.provincia.value == "")
	{
		if (language == "en"){
			alert("Field \"COUNTRY\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"PROVINCIA\".");
		}
		theForm.provincia.focus();
		return (false);
	}	

if (theForm.mail.value == "")
	{
		if (language == "en"){
			alert("Field \"E-MAIL\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"INDIRIZZO E-MAIL\".");
		}
		theForm.mail.focus();
		return (false);
	}
	
if(!isEmail(theForm.mail, language)) return false;

if (theForm.mail.value != theForm.ripeti_email.value)
	{
		if (language == "en"){
			alert("The \"E-MAIL ADDRESS\" and \"REPEAT E-MAIL\" fields are not the same.");
		}else{		
			alert("Il campo \"INDIRIZZO E-MAIL\" e \"RIPETI E-MAIL\" non corrispondono.");
		}
		theForm.ripeti_email.focus();
		return (false);
	}

if (theForm.tel1.value == "" && theForm.tel2.value == "")
	{
		if (language == "en"){
			alert("Fill in a value for the field \"HOME PHONE\" or \"MOBILE PHONE\".");
		}else{		
			alert("Inserire un valore per il campo \"TELEFONO FISSO\" oppure \"TELEFONO CELLULARE\".");
		}
		theForm.tel1.focus();
		return (false);
	}	

if (theForm.titolo_studio.value == "")
	{
		if (language == "en"){
			alert("Field \"EDUCATION\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"TITOLO DI STUDIO\".");
		}
		theForm.titolo_studio.focus();
		return (false);
	}
	
if (theForm.lingue.value == "")
	{
		if (language == "en"){
			alert("Field \"FOREIGN LANGUAGES\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"LINGUE DI SPECIALIZZAZIONE\".");
		}
		theForm.lingue.focus();
		return (false);
	}

if (theForm.esperienze_lavorative.value == "")
	{
		if (language == "en"){
			alert("Field \"WORK EXPERIENCE\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"ESPERIENZE LAVORATIVE\".");
		}
		theForm.esperienze_lavorative.focus();
		return (false);
	}	
	
	if (language == "en"){

		if (confirm("Confirm submission of the form?")){	
				if (theForm.foto1.value != ""){
					document.getElementById("wait").style.display = "block"
				}	
			return (true);
		}else{
			return (false);			
		}

	}else{
		
			if (confirm("Confermi l'invio del modulo?")){	
					if (theForm.foto1.value != ""){
						document.getElementById("wait").style.display = "block"
					}	
				return (true);
			}else{
				return (false);			
		}
		
	}
}

function open_traduzioni(){
	if (document.getElementById("interesse01").checked == true){
			document.getElementById("traduzioni").style.display = "block"		
		}else{
			document.getElementById("traduzioni").style.display = "none"	
		}
}

function open_interpretariato(){
	if (document.getElementById("interesse02").checked == true || document.getElementById("interesse03").checked == true){
			document.getElementById("interpretariato").style.display = "block"		
		}else{
			document.getElementById("interpretariato").style.display = "none"	
		}
}

function controllaFormPreventivo(theForm, language)
{
	
	
if (theForm.privacy.checked == false)
	{
		if (language == "en"){
			alert("Checkbox \"PRIVACY\" is Required.");
		}else{
			alert("Attenzione: negando il trattamento dei dati personali non sarà possibile inviare il modulo.");		}
		theForm.privacy.focus();
		return (false);
	}		
		
	
if (theForm.nome.value == "")
	{
		if (language == "en"){
			alert("Field \"CONTACT NAME\" is Required.");
		}else{
			alert("Inserire un valore per il campo \"NOME e COGNOME\".");
		}
		theForm.nome.focus();
		return (false);
	}

if (theForm.comune.value == "")
	{
		if (language == "en"){
			alert("Field \"CITY/TOWN\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"COMUNE'\".");
		}
		theForm.comune.focus();
		return (false);
	}	
	
if (theForm.provincia.value == "")
	{
		if (language == "en"){
			alert("Field \"COUNTRY\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"PROVINCIA\".");
		}
		theForm.provincia.focus();
		return (false);
	}	

if (theForm.telefono.value == "")
	{
		if (language == "en"){
			alert("Field \"TELEPHONE\" is Required.");			
		}else{		
			alert("Inserire un valore per il campo \"TELEFONO\".");
		}
		theForm.telefono.focus();
		return (false);
	}	

if (theForm.mail.value == "")
	{
		if (language == "en"){
			alert("Field \"E-MAIL\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"INDIRIZZO E-MAIL\".");
		}
		theForm.mail.focus();
		return (false);
	}
	
if(!isEmail(theForm.mail, language)) return false;


if (document.getElementById("interesse01").checked == false && document.getElementById("interesse02").checked == false  && document.getElementById("interesse03").checked == false  )	{
		if (language == "en"){
			alert("Select the service(s) for which you want a FREE quote");
		}else{		
			alert("Selezionare almeno un servizio per il preventivo.");
		}
		document.getElementById("interesse01").focus();
		return (false);
}

if (theForm.lingua_partenza.value == "")
	{
		if (language == "en"){
			alert("Field \"SOURCE LANGUAGE\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"LINGUA DI PARTENZA\".");
		}
		theForm.lingua_partenza.focus();
		return (false);
	}
	
	
	if (theForm.lingua_arrivo.value == "")
	{
		if (language == "en"){
			alert("Field \"TARGET LANGUAGE\" is Required.");
		}else{		
			alert("Inserire un valore per il campo \"LINGUA DI ARRIVO\".");
		}
		theForm.lingua_arrivo.focus();
		return (false);
	}
	

// TRADUZIONI
if (document.getElementById("interesse01").checked == true) {

	if (theForm.testo.value == "" && theForm.file1.value == "" )
		{
			if (language == "en"){
				alert("Field \"TEXT TO TRANSLATE\" OR \"FILE TO TRANSLATE\" is Required.");
			}else{		
				alert("Inserire un testo da tradurre oppure allegare un file.");
			}
			theForm.testo.focus();
			return (false);
		}
}

// INTERPRETARIATO
if (document.getElementById("interesse02").checked == true || document.getElementById("interesse03").checked == true) {

	if (theForm.info_interpretariato.value == "")
		{
			if (language == "en"){
				alert("Field \"INFO\" is Required.");
			}else{		
				alert("Indicare il luogo e la data per i servizi di Interpretariato.");
			}
			theForm.info_interpretariato.focus();
			return (false);
		}
}

	
	if (language == "en"){

		if (confirm("Confirm submission of the form?")){	
//				if (theForm.file1.value != ""){
					document.getElementById("wait").style.display = "block"
//				}	
			return (true);
		}else{
			return (false);			
		}

	}else{
		
			if (confirm("Confermi l'invio del modulo?")){	
//					if (theForm.file1.value != ""){
						document.getElementById("wait").style.display = "block"
//					}	
				return (true);
			}else{
				return (false);			
		}
		
	}
}