// JavaScript Document
percorsoFoto="../../public/"+idSessione+"/foto/";
percorsoLogo="../../public/"+idSessione+"/logo/";

/*------------------------- CONTROLLO CAMPI ------------------------------*/

stato="ANAGRAFICA"

function check(modulo){
	
	var messaggio="";
	var range_numerico;
	var right=true;
  	id_report = new Array();
	id_report["ANAGRAFICA"] = "errorAnagrafica";
	id_report["INFO"] = "errorInfo";
	id_report["CONTENUTI"] = "errorContenuti";
	id_report["REPORT"] = "report"; 
	
	if (stato=="REPORT"){
		messaggio+='<table><tr><td><div id="errorReport" class="error"></div></td></tr><tr><td>';
		messaggio+='<div class="sezione">1. <strong>anagrafica</strong></div><span class="nota">(cliente <strong>azienda</strong>)</span><br/><br/>';
	}
	
	/*----------------------------- ANAGRAFICA -------------------------*/
	
	if ((stato=="REPORT")||(stato=="ANAGRAFICA")){
		if (modulo.cliente[0].checked){
			if (modulo.ragione_sociale.value==""){
				messaggio+="<span class='wrong'>inserire la ragione sociale</span> <br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+="ragione sociale: "+modulo.ragione_sociale.value+"<br/>";
		}
		else{
			if (modulo.nome.value==""){
				messaggio+="<span class='wrong'>inserire il nome </span><br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+="nome: "+modulo.nome.value+"<br/>";
		}
		
		if (modulo.indirizzo.value==""){
			messaggio+="<span class='wrong'>inserire l'indirizzo</span>";
			right=false;
		}
		else if(stato=="REPORT") messaggio+="indirizzo: "+modulo.indirizzo.value;
		
		if (modulo.cap.value==""){
			messaggio+="<br/><span class='wrong'>inserire il cap</span><br/>";
			right=false;
		}
		else if(stato=="REPORT") messaggio+=" "+modulo.cap.value+"<br/>";
		
		if (modulo.citta.value==""){
			messaggio+="<span class='wrong'>inserire la citt&aacute;</span><br/>";
			right=false;
		}
		else if(stato=="REPORT") messaggio+=modulo.citta.value;
		
		if (modulo.provincia.value==""){
			messaggio+="<br/><span class='wrong'>inserire la provincia </span><br/>";
			right=false;
		}
		else if(stato=="REPORT") messaggio+=" ("+modulo.provincia.value+")<br/><br/>";
		
		if (modulo.cliente[0].checked){
			if (modulo.PI.value==""){
				messaggio+="<span class='wrong'>inserire la partita iva</span><br/><br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+="partita iva: "+modulo.PI.value+"<br/><br/>";
			if (modulo.riferimento.value==""){
				messaggio+="<span class='wrong'>inserire un riferimento</span><br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+=modulo.riferimento.value+" (riferimento)<br/>";
		}
		else{
			if (modulo.CF.value==""){
				messaggio+="<span class='wrong'>inserire il codice fiscale</span><br/><br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+="codice fiscale: "+modulo.CF.value+"<br/><br/>";
		}
		
		if (modulo.email.value==""){
			messaggio+="<span class='wrong'>inserire una mail</span><br/>";
			right=false;
		}
		else{
			var indirizzo_mail=modulo.email.value
			if ((indirizzo_mail.indexOf("@")==-1)||(indirizzo_mail.indexOf(".")==-1)){
				messaggio+="<span class='wrong'>"+modulo.email.value+" mail non valida</span><br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+=modulo.email.value+"<br/>";
		}
		
		if (modulo.telefono.value==""){
			messaggio+="<span class='wrong'>inserire un recapito telefonico</span><br/><br/>";
			right=false;
		}
		else{
			range_numerico=/\D/;              // lettera
			numero=modulo.telefono.value;
			if (range_numerico.test(numero)){
				messaggio+="<span class='wrong'>"+modulo.telefono.value+" inserisci solo caratteri numerici</span><br/><br/>";
				right=false;
			}
			else{
				range_numerico=/\d{9,}/;
				if (!(range_numerico.test(numero))){
					messaggio+="<span class='wrong'>"+modulo.telefono.value+" numero troppo corto</span><br/><br/>";
					right=false;
				}
				else if(stato=="REPORT") messaggio+=modulo.telefono.value+"<br/><br/>";
			}
		}	
		
		if (modulo.indirizzo_fatturazione.value!=""){
			if(stato=="REPORT")messaggio+="<span class='sottosezione'><strong>fatturare</strong> a:</span><br/>"+modulo.indirizzo_fatturazione.value;	
			if (modulo.cap_fatturazione.value==""){
				messaggio+="<br/><span class='wrong'>inserire il cap fatturazione</span><br/>";
				right=false;
			}	
			else if(stato=="REPORT") messaggio+=" "+modulo.cap_fatturazione.value+"<br/>";	
			if (modulo.citta_fatturazione.value==""){
				messaggio+="<span class='wrong'>inserire la citt&aacute; di fatturazione</span><br/>";
				right=false;
			}	
			else if(stato=="REPORT") messaggio+="città fatturazione: "+modulo.citta_fatturazione.value;
			if (modulo.provincia_fatturazione.value==""){
				messaggio+="<br/><span class='wrong'>inserire la provincia fatturazione</span><br/><br/>";
				right=false;
			}	
			else if(stato=="REPORT") messaggio+=" "+modulo.provincia_fatturazione.value+"<br/><br/>";	
		}
		
		if (modulo.indirizzo_consegna.value!=""){
			if(stato=="REPORT") messaggio+="<span class='sottosezione'><strong>inviare</strong> a:</span><br/> "+modulo.indirizzo_consegna.value;
			if (modulo.cap_consegna.value==""){
				messaggio+="<br/><span class='wrong'>inserire il cap consegna</span><br/>";
				right=false;
			}	
			else if(stato=="REPORT") messaggio+=" "+modulo.cap_consegna.value+"<br/>";	
			if (modulo.citta_consegna.value==""){
				messaggio+="<span class='wrong'>inserire la citt&aacute; di consegna</span><br/>";
				right=false;
			}	
			else if(stato=="REPORT") messaggio+="città consegna: "+modulo.citta_consegna.value;
			if (modulo.provincia_consegna.value==""){
				messaggio+="<br/><span class='wrong'>inserire la provincia consegna</span><br/><br/>";
				right=false;
			}
			else if(stato=="REPORT") messaggio+=" "+modulo.provincia_consegna.value+"<br/><br/>";	
		}
		
		if (!(modulo.consenso.checked)) {messaggio+="<span class='wrong'>è necessario autorizzare il trattamento dei dati personali</span><br/><br/>"; right=false;}
	}
		
	if (stato=="REPORT"){	
		messaggio+="</td></tr><tr><td class='noPadding'><div><img src='img/div_separatoreLongG.gif' alt=''></div></td></tr><tr><td>";		
		messaggio+='<span class="sezione">2. <strong>informazioni video</strong></span><br/>';
	}
	
	/*----------------------- VIDEO INFO -------------------------*/
	
	if ((stato=="REPORT")||(stato=="INFO")){
		checked=false;
		for (i=0; i<modulo.formato.length; i++) {
			if (modulo.formato[i].checked){
				checked=true;
				if (modulo.formato[i].value=="altro"){
					if (modulo.altro_formato.value=="") checked=false;
					else if(stato=="REPORT") messaggio+="formato: <strong>"+modulo.altro_formato.value+"</strong><br/>";
				}
				else if(stato=="REPORT") messaggio+="formato: "+modulo.formato[i].value+"<br/>";
				break;
			}
		}
		if (!checked){messaggio+="formato: <span class='wrong'>specifica il formato</span><br/>";right=false;}
		
		checked=false;
		altro=false;
		for (i=0; i<modulo.durata.length; i++) {
			if (modulo.durata[i].checked){
				checked=true;
				if (modulo.durata[i].value=="altro"){
					altro=true;
					if (modulo.altro_durata.value=="") checked=false;
					else{ if(stato=="REPORT") {messaggio+="durata: <strong>"+modulo.altro_durata.value+"</strong> secondi<br/>"; costo="da concordare telefonicamente"}}
				}
				else{ if(stato=="REPORT"){ messaggio+="durata: "+modulo.durata[i].value+"<br/>"; costo=i*50+250+"&euro;"}}
				break;
			}
		}
		if (!checked) {messaggio+="durata: <span class='wrong'>specifica la durata</span><br/>";right=false;}
		
		checked=false;
		for (i=0; i<modulo.utilizzo.length; i++) {
			if (modulo.utilizzo[i].checked){
				checked=true;
				if (modulo.utilizzo[i].value=="altro"){
					if (modulo.altro_utilizzo.value=="") checked=false;
					else if(stato=="REPORT") messaggio+="durata: <strong>"+modulo.altro_utilizzo.value+"</strong><br/><br/>";
				}
				else if(stato=="REPORT") messaggio+="utilizzo: "+modulo.utilizzo[i].value+"<br/><br/>";
				break;
			}
		}
		if (!checked) {messaggio+="utilizzo: <span class='wrong'>specifica il tipo di utilizzo</span><br/><br/>";right=false;}
	}
	
	if (stato=="REPORT"){
		messaggio+='</td></tr><tr><td class="noPadding"><div><img src="img/div_separatoreLongG.gif" alt=""></div></td></tr><tr><td>';
		messaggio+='<span class="sezione">3. <strong>contenuti video</strong></span><br/>';
	}
	
	/*---------------------- VIDEO CONTENT -------------------*/
	
	if ((stato=="REPORT")||(stato=="CONTENUTI")){
		if (!(altro)){
		
			if(stato=="REPORT") messaggio+="immagini:<br/>";
			if (contatore>maxFoto){
				messaggio+="<span class='wrong'>sono state inserite troppe immagini rispetto alla durata selezionata; diminuire il numero di immagini o aumentare la durata (inserite"+contatore+" di "+maxFoto+" immagini richieste)<br/></span>"; right=false;
			}
			else{
				if (minFoto==0){messaggio+="<span class='wrong'>inserire immagini</span><br/>"; right=false;}
				if (contatore<minFoto){messaggio+="<span class='wrong'>non è stato inserito il numero di immagini richieste (inserite "+contatore+" di "+minFoto+" richiestre)</span><br/>"; right=false;}
				else
					if(stato=="REPORT"){
						//messaggio+=contatore+"/"+maxFoto+"<br/>";
						tabella=document.getElementById("listaFoto");
						tr=tabella.getElementsByTagName('tr');
						for(i=0; i<tr.length;i++){
							if (i<10) y="0"+(i+1);
							else y=(i+1);
							messaggio+=y+". <a href='"+percorsoFoto+tr[i].getElementsByTagName("td")[2].firstChild.nodeValue+"' target='_blank'>"+tr[i].getElementsByTagName("td")[2].firstChild.nodeValue+"</a><br/>";
						}
					}
			}
			
			if (contatoreLogo>=1){
				messaggio+="<br/>logo:<br/>"
				tabella=document.getElementById("lista_logo");
				tr=tabella.getElementsByTagName('tr');
				for(i=0; i<tr.length;i++){
					messaggio+=tr[i].getElementsByTagName("td")[1].firstChild.nodeValue+"<br/>";
				}
			}
		
			if(stato=="REPORT") messaggio+="<br/>testo:<br/>"
			if (modulo.testo.value==""){
				messaggio+="<span class='wrong'>inserire testo</span><br/>"; right=false;}
			else if(stato=="REPORT") messaggio+=modulo.testo.value+"<br/>";
				
		}
	
		if(stato=="REPORT") messaggio+="<br/>speaker:<br/>"
		checked=false;
		for (i=0; i<modulo.speaker.length; i++) {
			if (modulo.speaker[i].checked){
				checked=true;
				break;
			}
		}	
		if (!checked) {messaggio+="<span class='wrong'>specifica speaker desiderato</span><br/>";right=false;}
		else if(stato=="REPORT") messaggio+=modulo.speaker[i].value+"<br/>";
		
		if(stato=="REPORT") messaggio+="<br/>base musicale:<br/>"
		checked=false;
		for (i=0; i<modulo.base.length; i++) {
			if (modulo.base[i].checked){
				checked=true;
				break;
			}
		}
		if (!checked) {messaggio+="<span class='wrong'>specifica la base desiderato</span><br/>";right=false;}
		else if(stato=="REPORT") messaggio+=modulo.base[i].value+"<br/><br/>";
	}
	
	if (stato=="REPORT"){
		messaggio+='</td></tr><tr><td class="noPadding"><div><img src="img/div_separatoreLongG.gif" alt=""></div></td></tr><tr><td>';	
		messaggio+='<p class="costo">costo servizio: <strong>'+costo+'</strong><p>';
		messaggio+='</td></tr></table>';
	}
	
	/*------------------- SCRITTURA -----------------------------*/
	
	//alert(elemento)
	var elemento;
	if ((stato=="CONTENUTI")&&(altro)) id="errorContenutiAltro";
	else id=id_report[stato];
		
	if(document.getElementById)
		elemento = document.getElementById(id);
	else
		elemento = document.all[id];

	elemento.innerHTML=messaggio;
	
	if (stato=="REPORT"){
		document.getElementById("corpoFile").value=messaggio;
	}

	//alert(right);
	return(right);
}

/*----------------------------*/
/*-------------------------- GESTIONE INSERIMENTO IMMAGINI ------------------------------*/
/*----------------------------*/

contatore=0;
contatoreLogo=0;
maxFoto=0;
minFoto=0;
costo=0;

function addImg(img){
	//alert("addImg");
	++contatore;
	var r  = document.createElement('tr');
	var ca = document.createElement('td');
	ca.setAttribute('class', 'small');
	ca.setAttribute('width', '15');
	var cb = document.createElement('td');
	var cc = document.createElement('td');
	var cd = document.createElement('td');
	cd.setAttribute('class', 'small');
	cd.setAttribute('width', '15');
	var ta = document.createElement('a');
	ta.setAttribute('href', '#');
	//ta.setAttribute('onclick', 'cancella("'+img+'"); return false');
	ta.onclick = function(){cancella(img); return false};
	var tCancella = document.createElement('img');
	tCancella.setAttribute('src', 'img/cancel.gif');
	var tb = document.createTextNode(img);
	var tc = document.createTextNode(contatore);
	var td = document.createElement('a');
	td.setAttribute('href', '#');
	td.onclick = function(){up(img); return false};
	var tUp = document.createElement('img');
	tUp.setAttribute('src', 'img/up.gif');
	
	ta.appendChild(tCancella);
	td.appendChild(tUp);
	
	ca.appendChild(ta);
	cb.appendChild(tb);
	cc.appendChild(tc);
	cd.appendChild(td);
	
	r.appendChild(ca);
	r.appendChild(cd);
	r.appendChild(cb);
	//r.appendChild(cc);
	
	table=document.getElementById("listaFoto");
	table.appendChild(r);
	if (contatore>=maxFoto){
		document.getElementById('frameFoto').style.display="none";
		//document.getElementById('frameFoto').disable=true;
		//frames['frameFoto'].disabilita();
		//frameFoto.document.getElementById('submitFile').disable=true;
	}
	document.getElementById('contatore').innerHTML=contatore;
}

function addLogo(img){
	++contatoreLogo;
	var r  = document.createElement('tr');
	var ca = document.createElement('td');
	ca.setAttribute('class', 'small');
	var cb = document.createElement('td');
	var cc = document.createElement('td');
	var cd = document.createElement('td');
	cd.setAttribute('class', 'small');
	var ta = document.createElement('a');
	ta.setAttribute('href', '#');
	ta.onclick = function(){cancellaLogo(); return false};
	var tCancella = document.createElement('img');
	tCancella.setAttribute('src', 'img/cancel.gif');
	var tb = document.createTextNode(img);
	var tc = document.createTextNode(contatore);
	var td = document.createElement('a');
	td.setAttribute('href', '#');
	td.onclick = function(){up(img); return false};
	var tUp = document.createElement('img');
	tUp.setAttribute('src', 'img/up.gif');
	
	ta.appendChild(tCancella);
	td.appendChild(tUp);
	
	ca.appendChild(ta);
	cb.appendChild(tb);
	cc.appendChild(tc);
	cd.appendChild(td);
	
	r.appendChild(ca);
	//r.appendChild(cd);
	r.appendChild(cb);
	//r.appendChild(cc);
	
	table=document.getElementById("lista_logo");
	table.appendChild(r);
	if (contatoreLogo>=1){
		document.getElementById('frameLogo').style.display="none";
		//document.getElementById('frameFoto').disable=true;
		//frames['frameFoto'].disabilita();
		//frameFoto.document.getElementById('submitFile').disable=true;
	}
}

function cancella(img){
	//alert(img);
	tabella=document.getElementById("listaFoto");
	tr=tabella.getElementsByTagName('tr');
	for(i=0; i<tr.length;i++){
		//alert(tr[i].getElementsByTagName("td")[2].firstChild.nodeValue+"=="+img);
		if (tr[i].getElementsByTagName("td")[2].firstChild.nodeValue==img){
			--contatore;
			document.getElementById('contatore').innerHTML=contatore;
			tabella.removeChild(tr[i]);
			document.getElementById('frameFoto').style.display="block";
			break;
		}
	}
}

function cancellaLogo(){
	tabella=document.getElementById("lista_logo");
	tr=tabella.getElementsByTagName('tr');
	for(i=0; i<tr.length;i++){
		--contatoreLogo;
		tabella.removeChild(tr[i]);
		document.getElementById('frameLogo').style.display="block";
	}
}

function up(img){
	//alert("up "+img);
	tabella=document.getElementById("listaFoto");
	tr=tabella.getElementsByTagName('tr');
	for(i=0; i<tr.length;i++){
		//alert(tr[i].getElementsByTagName("td")[2].firstChild.nodeValue+"=="+img);
		if (tr[i].getElementsByTagName("td")[2].firstChild.nodeValue==img){
			if (i>0)
				tabella.insertBefore(tr[i], tr[i-1]);
			else
				//alert("già in prima posizione");
			break;
		}
	}
	//parent.insertBefore(tr[img], tr[imgBefore]);
}

/*-------------------------------- GESTIONE VISUALIZZAZIONE DIV --------------------------------*/

function newWin(name, path){	
	var j=new WinLIKE.window(name,572,179,209,353,5);
	j.Nam="istruzioni";
	j.Mn=false;
	j.Cls=false;
	j.Ski='businessmovie2';
	j.Adr=path;
	WinLIKE.addwindow(j);
}

function anagrafica(){
	stato="ANAGRAFICA"
	document.getElementById('conferma').checked=false;
	document.getElementById('banner').style.display="block";
	document.getElementById('anagrafica').style.display="block";
	document.getElementById('video_info').style.display="none";
	document.getElementById('contenuti').style.display="none";
	document.getElementById('riepilogo').style.display="none";
	document.getElementById('botta_e_risposta').style.display="block";
	if (WinLIKE.windows.length>3){
		WinLIKE.windows[3].Vis=false;
		WinLIKE.windows[3].draw();
	}
	var IE = navigator.appName.indexOf("Microsoft") != -1;
	var oggettoFlash = IE ? window.flashNavigazione : window.document.flashNavigazione;
	oggettoFlash.SetVariable("v1","true");
	oggettoFlash.SetVariable("v2","false");
	oggettoFlash.SetVariable("v3","false");
	oggettoFlash.SetVariable("v4","false");
	oggettoFlash.SetVariable("v5","false");
	oggettoFlash.GotoFrame(1);
	oggettoFlash.Play();
}

function video(modulo){
	//alert(check(modulo));
	if ((modulo==0) || (check(modulo))){
		stato="INFO"
		document.getElementById('conferma').checked=false;
		document.getElementById('banner').style.display="none";
		document.getElementById('anagrafica').style.display="none";
		document.getElementById('video_info').style.display="block";
		document.getElementById('contenuti').style.display="none";
		document.getElementById('riepilogo').style.display="none";
		document.getElementById('botta_e_risposta').style.display="none";
		if (WinLIKE.windows.length>3){
			WinLIKE.windows[3].Ttl="istruzioni";
			window.open("istruzioni/istruzioni3.htm","istruzioni");
			WinLIKE.windows[3].Vis=true;
			WinLIKE.windows[3].draw();
		}
		else{
			newWin("istruzioni", "istruzioni/istruzioni3.htm");
			WinLIKE.windows[3].Vis=true;
			WinLIKE.windows[3].draw();
		}
		var IE = navigator.appName.indexOf("Microsoft") != -1;
		var oggettoFlash = IE ? window.flashNavigazione : window.document.flashNavigazione;
		oggettoFlash.SetVariable("v1","false");
		oggettoFlash.SetVariable("v2","true");
		oggettoFlash.SetVariable("v3","false");
		oggettoFlash.SetVariable("v4","false");
		oggettoFlash.SetVariable("v5","false");
		oggettoFlash.GotoFrame(1);
		oggettoFlash.Play();
	}
}

function contenuti(modulo){
	//alert(modulo);
	if ((modulo==0) || (check(modulo))){
		stato="CONTENUTI"
		//alert("contenuti");
		if(modulo!=0){
			checked=false;
			for (i=0; i<modulo.durata.length; i++) {
				//alert(i);
				if (modulo.durata[i].checked){
					checked=true;
					if (modulo.durata[i].value=="altro"){
						document.getElementById('container_foto').style.display="none";
						document.getElementById('container_testo').style.display="none";
						document.getElementById('avviso').style.display="block";
					}
					else{
						document.getElementById('container_foto').style.display="block";
						document.getElementById('container_testo').style.display="block";
						document.getElementById('avviso').style.display="none";
						switch (i){
							case 0: minFoto=5; maxFoto=10; maxChar=500; document.getElementById('numero_foto').innerHTML="filmato da <strong>30\"</strong> | n° min: <strong>5</strong> n° max: <strong>10</strong>"; document.getElementById('numero_char').innerHTML="filmato da <strong>30\"</strong> | n° max di caratteri: <strong>500</strong>"; break;
							case 1: minFoto=10; maxFoto=15; maxChar=1000; document.getElementById('numero_foto').innerHTML="filmato da <strong>60\"</strong> | n° min: <strong>10</strong> n° max: <strong>15</strong>"; document.getElementById('numero_char').innerHTML="filmato da <strong>60\"</strong> | n° max di caratteri: <strong>1000</strong>"; break;
							case 2: minFoto=15; maxFoto=20; maxChar=1500; document.getElementById('numero_foto').innerHTML="filmato da <strong>90\"</strong> | n° min: <strong>15</strong> n° max: <strong>20</strong>"; document.getElementById('numero_char').innerHTML="filmato da <strong>90\"</strong> | n° max di caratteri: <strong>1500</strong>"; break;
						}	
					}
					//alert("maxFoto="+maxFoto);
					break;
				}
			}
			if (!checked){
				document.getElementById('numero_foto').innerHTML="durata filmato <strong>non selezionata</strong> | n° max di immagini: <strong>0</strong>";
				document.getElementById('numero_char').innerHTML="durata filmato <strong>non selezionata</strong> | n° max di caratteri: <strong>0</strong>";
			}
			if (contatore>=maxFoto){
				document.getElementById('frameFoto').style.display="none";
			}
			else{
				document.getElementById('frameFoto').style.display="block";
			}
			calcolaCaratteri();
		}
		document.getElementById('banner').style.display="none";
		document.getElementById('anagrafica').style.display="none";
		document.getElementById('video_info').style.display="none";
		document.getElementById('contenuti').style.display="block";
		document.getElementById('riepilogo').style.display="none";
		document.getElementById('botta_e_risposta').style.display="none";
		if (WinLIKE.windows.length>3){
			WinLIKE.windows[3].Ttl="istruzioni";
			window.open("istruzioni/istruzioni.htm","istruzioni");
			WinLIKE.windows[3].Vis=true;
			WinLIKE.windows[3].draw();
		}
		else{
			newWin("istruzioni", "istruzioni/istruzioni.htm");
			WinLIKE.windows[3].Vis=true;
			WinLIKE.windows[3].draw();
		}
		var IE = navigator.appName.indexOf("Microsoft") != -1;
		var oggettoFlash = IE ? window.flashNavigazione : window.document.flashNavigazione;
		oggettoFlash.SetVariable("v1","false");
		oggettoFlash.SetVariable("v2","false");
		oggettoFlash.SetVariable("v3","true");
		oggettoFlash.SetVariable("v4","false");
		oggettoFlash.SetVariable("v5","false");
		oggettoFlash.GotoFrame(1);
		oggettoFlash.Play();
	}
}

function riepilogo(modulo){
	stopBrano();
	if ((modulo==0) || (check(modulo))){
		stato="REPORT";
		check(modulo);
		document.getElementById('banner').style.display="none";
		document.getElementById('anagrafica').style.display="none";
		document.getElementById('video_info').style.display="none";
		document.getElementById('contenuti').style.display="none";
		document.getElementById('riepilogo').style.display="block";
		document.getElementById('botta_e_risposta').style.display="none";
		if (WinLIKE.windows.length>3){
			WinLIKE.windows[3].Ttl="consegna";
			window.open("consegna/consegna.htm","istruzioni");
			WinLIKE.windows[3].Vis=true;
			WinLIKE.windows[3].draw();
		}
		else{
			newWin("istruzioni", "istruzioni/istruzioni.htm");
			WinLIKE.windows[3].Vis=true;
			WinLIKE.windows[3].draw();
		}
		var IE = navigator.appName.indexOf("Microsoft") != -1;
		var oggettoFlash = IE ? window.flashNavigazione : window.document.flashNavigazione;
		oggettoFlash.SetVariable("v1","false");
		oggettoFlash.SetVariable("v2","false");
		oggettoFlash.SetVariable("v3","false");
		oggettoFlash.SetVariable("v4","true");
		oggettoFlash.SetVariable("v5","false");
		oggettoFlash.GotoFrame(1);
		oggettoFlash.Play();
	}
}

function pagamento(modulo){
	if (document.getElementById('conferma').checked){
		modulo.submit();
	}
	else{
		var elemento;
		id="errorReport";
		
		if(document.getElementById)
			elemento = document.getElementById(id);
		else
			elemento = document.all[id];

		elemento.innerHTML="<span class='wrong'>per proseguire &egrave; e necessario confermare l'esattezza dei dati</span>";	
	}
}

function fatturazione(modulo){
	if (document.getElementById('fatturazione').style.display!="none"){
		document.getElementById('fatturazione').style.display="none";
		document.getElementById('fatturazione1').style.display="block";
		document.getElementById('fatturazione2').style.display="block";
	}
	else{
		document.getElementById('fatturazione').style.display="block";
		document.getElementById('fatturazione1').style.display="none";
		document.getElementById('fatturazione2').style.display="none";
		modulo.indirizzo_fatturazione.value="";
		modulo.cap_fatturazione.value="";
		modulo.citta_fatturazione.value="";
		modulo.provincia_fatturazione.value="";
	}
}

function consegna(modulo){
	if (document.getElementById('consegna').style.display!="none"){
		document.getElementById('consegna').style.display="none";
		document.getElementById('consegna1').style.display="block";
		document.getElementById('consegna2').style.display="block";
	}
	else{
		document.getElementById('consegna').style.display="block";
		document.getElementById('consegna1').style.display="none";
		document.getElementById('consegna2').style.display="none";
		modulo.indirizzo_consegna.value="";
		modulo.cap_consegna.value="";
		modulo.citta_consegna.value="";
		modulo.provincia_consegna.value="";
	}
}

function cambiaCliente(elem){
	if(elem.cliente[0].checked){
		document.getElementById('ragione_sociale').disabled=false;
		document.getElementById('ragione_sociale').style.backgroundColor="#fff";
		document.getElementById('riferimento').disabled=false;
		document.getElementById('riferimento').style.backgroundColor="#fff";
		document.getElementById('PI').disabled=false;
		document.getElementById('PI').style.backgroundColor="#fff";
		document.getElementById('nome').disabled=true;
		document.getElementById('nome').style.backgroundColor="#ebebe4";
		document.getElementById('nome').value="";
		document.getElementById('CF').disabled=true;
		document.getElementById('CF').style.backgroundColor="#ebebe4";
		document.getElementById('CF').value="";
	}
	else{
		document.getElementById('ragione_sociale').disabled=true;
		document.getElementById('ragione_sociale').style.backgroundColor="#ebebe4";
		document.getElementById('ragione_sociale').value="";
		document.getElementById('riferimento').disabled=true;
		document.getElementById('riferimento').style.backgroundColor="#ebebe4";
		document.getElementById('riferimento').value="";
		document.getElementById('PI').disabled=true;
		document.getElementById('PI').style.backgroundColor="#ebebe4";
		document.getElementById('PI').value="";
		document.getElementById('nome').disabled=false;
		document.getElementById('nome').style.backgroundColor="#fff";
		document.getElementById('CF').disabled=false;
		document.getElementById('CF').style.backgroundColor="#fff";
	}
	//alert("cambiaCliente");
}

maxChar=0;
function calcolaCaratteri(){
	char=document.getElementById('testo').value.length;
	if (char<=maxChar){
		document.getElementById('nChar').innerHTML=char;
	}
	else{
		document.getElementById('testo').value=document.getElementById('testo').value.substr(0,maxChar);	
		document.getElementById('nChar').innerHTML=maxChar;
	}
}

function visualizza(id){
	document.getElementById(id).style.display="block";
}

function nascondi(id){
	document.getElementById(id).style.display="none";
}

function flashNav(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="367" height="131" title="galleria" id="flashNavigazione">\n');
	document.write('<param name="movie" value="img/procedura.swf" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent">\n');
	document.write('<embed src="img/procedura.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="367" height="131" swLiveConnect="true" name="flashNavigazione"></embed>\n');
	document.write('</object>\n');
}

function flashPlayer(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="345" height="43" title="player" id="flashMPlayer">\n');
	document.write('<param name="movie" value="img/player.swf" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<embed src="img/player.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="345" height="43" swLiveConnect="true" name="flashMPlayer"></embed>\n');
	document.write('</object>\n');
}

function stopBrano(){
	var IE = navigator.appName.indexOf("Microsoft") != -1;
	var oggettoFlash = IE ? window.document.getElementById("flashMPlayer") : window.document.flashMPlayer;
	//alert(oggettoFlash);
	//oggettoFlash.SetVariable("tune",i);
	oggettoFlash.GotoFrame(5);
	//oggettoFlash.Play();
	//alert("stopBrano");
}

function setBrano(i){
	var IE = navigator.appName.indexOf("Microsoft") != -1;
	var oggettoFlash = IE ? window.document.getElementById("flashMPlayer") : window.document.flashMPlayer;
	//alert(oggettoFlash);
	oggettoFlash.SetVariable("tune",i);
	oggettoFlash.GotoFrame(3);
	//oggettoFlash.Play();
}
