function focuskeyc()
{
try {document.getElementById("keyc").focus();} catch(e) {}
endFlash=4;
if (idsetInterval>0) clearInterval(idsetInterval);
}
function focuspwd()
{
try {document.getElementById("pwd").focus();} catch(e) {}
endFlash=4;
if (idsetInterval>0) clearInterval(idsetInterval);
}

function focuspromo()
{
try {document.getElementById("SCELTAP").style.textDecoration="underline";} catch(e) {}
try {document.getElementById("SCELTAP").focus();} catch(e) {}
endFlash=4;
if (idsetInterval>0) clearInterval(idsetInterval);
}
function focusform()
{
try {document.forms["ins_dati"].EMAIL.focus();} catch(e) {}
try {document.forms["ins_dati"].NOME.focus();} catch(e)  {}
endFlash=4;
if (idsetInterval>0) clearInterval(idsetInterval);
}
function TestEndSwf()
{
try
	{
	mySwf = window.document.getElementById("flashwizard");
	//ReadyState (get only) - 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.
	//TotalFrames (get only) - Returns the total number of frames in the movie. This is not available until the movie has loaded. Wait for ReadyState = 4.
	//FrameNum (get or set) - The currently displayed frame of the movie. Setting this will advance or rewind the movie.
	var ReadyState=mySwf.ReadyState;
	if ((endFlash<4) && (ReadyState==4))
		{
		var TotalFrames=mySwf.TotalFrames;
		var FrameNum=mySwf.FrameNum;
		if (FrameNum >= (TotalFrames-1))
			{
			var wzpasso=document.getElementById("wzpasso").value;// wzpasso è il PASSO SUCCESSIVO settato in automatico nella form
			if (wzpasso=="6")
				{setTimeout("focusform()",1000);}
			else if (wzpasso=="5")
				{setTimeout("focuspromo()",1000);}			
			else if (wzpasso=="0")
				{setTimeout("focuspwd()",1000);}			
			else if (wzpasso=="")
				{setTimeout("focuskeyc()",1000);}			
			else 
				{setTimeout("document.getElementById(\"formwizard\").submit();",3000);}
			endFlash=4;
			if (idsetInterval>0) clearInterval(idsetInterval);
			}
		}
	}
catch(e)
	{
//	alert(e.description);
	endFlash=4;
	clearInterval(idsetInterval);
	}
}
function onloadfilmato()
{
var ok=true;
endFlash=2;
try
	{
	mySwf = window.document.getElementById("flashwizard");
	}
catch(e)
	{
	ok=false;
	}
if (ok) {idsetInterval=setInterval( TestEndSwf, 5000);}
}

function prima_lettera_maiuscola(stringa)
{
var stemp="";
var arrfr=String(stringa).replace("  "," ").split(" ");
for (i=0;i<arrfr.length;i++)
	{
	if ((arrfr[i].length)>2)
		{
		stemp+=String(arrfr[i]).substr(0,1).toUpperCase()+String(arrfr[i]).substr(1) 
		}
	else
		{
		stemp+=arrfr[i] 
		}
	stemp+=" ";
	}
return stemp;	
}
function verifica_form()
{
	if (document.forms["ins_dati"].NOME.value=="")
	{
		alert("Si prega di indicare il nome.")
		document.forms["ins_dati"].NOME.select()
		document.forms["ins_dati"].NOME.focus()		
		return
	}
	document.forms["ins_dati"].NOME.value=prima_lettera_maiuscola(document.forms["ins_dati"].NOME.value);
	if (document.forms["ins_dati"].COGNOME.value=="")
	{
		alert("Si prega di indicare il cognome.")
		document.forms["ins_dati"].COGNOME.select()
		document.forms["ins_dati"].COGNOME.focus()		
		return
	}
	document.forms["ins_dati"].COGNOME.value=prima_lettera_maiuscola(document.forms["ins_dati"].COGNOME.value);	
	if (document.forms["ins_dati"].RAGIONE_SOCIALE.value=="")
	{
		alert("Si prega di indicare la ragione sociale.")
		document.forms["ins_dati"].RAGIONE_SOCIALE.select()
		document.forms["ins_dati"].RAGIONE_SOCIALE.focus()		
		return
	}	
	document.forms["ins_dati"].RAGIONE_SOCIALE.value=prima_lettera_maiuscola(document.forms["ins_dati"].RAGIONE_SOCIALE.value);		

	if (document.forms["ins_dati"].INDIRIZZO.value=="")
	{
		alert("Si prega di indicare l'indirizzo.")
		document.forms["ins_dati"].INDIRIZZO.select()
		document.forms["ins_dati"].INDIRIZZO.focus()		
		return
	}		
	
	if (document.forms["ins_dati"].COMUNE.value=="")
	{
		alert("Si prega di indicare il comune.")
		document.forms["ins_dati"].COMUNE.select()
		document.forms["ins_dati"].COMUNE.focus()		
		return
	}	

	if (document.forms["ins_dati"].CAP.value=="")
	{
		alert("Si prega di indicare il CAP.")
		document.forms["ins_dati"].CAP.select()
		document.forms["ins_dati"].CAP.focus()		
		return
	}	

	if (document.forms["ins_dati"].PROVINCIA.value=="")
	{
		alert("Si prega di indicare la provincia.")
		document.forms["ins_dati"].PROVINCIA.select()
		document.forms["ins_dati"].PROVINCIA.focus()		
		return
	}	
				
	if (document.forms["ins_dati"].PIVA.value=="")
	{
		alert("Si prega di indicare la Partita IVA.")
		document.forms["ins_dati"].PIVA.select()
		document.forms["ins_dati"].PIVA.focus()		
		return
	}
	if(!(controlla_piva(document.forms["ins_dati"].PIVA.value)))
	{
		alert("E' stata indicata una partita IVA non valida. Si prega di verificare la sintassi");
		document.forms["ins_dati"].PIVA.select()
		document.forms["ins_dati"].PIVA.focus()		
		return;
	}
	if (document.forms["ins_dati"].TELEFONO.value=="")
	{
		alert("Si prega di indicare il numero di telefono.")
		document.forms["ins_dati"].TELEFONO.select()
		document.forms["ins_dati"].TELEFONO.focus()		
		return
	}
	if (isNaN(document.forms["ins_dati"].TELEFONO.value))
	{
		alert("E' stato indicato un numero di telefono non valido. Si prega di verificare.")
		document.forms["ins_dati"].TELEFONO.select()
		document.forms["ins_dati"].TELEFONO.focus()		
		return
	}
	if (document.forms["ins_dati"].EMAIL.value=="")
	{
		alert("Si prega di indicare il recapito e-mail.")
		document.forms["ins_dati"].EMAIL.select()
		document.forms["ins_dati"].EMAIL.focus()		
		return
	}
	if(!controllo_email(document.forms["ins_dati"].EMAIL.value))
	{
		alert("E' stato indicato un indirizzo e-mail non valido.\nSi prega di verificare la correttezza della sintassi.")
		document.forms["ins_dati"].EMAIL.select()
		document.forms["ins_dati"].EMAIL.focus()		
		return
	}
	
	
	if (confirm("Confermi la registrazione?"))
		{
		document.forms["ins_dati"].action=urlattuale;
		document.forms["ins_dati"].submit()
		}
}


function wizard_registrazione_cli_radio()
{
try
	{
	var obj=document.getElementById("consenso_dati_personali_675_si");
	var valoredisplay_si=( obj.checked && obj.value=='si') ? "" : "none";
	var valorevisibility_si=( obj.checked && obj.value=='si') ? "" : "hidden";
	var valoredisplay_no=( valoredisplay_si=='none') ? "" : "none";
	var valorevisibility_no=( valoredisplay_si=='none') ? "" : "hidden";
	document.getElementById("span_non_do_il_consenso").style.display=valoredisplay_no;
	document.getElementById("span_non_do_il_consenso").style.visibility=valorevisibility_no;
	}
catch(e)
	{
	}
try
	{
	document.getElementById("immagine_conferma_registrazione_dati").style.display=valoredisplay_si;	
	document.getElementById("immagine_conferma_registrazione_dati").style.visibility=valorevisibility_si;	
	}
catch(e)
	{
	}	
}
function opencontratto()
{

	window.open('ftp://ftp.executive.it/allegati/moduli/RID2009.pdf','_new');
	void wizard_registrazione_cli_radio();
}

function wizardplay()
{
try {
	var mySwf=document.getElementById("flashwizard");
	void mySwf.Play();
	//void onloadfilmato()	
	} 
catch(e) 
	{
	}
}
function wizardstop()
{
try 
	{
	var mySwf=document.getElementById("flashwizard");
	void mySwf.Stop();
	endFlash=4;
	clearInterval(idsetInterval);
	} 
catch(e) 
	{}
}

function wizard_indietro(newurl,passo)
{
if (newurl!="") document.getElementById("formwizard").action=newurl;
//document.getElementById("view").value=view;
document.getElementById("wzpasso").value=passo;
document.getElementById("formwizard").submit();
}
function wizard_avanti(newurl,passo)
{
///document.getElementById("view").value=view;
if (newurl!="") document.getElementById("formwizard").action=newurl;
document.getElementById("wzpasso").value=passo;
document.getElementById("formwizard").submit();
}
function wizard_topmenu(newurl,passo)
{
if (newurl!="") document.getElementById("formwizard").action=newurl;
document.getElementById("wzpasso").value=passo;
document.getElementById("formwizard").submit();
}
function wizard_leftmenu(newurl,passo)
{
if (newurl!="") document.getElementById("formwizard").action=newurl;
document.getElementById("wzpasso").value=passo;
document.getElementById("formwizard").submit();
}
function wizard_freemenu(newurl,passo)
{
if (newurl!="") document.getElementById("formwizard").action=newurl;
document.getElementById("wzpasso").value=passo;
document.getElementById("formwizard").submit();
}

function wizard_ukc_form(passo,elencorequest)
{
//document.getElementById("view").value=view;
var arrayrequest=String(elencorequest).split("~");
for(var i=0;i<arrayrequest.length;i+=2)
	{
	var obj=document.getElementById(arrayrequest[i])
	if (obj!=null) obj.value=arrayrequest[i+1];
	}
document.getElementById("wzpasso").value=passo;
document.getElementById("formwizard").submit();
}
function entrapwdesk()
{
if(String(document.getElementById("pwdexe").value).replace("undefined","")=="" || String(document.getElementById("pwdexe").value).length<4)
	{alert("Password non corretta!");return;}
if(!confirm("Sei sicuro di voler entrare in PowerDesk?")) {return;}
document.getElementById("cod_cli_exe").value=document.getElementById("codcliexe").value;
document.getElementById("pwd").value=document.getElementById("pwdexe").value;
document.getElementById("ins_ag").submit();
}
