function openPopUp(URL) 
	{
	window.open(URL, "","menubar=0,toolbar=0,location=0,resizable=0,scrollbars=1,height=550,width=550");
	}

function openMyPopUp(URL) 
{
	window.open(URL,"","menubar=0,toolbar=0,location=0,resizable=1,scrollbars=1,height=600,width=800");
}
	
function CheckDBValue(textc, campo, rexp, obbligo, nome_form,lang)
{
	// campo, indica il nome del campo da valutare
	// rexp, indica quale espressione regolare utilizzare e quale messaggio di alert
	//obbligo, se 1 indica che il campo è obbligatorio, se 0 indica che può avere valore nullo
	//per accettare qualsiasi input e richiedere inserimento obbligatorio rexp='all' e obbligo=1
	
	all=/((^(((\s)|(\S)){1,}))$){1,1}/g
	mail=/((^((([a-z]|[A-Z]|\d)+(\.|\-|\_){0,1})+([a-z]|[A-Z]|\d)+(\@){1,1}(([a-z]|[A-Z]|\d)+(\.|\-){0,1})+([a-z]|[A-Z]|\d)+(\.){1,1}([a-z]){2,3}))$){1,1}/g
	
	if ((textc=='nome') && (lang.toLowerCase()=="_eng"))
		{textc='name'}
	if ((textc=='nome') && (lang.toLowerCase()=="_fra"))
		{textc='nom'}
	if ((textc=='nome') && (lang.toLowerCase()=="_deu"))
		{textc='name'}
	if ((textc=='nome') && (lang.toLowerCase()=="_esp"))
		{textc='nombre'}
	
	if ((textc=='cognome') && (lang.toLowerCase()=="_eng"))
		{textc='surname'}
	if ((textc=='cognome') && (lang.toLowerCase()=="_fra"))
		{textc='prénom'}
	if ((textc=='cognome') && (lang.toLowerCase()=="_deu"))
		{textc='vorname'}
	if ((textc=='cognome') && (lang.toLowerCase()=="_esp"))
		{textc='apellido'}
	
	if ((textc=='indirizzo') && (lang.toLowerCase()=="_eng"))
		{textc='address'}
	if ((textc=='indirizzo') && (lang.toLowerCase()=="_fra"))
		{textc='adresse'}
	if ((textc=='indirizzo') && (lang.toLowerCase()=="_deu"))
		{textc='anschrift'}
	if ((textc=='indirizzo') && (lang.toLowerCase()=="_esp"))
		{textc='dirección'}
		
	if ((textc=='città') && (lang.toLowerCase()=="_eng"))
		{textc='town/city'}
	if ((textc=='città') && (lang.toLowerCase()=="_fra"))
		{textc='ville'}
	if ((textc=='città') && (lang.toLowerCase()=="_deu"))
		{textc='ort'}
	if ((textc=='città') && (lang.toLowerCase()=="_esp"))
		{textc='ciudad'}	
			
	if ((textc=='nazione') && (lang.toLowerCase()=="_eng"))
		{textc='country'}
	if ((textc=='nazione') && (lang.toLowerCase()=="_fra"))
		{textc='pays'}
	if ((textc=='nazione') && (lang.toLowerCase()=="_deu"))
		{textc='nation'}
	if ((textc=='nazione') && (lang.toLowerCase()=="_esp"))
		{textc='nación'}		
		
	if (lang.toLowerCase()=="_ita")
	{
		msgall=textc+" è richiesto"
		msgmail=textc+" non contiene un indirizzo e-mail valido"
	}
	if (lang.toLowerCase()=="_eng")
	{
		msgall=textc+" required"
		msgmail=textc+" invalid e-mail address"
	}
	if (lang.toLowerCase()=="_fra")
	{
		msgall=textc+" obligatoire"
		msgmail=textc+" e-mail incorrecte"
	}
	if (lang.toLowerCase()=="_deu")
	{
		msgall=textc+" noetig"
		msgmail=textc+" unzulässige E-mail Adresse"
	}
	if (lang.toLowerCase()=="_esp")
	{
		msgall=textc+" obligatorio"
		msgmail=textc+" E-mail dirección incorrecta"
	}	
	
	
	ok_r=null
	ok_o=false
	ok_r=eval("document."+nome_form+"."+campo+".value.match("+rexp+")")

	if (obbligo!=1)
	{
		if (eval("document."+nome_form+"."+campo+".value==''"))
		ok_o=true
	}
	if ((ok_r!=null)||(ok_o==true))
	{
		return 1;
	}
	else
	{
		eval("alert(msg"+rexp+")")
		return 0;
	}
}

function subform(lang)
{	
	if (CheckDBValue('nome', 'nome', 'all', 1, 'formy',lang))
	if (CheckDBValue('cognome', 'cognome', 'all', 1, 'formy',lang))
	if (CheckDBValue('indirizzo', 'indirizzo', 'all', 1, 'formy',lang))
	if (CheckDBValue('città', 'citta', 'all', 1, 'formy',lang))
	if (CheckDBValue('nazione', 'nazione', 'all', 1, 'formy',lang))
	
	if ((document.formy.nazione.value=='Italy')&&(document.formy.provincia.value==''))
		{
		if (lang.toLowerCase()=="_ita")
			{alert("provincia è richiesto")}
		if (lang.toLowerCase()=="_eng")
			{alert("Province required")}
		if (lang.toLowerCase()=="_fra")
			{alert("Province obligatoire")}
		if (lang.toLowerCase()=="_deu")
			{alert("Provinz noetig")}
		if (lang.toLowerCase()=="_esp")
			{alert("Provincia obligatorio")}
		}
	else
		{
		if (CheckDBValue('e-mail', 'email', 'mail', 1, 'formy',lang))
		if ((document.formy.rivenditore.checked==false)&&(document.formy.privato.checked==false)&&(document.formy.progettista.checked==false)&&(document.formy.altroimpiego.checked==false))
			{
			if (lang.toLowerCase()=="_ita")
				{alert("Sono un è richiesto")}
			if (lang.toLowerCase()=="_eng")
				{alert("I am a required")}
			if (lang.toLowerCase()=="_fra")
				{alert("Je suis obligatoire")}
			if (lang.toLowerCase()=="_deu")
				{alert("Ich bin noetig")}
			if (lang.toLowerCase()=="_esp")
				{alert("Soy un obligatorio")}
			}
		else
			{
			if ((document.formy.altroimpiego.checked==true)&&(document.formy.sonoaltro.value==''))
				{
				if (lang.toLowerCase()=="_ita")
					{alert("altro è richiesto")}
				if (lang.toLowerCase()=="_eng")
					{alert("other required")}
				if (lang.toLowerCase()=="_fra")
					{alert("autre obligatoire")}
				if (lang.toLowerCase()=="_deu")
					{alert("andere noetig")}
				if (lang.toLowerCase()=="_esp")
					{alert("otras obligatorio")}
				}
			else
				{	
				if (document.formy.autorizzo.checked==1)
					{document.formy.submit();}
				else
					{
					if (lang.toLowerCase()=="_ita")
						{alert("Attenzione! Per completare la procedura è necessario accettare il modulo dell'informativa")}
					if (lang.toLowerCase()=="_eng")
						{alert("Attention!  In order to complete the transmission, please accept the privacy policy")}
					if (lang.toLowerCase()=="_fra")
						{alert("Attention ! Vous devez approuver la note d'information sur la confidentialité")}
					if (lang.toLowerCase()=="_deu")
						{alert("Achtung! Um das Verfahren durchzuführen, ist Ihre Zustimmung zu dem Privacy Policy notwendig")}
					if (lang.toLowerCase()=="_esp")
						{alert("Atención! Es necesario aceptar los términos sobre la ley de la privacidad")}
					}
				}
			}	
		}
}	