var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {browserType= "gecko"}


function hide() {
  if (browserType == "gecko" )
     document.poppedLayer = eval('document.getElementById(\'realtooltip\')');
  else if (browserType == "ie")
     document.poppedLayer = eval('document.all[\'realtooltip\']');
  else
     document.poppedLayer = eval('document.layers[\'`realtooltip\']');
  document.poppedLayer.style.visibility = "hidden";
}

function show() {
  if (browserType == "gecko" )
     document.poppedLayer = eval('document.getElementById(\'realtooltip\')');
  else if (browserType == "ie")
     document.poppedLayer = eval('document.all[\'realtooltip\']');
  else
     document.poppedLayer = eval('document.layers[\'`realtooltip\']');
  document.poppedLayer.style.visibility = "visible";
}

function login(){
txt_utente = document.form1.txt_utente.value;
txt_password = document.form1.txt_password.value;
if(txt_utente != "" && txt_utente != "userid"){
document.form1.txt_utente.style.background = "#FFFFFF";
document.form1.txt_utente.style.color = "#555555";
if(txt_password != "" && txt_password != "password"){
document.form1.txt_password.style.background = "#FFFFFF";
document.form1.txt_password.style.color = "#555555";
document.form1.HdnFnc.value = 1;
document.form1.submit();
}
else{
document.form1.txt_password.focus();
document.form1.txt_password.style.background = "#87082B";
document.form1.txt_password.style.color = "#FFFFFF";
}
}
else{
document.form1.txt_utente.focus();
document.form1.txt_utente.style.background = "#87082B";
document.form1.txt_utente.style.color = "#FFFFFF";
}
}

function pagenav(page){
document.form1.page.value = page;
document.form1.submit();
}

function check_affiliazione(){
document.retVal = false;
txt_nome = document.form1.txt_nome.value;
txt_cognome = document.form1.txt_cognome.value;
txt_eta = document.form1.txt_eta.value;
txt_telefono = document.form1.txt_telefono.value;
txt_email = document.form1.txt_email.value;
if(txt_nome != ""){
if(txt_cognome != ""){
if(document.form1.dtlprovincia.value != ""){
if(txt_eta != ""){
if(txt_telefono != ""){
if(txt_email != ""){
if(document.form1.radio9[0].checked == true){
document.form1.HdnFnc.value = 2;
document.retVal = true;
}
else{
alert("Attenzione!\nSelezionare SI ed accettare il trattamento dei dati personali per inviare il modulo.\nSe il trattamento dei dati non è accettato non sarà possibile continuare.");
document.form1.radio9[0].focus();
}
}
else{
document.form1.txt_email.focus();
}
}
else{
document.form1.txt_telefono.focus();
}
}
else{
document.form1.txt_eta.focus();
}
}
else{
document.form1.dtlprovincia.focus();
}
}
else{
document.form1.txt_cognome.focus();
}
}
else{
document.form1.txt_nome.focus();
}
}

function sendcv(){
document.retVal = false;
if (checkInputData('txtNome') == true){
if (checkInputData('txtCognome') == true){
if (checkInputData('txtCittaNascita') == true){
if (document.form1.dropDown_GG.value != 'default'){
if (document.form1.dropDown_MM.value != 'default'){
if (checkInputData('txtAnno') == true && document.form1.txtAnno.value != 'ANNO'){
if (checkInputData('txtCittadinanza') == true){
if (checkInputData('txtIndirizzo') == true){
if (checkInputData('txtCittaResidenza') == true){
if (document.form1.dropDown_PrvResidenza.value != 'default'){
if (checkInputData('txtCAP') == true){
if (checkInputData('txtTelefono1') == true){
if (checkInputData('txtTelefono2') == true){
if (checkInputData('txtMail') == true){
if (checkMail('txtMail') == true){
if(document.form1.radio9[0].checked == true){
document.form1.HdnFnc.value = 3;
document.retVal = true;
}
else{
alert("Attenzione!\nSelezionare SI ed accettare il trattamento dei dati personali per inviare il modulo.\nSe il trattamento dei dati non è accettato non sarà possibile continuare.");
document.form1.radio9[0].focus();
}
}
else{
document.form1.txtMail.value = "@";
document.form1.txtMail.focus();
}
}
else{
document.form1.txtMail.value = "@";
document.form1.txtMail.focus();
}
}
else{
document.form1.txtTelefono2.focus();
}
}
else{
document.form1.txtTelefono1.focus();
}
}
else{
document.form1.txtCAP.focus();
}
}
else{
document.form1.dropDown_PrvResidenza.focus();
}
}
else{
document.form1.txtCittaResidenza.focus();
}
}
else{
document.form1.txtIndirizzo.focus();
}
}
else{
document.form1.txtCittadinanza.focus();
}
}
else{
document.form1.txtAnno.focus();
}
}
else{
document.form1.dropDown_MM.focus();
}
}
else{
document.form1.dropDown_GG.focus();
}
}
else{
document.form1.txtCittaNascita.focus();
}
}
else{
document.form1.txtCognome.focus();
}
}
else{
document.form1.txtNome.focus();
}
}

function resetmailform(){
document.form1.txt_email_nome.value = "";
document.form1.txt_email_cognome.value = "";
document.form1.txt_email_email.value = "@";
document.form1.txt_email_testo.value = "";
}

function resetnewsform(){
document.form1.txt_newsletter_nome.value = "";
document.form1.txt_newsletter_cognome.value = "";
document.form1.txt_newsletter_email.value = "@";
}

function sendmail(){
strName = document.form1.txt_email_nome.value;
strLastName = document.form1.txt_email_cognome.value;
strEmail = document.form1.txt_email_email.value;
strText = document.form1.txt_email_testo.value;
if (strName != ""){
if (strLastName != ""){
if (strEmail != ""){
if (checkMail('txt_email_email') == true){
if (strText != ""){
document.form1.HdnFnc.value = 4;
document.form1.submit();
}
else{
document.form1.txt_email_testo.focus();
}
}
else{
document.form1.txt_email_email.value="@";
document.form1.txt_email_email.focus();
}
}
else{
document.form1.txt_email_email.focus();
}
}
else{
document.form1.txt_email_cognome.focus();
}
}
else{
document.form1.txt_email_nome.focus();
}
}

function sendnews(){
strName = document.form1.txt_newsletter_nome.value;
strLastName = document.form1.txt_newsletter_cognome.value;
strEmail = document.form1.txt_newsletter_email.value;
if (strName != ""){
if (strLastName != ""){
if (strEmail != ""){
if (checkMail('txt_newsletter_email') == true){
document.form1.HdnFnc.value = 5;
document.form1.submit();
}
else{
document.form1.txt_newsletter_email.value="@";
document.form1.txt_newsletter_email.focus();
}
}
else{
document.form1.txt_newsletter_email.focus();
}
}
else{
document.form1.txt_newsletter_cognome.focus();
}
}
else{
document.form1.txt_newsletter_nome.focus();
}
}

function findagency(){
if (document.form1.lstprovincia.value != 0){
if (document.form1.lstcomune.value != 0){
document.form1.HdnFnc.value = 6;
document.form1.submit();
}
else{
document.form1.lstcomune.focus();
}
}
else{
document.form1.lstprovincia.focus();
}
}

function removenow(){
if (checkMail("txt_newsletterremove_email") == true){
document.form1.HdnFnc.value = 12;
document.form1.submit();
}
else{
document.form1.txt_newsletterremove_email.focus();
}
}

function findestate(what){
if (document.form1["lstprovincia"+what].value != 0){
if (document.form1["lstcomune"+what].selectedIndex != 0){
switch (what) {
case "1_1":
document.form1.HdnFnc.value = 7;
break;
case "1_2":
document.form1.HdnFnc.value = 8;
}
document.form1.submit();
}
else{
document.form1["lstcomune"+what].focus();
}
}
else{
document.form1["lstprovincia"+what].focus();
}
}

function sendrch(){
document.retVal = false;
strName = document.form1.txtNome.value;
strLastName = document.form1.txtCognome.value;
strTelephone = document.form1.txtTelefono1.value;
strEmail = document.form1.txtMail.value;
strAddress = document.form1.txt_indirizzo.value;
strDescription = document.form1.txt_descrizione.value;
if (strName != ""){
if (strLastName != ""){
if (strTelephone != ""){
if (strEmail != ""){
if (checkMail('txtMail') == true){
if (strAddress != ""){
if (strDescription != ""){
if(document.form1.radio9[0].checked == true){
document.form1.HdnFnc.value = 11;
document.retVal = true;
}
else{
alert("Attenzione!\nSelezionare SI ed accettare il trattamento dei dati personali per inviare il modulo.\nSe il trattamento dei dati non è accettato non sarà possibile continuare.");
document.form1.radio9[0].focus();
}}
else{
document.form1.txt_descrizione.focus();
}
}
else{
document.form1.txt_indirizzo.focus();
}
}
else{
document.form1.txtMail.value="@";
document.form1.txtMail.focus();
}
}
else{
document.form1.txtMail.focus();
}
}
else{
document.form1.txtTelefono1.focus();
}
}
else{
document.form1.txtCognome.focus();
}
}
else{
document.form1.txtNome.focus();
}
}

function sendrchmdl(){
strName = document.form1.txtNome.value;
strLastName = document.form1.txtCognome.value;
strEmail = document.form1.txtMail.value;
strIndirizzo = document.form1.txtIndirizzo.value;
strComune = document.form1.txtComune.value;
strProvincia = document.form1.dropDown_provincia.value;
strCap = document.form1.txtCap.value;
strDescription = document.form1.txt_descrizione.value;
if (strName != ""){
if (strLastName != ""){
if (strEmail != ""){
if (checkMail('txtMail') == true){
if (strIndirizzo != ""){
if (strComune != ""){
if (strProvincia != ""){
if (strCap != ""){
if (strDescription != ""){
if(document.form1.radio9[0].checked == true){
document.form1.HdnFnc.value = 13;
document.form1.submit();
}
else{
alert("Attenzione!\nSelezionare SI ed accettare il trattamento dei dati personali per inviare il modulo.\nSe il trattamento dei dati non è accettato non sarà possibile continuare.");
document.form1.radio9[0].focus();
}
}
else{
document.form1.txt_descrizione.focus();
}
}
else{
document.form1.txtCap.focus();
}
}
else{
document.form1.dropDown_provincia.focus();
}
}
else{
document.form1.txtComune.focus();
}
}
else{
document.form1.txtIndirizzo.focus();
}
}
else{
document.form1.txtMail.value="@";
document.form1.txtMail.focus();
}
}
else{
document.form1.txtMail.focus();
}
}
else{
document.form1.txtCognome.focus();
}
}
else{
document.form1.txtNome.focus();
}
}

function checkInputData(InputName){
strData = document.form1[InputName].value;
strData.test = /\w/;
if (strData != false || strData != ""){
bTrue = true;
}
else{
bTrue = false;
}
return bTrue;}

function invia_modulo(){
document.retVal = false;
strName = document.form1.txtNome.value;
strLastName = document.form1.txtCognome.value;
strTelephone = document.form1.txtTelefono1.value;
strEmail = document.form1.txtMail.value;
if (strName != ""){
if (strLastName != ""){
if (strTelephone != ""){
if (strEmail != ""){
if (checkMail('txtMail') == true){
if(document.form1.radio9[0].checked == true){
document.form1.HdnFnc.value = 20;
document.retVal = true;
}
else{
alert("Attenzione!\nSelezionare SI ed accettare il trattamento dei dati personali per inviare il modulo.\nSe il trattamento dei dati non è accettato non sarà possibile continuare.");
document.form1.radio9[0].focus();
}
}
else{
document.form1.txtMail.value="@";
document.form1.txtMail.focus();
}
}
else{
document.form1.txtMail.focus();
}
}
else{
document.form1.txtTelefono1.focus();
}
}
else{
document.form1.txtCognome.focus();
}
}
else{
document.form1.txtNome.focus();
}
}

function checkMail(InputData){
Mail = document.form1[InputData].value;
var mailRet = false;
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
  	if (Filtro.test(Mail)){
	mailRet = true;}
return mailRet;}

function privacywin() {
width = (screen.width - 600)/2;
height = (screen.height - 500)/2;
win = window.open('privacy.asp','popup','width=600,height=500,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,screenX='+width+',screenY='+height+',top='+height+',left='+width+'');
win.focus();
}

function sendetail(query) {
width = (screen.width - 600)/2;
height = (screen.height - 500)/2;
win = window.open('sendetail.asp?'+query,'detail','width=600,height=500,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,screenX='+width+',screenY='+height+',top='+height+',left='+width+'');
win.focus();
}

function blocconote() {
width = (screen.width - 600)/2;
height = (screen.height - 500)/2;
win = window.open('blocconote.asp','blocconote','width=600,height=500,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,screenX='+width+',screenY='+height+',top='+height+',left='+width+'');
win.focus();
}

function keyControl(){
	if( (event.keyCode < 48) || (event.keyCode > 57 ) ){
		event.keyCode = "".charCodeAt(0);
	}
}

function Associa(source,target){
   with (document.form1[target])
     {
     while (options.length > 0)
       options[0]=null;
     for (i=0;i<sigle[source].length;i++)
	 if (sigle[source][i]!= ""){
       options[i]=new Option(sigle[source][i])
	   }
     options.selectedIndex=0;
	  }
   }
   
function AssociaPrezzo(source,target){
   with (document.form1[target])
     {
     while (options.length > 0)
       options[0]=null;
     for (i=0;i<prezzo[source].length;i++)
	 if (prezzo[source][i]!= ""){
       options[i]=new Option(testo[source][i],prezzo[source][i])
	   }
     options.selectedIndex=0;
	  }
   }
function AssociaPrezzoCommerciale(source,target){
   with (document.form1[target])
     {
     while (options.length > 0)
       options[0]=null;
     for (i=0;i<prezzocommerciale[source].length;i++)
	 if (prezzocommerciale[source][i]!= ""){
       options[i]=new Option(testocommerciale[source][i],prezzocommerciale[source][i])
	   }
     options.selectedIndex=0;
	  }
   }
function findestateperif(){
if (document.form1.txtA511.value != ''){
	document.form1.HdnFnc.value = 1111;
	document.form1.submit();
	}
	else{
		document.form1.txtA511.focus();
		}
}
	
function EnableSrcText(){
retVal = false;
string=document.form1.txtString.value;
if (string != ""){
document.form1.HdnFnc.value = 1000;
retVal = true;
}
else{
document.form1.txtString.focus();
}
return retVal;
}

function calcolarata(){
one_check = 0;
if (document.form1.dtlist_finalita.value == 0 && one_check == 0){
first_check = "dtlist_finalita";
one_check = 1;
}

if (document.form1.dtlist_prodotto.value == 0 && one_check == 0){
first_check = "dtlist_prodotto";
one_check = 1;
}

if (document.form1.txtImporto.value == "" && one_check == 0){
first_check = "txtImporto";
one_check = 1;
}

if (document.form1.dtlist_durata.value == 0 && one_check == 0){
first_check = "dtlist_durata";
one_check = 1;
}

if (one_check == 0){
width = (screen.width - 600)/2;
height = (screen.height - 500)/2;
win = window.open('calcolarata.asp?q1='+document.form1.dtlist_finalita.value+'&q2='+document.form1.dtlist_prodotto.value+'&q3='+document.form1.txtImporto.value+'&q4='+document.form1.dtlist_durata.value+'','calcolorata','width=600,height=500,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,screenX='+width+',screenY='+height+',top='+height+',left='+width+'');
win.focus();
}
else{
document.form1[first_check].focus();
}
}
function blankfnc(){
if (document.form1.txtString.value == 'cerca nel sito'){
document.form1.txtString.value = '';
}
}
