
	function _InitSPENALZO()
	{

	
		setTimeout("dispatchClick()",100);


		//Inizializzazione gestore evento click
		if (document.addEventListener)
			document.addEventListener("click",dispatchClick, false);
		else if (window.attachEvent)
			document.attachEvent("onclick", dispatchClick);
	

	}
	
	function bo(area)
	{
			caricameloTutto('PanelRight','loadProgramma.asp?areaid='+area);
			caricameloTutto('PanelComandi','loadComandi.asp?areaid='+area);
	}

	function salvaUtente()
	{
	elemento = document.frmSalvataggio;
	utenteID = elemento.utenteID.value;
	nomeutente= elemento.nomeutente.value;
	password = elemento.password.value;
	cognome = elemento.cognome.value;
	nome = elemento.nome.value;
	email = elemento.email.value;
	accessol = elemento.accesso.length;
	utenteTipo = elemento.utenteTipo.value;
	if(elemento.stato[0].checked){
		stato = 1;
	}else{
		stato = 0;
	}


	stringaAccessi = "";
	for(k=0;k<accessol;k++){
		if(elemento.accesso[k].checked)
			stringaAccessi += elemento.accesso[k].value+'#';
	}	

	stringParameters =  "utenteID="+encodeURI(utenteID) +
						"&nomeutente="+encodeURI(nomeutente)+
						"&password="+encodeURI(password)+
						"&cognome="+encodeURI(cognome)+
						"&nome ="+encodeURI(nome)+
						"&email ="+encodeURI(email)+
						"&utenteTipo="+utenteTipo+
						"&stato ="+stato+
						"&stringaaccessi ="+stringaAccessi;

	
		if(utenteID==0){
			if(confirm("Stai per salvare un utente;\n\nvuoi continuare?")){							
				fmk$PostCall('gestioneUtentiManageACT.asp',stringParameters,true,'confermaSalva');	
			}
		}else{
			fmk$PostCall('gestioneUtentiManageACT.asp',stringParameters,true,'confermaSalva');	
		}
		setTimeout("controllaErroriPostCall()",1000);
	}
	
	function controllaErroriPostCall()
	{
		if(!fmk$checkObject('errori')){
			setTimeout("controllaErroriPostCall()",500);
			return;
		}
		responso = document.getElementById('errori').innerHTML;
		utenteID = document.getElementById('userpostid').innerHTML;
		loadazione = document.getElementById('azione').innerHTML;
	
		
		if(responso!="True"){
			setTimeout("document.getElementById('confermaSalva').innerHTML=''",1000);
			if(loadazione=="insert" || loadazione=="delete"){
				setTimeout("caricameloTutto('PanelRight','loadProgramma.asp?areaid=1')",1000);
				setTimeout("caricameloTutto('toolUtenti','gestioneUtentiManage.asp?utenteID='+utenteID)",1500);
			}else{
				setTimeout("caricameloTutto('elencoUtenti','gestioneUtentiElenco.asp')",100);
			}
		}

	}
	
	function cancellaUtente(u)
	{
		elemento = document.frmSalvataggio;
		if(u==''){
			utenteID = elemento.utenteID.value;	
		}else{
			utenteID = u;
		}
		stringParameters =  "utenteID="+encodeURI(utenteID)+"&ope=del";
		if(confirm("ATTENZIONE: stai per rimuovere un utente;\neliminandolo, anche i riferimenti nel Log verranno rimossi.\n\nvuoi continuare?")){						
			if(u==''){
				fmk$PostCall('gestioneUtentiManageACT.asp',stringParameters,true,'confermaSalva');
				setTimeout("controllaErroriPostCall()",2000);	
				fmk$clean("toolUtenti");
			}else{
				Processa('gestioneUtentiManageACT.asp?'+stringParameters);
				setTimeout("caricameloTutto('elencoUtenti','gestioneUtentiElenco.asp')",500);
				fmk$clean("toolUtenti");
			}
			
		}
		
	}
	
	
	function cancellaNews(n)
	{

		newsID = n;
		stringParameters =  "newsID="+encodeURI(newsID)+"&ope=del";
		if(confirm("Stai per rimuovere una news;\n\nvuoi continuare?")){						
			Processa('newsDel.asp?'+stringParameters);
			setTimeout("caricameloTutto('elencoNews','gestioneNewsElenco.asp');fmk$clean('toolNews')",500);
			
		}
		
	}	
	
	function cancellaFile(filename,id)
	{
		if(confirm("Stai per rimuovere un file;\neliminandolo, anche i riferimenti nel Log verranno rimossi.\n\nvuoi continuare?")){						
			Processa('gestioneFileManageDeleteACT.asp?fn='+filename+"&id="+id);
			setTimeout("bo(2)",1000);
			
		}
	}
	
	function cancellaFoto(filename,id)
	{
		if(confirm("Stai per rimuovere una foto;\n\nvuoi continuare?")){						
			Processa('gestioneGalleryManageDeleteACT.asp?fn='+filename+"&id="+id);
			setTimeout("bo(6)",1000);
			
		}
	}	
	
	function cancellaLOG()
	{
		if(confirm("Stai per eliminare completamente il LOG dei download;\n\nvuoi continuare?")){						
			Processa('gestioneVisitatoriPurge.asp');
			setTimeout("bo(4)",1000);
			
		}
	}
	
	function cancellaLOGCompleto()
	{
		if(confirm("Stai per azzerare completamente il LOG dei download;\n\nvuoi continuare?")){						
			Processa('gestioneVisitatoriPurge.asp?ope=completo');
			setTimeout("bo(4)",1000);
			
		}
	}
	
	function refreshNewsDett(n)
	{
		caricameloTutto('toolNews','gestioneNewsManage.asp?newsid='+n);
		setTimeout("caricameloTutto('elencoNews','gestioneNewsElenco.asp')",500);
	}
	
	function dispatchClick()
	{

		var anchors = document.getElementsByTagName('input');
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			var relAttribute = String(anchor.getAttribute('zone'));
			if (anchor.getAttribute('zone')  ){
				anchor.onclick = function () {
					elemento = this.getAttribute('id');
					evento = this.getAttribute('zone');
					area = this.getAttribute('area');
					switch(evento){
						case "salvautente":
						case "salvautentenuovo":
							salvaUtente();
							break;
						case "cancellautente":
							cancellaUtente();
							break;
					}
				}
			}
		}
		
	
		var anchors = document.getElementsByTagName('li');
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			var relAttribute = String(anchor.getAttribute('zone'));
			if (anchor.getAttribute('zone')  ){
				anchor.onclick = function () {
					elemento = this.getAttribute('id');
					evento = this.getAttribute('zone');
					area = this.getAttribute('area');
					switch(evento){
						case "caricaProgramma":
							caricameloTutto('PanelRight','loadProgramma.asp?areaid='+area);
							caricameloTutto('PanelComandi','loadComandi.asp?areaid='+area);
							break;
						case "caricafiletipo":
							 fmk$clean('PanelComandi');
							caricameloTutto('PanelRight','guestFileElenco.asp?tip='+elemento)
							break;							
					}
				}
			}
		}
		
		
		var anchors = document.getElementsByTagName('a');
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			var relAttribute = String(anchor.getAttribute('zone'));
			if (anchor.getAttribute('zone')  ){
				anchor.onclick = function () {
					elemento = this.getAttribute('id');
					evento = this.getAttribute('zone');
					area = this.getAttribute('area');
					valore = this.getAttribute('value');
					switch(evento){
						case "cancellautente":
							utente = this.getAttribute('utenteid');														
							cancellaUtente(utente);
							break;
						case "cancellanews":
							newsid = this.getAttribute('newsid');														
							cancellaNews(newsid);
							break;
						case "nuovoutente":
						case "editutente":
							caricameloTutto('toolUtenti','gestioneUtentiManage.asp?utenteID='+valore);
							break;
						case "nuovofile":
						case "editfile":
							caricameloTutto('toolFile','gestioneFileManage.asp?utenteID='+valore);
							break;	
						case "nuovanews":
						case "editnews":
							if(!valore)
								valore = '';
								caricameloTutto('toolNews','gestioneNewsManage.asp?newsid='+valore);
							break;							
						case "nuovafoto":
						case "editfoto":
							caricameloTutto('toolFoto','gestioneGalleryManage.asp?utenteID='+valore);
							break;							
						case "downloadfile":
							filen = this.getAttribute('filen');
							Processa("gestioneFileLogger.asp?File_ID="+valore);
							//document.location.href='/file/'+filen;
							window.open('downloader.asp?pathfile=/file/'+filen+'&nome='+filen);
							break;	
						case "cancellafile":
							filen = this.getAttribute('filen');
							fileid = this.getAttribute('fileid');
							cancellaFile(filen,fileid);
							break;
						case "cancellafoto":
							filen = this.getAttribute('filen');
							fileid = this.getAttribute('fileid');
							cancellaFoto(filen,fileid);
							break;	
						case "dellog":
							cancellaLOG();
							break;	
						case "dellogcomplete":
							cancellaLOGCompleto();
							break;																								
					}
				}
			}
		}		
	}
	