//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------

	var win;
	var cur_lyr;

//-----------------------------------------------------------------------------------

//Usata nella pagina spalmAdempimento.asp
	function chkSpalma(quanti)
	{
		var chk = false
		for (i=1;i<=quanti;i++)
			{
			if (document.getElementById("adempimenti"+ i).checked)
				{
				chk = true;
				break;
				}
			}

		if (chk)
			{document.spalmAdempimento.submit();}
		else
			{alert("Selezionare almeno un adempimento su cui spalmare i dati!");}
	}

//-----------------------------------------------------------------------------------

//Usata nella pagina spalmAdempimento.asp
	function selCampiSA()
	{
		var divCampi = document.getElementById("selezioneCampi")
		divCampi.style.display = ''
	}

//-----------------------------------------------------------------------------------

//Usata nella pagina modAdempimenti.asp per decidere se nella copia degli adempimenti 
//vanno copiate anche le relazioni con le pratiche
	function copiaAd(url)
	{
		if (confirm("Effettuo anche la copia delle associazioni con le pratiche?"))
			{window.location = url + "&copiaAdPr=1"}
		else
			{window.location = url + "&copiaAdPr=0"}
	}

//-----------------------------------------------------------------------------------

	function invioWeGo(idfms, newMod)
	{
	var url
	if (newMod == 0)
		{url = '/back/m_xmlSutMarche.asp?sotto=x&idfms='+ idfms +'&tipo=m'}
	else
		{url = '/chkXmlSut.asp?sotto=x&popup=x&idfms='+ idfms}
		//{url = '/back/xmlSutMarche.asp?sotto=x&idfms='+ idfms}
	winOpenTB(url, '800', '600', 'SUT', true)
	}

//-----------------------------------------------------------------------------------

//Usata nella pagina m_codWeGo.asp
    function salvaWeGo()
    {
        if (document.m_codWeGo.canc.checked)
            {
            if (confirm("Confermi la cancellazione?"))
                {document.m_codWeGo.submit();}
            }
        else
            {document.m_codWeGo.submit();}
    }

//-----------------------------------------------------------------------------------

//Usanata nella pagina e_utenti.asp
    function cancellaUtente(idut)
    {
      if (confirm("Confermi la cancellazione dell'utente?"))
        {window.location = 'm_utenti.asp?sotto=x&canc=x&idut='+ idut}
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina e_allegati.asp
    function cancAllegati(idal)
    {
		if (confirm("Confermi la cancellazione?"))
			{window.location="e_allegati.asp?idal="+ idal + "&sotto=x&canc=x";}
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina m_allegati.asp
    function chkAllegati()
    {
    var eti = document.m_allegati.eti.value;
	var url = document.m_allegati.url.value;
	if (eti!='' && url!='')
		{document.m_allegati.submit();}
	else
		{alert("Compilare sia il campo 'Etichetta' che il campo 'Percorso'")}
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina e_selezionaAdempimento.asp
    function exportElencoAd()
    {
    var idpr    = document.getElementById("idpr2").value;
    var idad    = document.eAdempimenti.idad.value;
    var url     = "v_prAdCr.asp?idpr="+ idpr +"&amp;idad="+ idad +"&amp;popup=x"
    window.open(url,'pradcr', "toolbr=yes, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, width=800, height=600");
    }

//-----------------------------------------------------------------------------------

//Usanata nella pagina e_skAnagraficaContratto.asp
    function instaura(idan)
    {
    var idar = document.getElementById("anCliente"+ idan).value
    var idas = document.getElementById("sedeCliente"+ idan).value
    window.location = 'e_skAnagraficaContatto.asp?inst=x&amp;idan='+ idan +'&amp;idar='+ idar +'&amp;idas='+ idas
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina e_sediCna.asp
    function cancellaSediCna(idsc)
    {
      if (confirm("Confermi la cancellazione della sede?"))
        {window.location = 'm_sediCna.asp?sotto=x&canc=x&idsc='+ idsc}
    }

//-----------------------------------------------------------------------------------

//Usata in tutte le popup e le visualizzazioni
	function indietro()
	{
    if (window.opener)
      {
      window.close();
      window.opener.focus();
      }
    else
      {window.history.go(-1)}
    }

//-----------------------------------------------------------------------------------

		var vpath = '<%= vpath %>';

		function setInUso()
		{
			var node = document.getElementById("inUso");
			if (!node) return;
			
			var div = getAncestor(node, "DIV");
			
			div.className = "hi check";
			node.disabled = true;

			var commentoNotifica = "";
			try { commentoNotifica = window.Cnasir.commentoNotifica; }
			catch (e) { alert(e.message); }
			if (!commentoNotifica) commentoNotifica = "";

			var osservatoriNotifica = "";
			try { osservatoriNotifica = window.Cnasir.osservatoriNotifica; }
			catch (e) { alert(e.message); }
			if (!osservatoriNotifica) osservatoriNotifica = "";

			var request = new XMLHttpRequest();
			var vpath = "/";
			if (window.vpath)
				path = window.vpath;
			var page = vpath + "setInUso.asp?idtipo=" + window.idTipo + "&idog=" + window.idog +
				"&txtCommento=" + escape(commentoNotifica) +
				"&txtOsservatori=" + escape(osservatoriNotifica);
								
			if (node.checked)
				page += "&idut=" + window.idut;
			else
				page += "&idut=0"
			page += "&idutente=" + window.idut;
			
//debug
//window.open(page, "_blank"); return;
// alert(page);
			
			request.open("GET", page, true);
			request.onreadystatechange = function()
			{
				if (request.readyState == 4)
				{
// alert(request.responseText);
				
					var result = 0;
					var response = null; try { eval("var response = " + request.responseText); } catch (e) {}
					try { result = parseInt(response.result, 10); } catch (e) { }
					
					setTimeout
					(
						function()
						{
							if (result == 1)
							{
								var infoUtente = document.getElementById("infoUtente");
								if (infoUtente) try
								{
									infoUtente.innerHTML = response.infoUtente;
								}
								catch (e) { }
								var dataInUso = document.getElementById("dataInUso");
								if (dataInUso) try
								{
									dataInUso.innerHTML = response.dataInUso;
								}
								catch (e) { }

								var divInfoUtente = null;
								if (infoUtente)
									divInfoUtente = getAncestor(infoUtente, "DIV");					
								if (node.checked)
									divInfoUtente.style.display = "";
								else
									divInfoUtente.style.display = "none";
							}
							else
							{
								alert("Impossibile eseguire l'operazione");
								node.checked = !node.checked;
							}
							div.className = "check";
							node.disabled = false;
						},
						250
					);
				}
			}
			request.send(null);
			return false;
		}

//-----------------------------------------------------------------------------------

  	function Area(titolo, id)
  	{
  		this.id = id;
  		this.titolo = titolo;
  	}
  
  	Area.prototype.toString = function()
  	{
  		return "[Area: " + this.titolo + ", " + this.id + "]"
  	}
  
  	var nazionale = new Area("Nazionale", "150");
  	var regionale = new Area("Regionale", "151");
  	var provinciale = new Area("Provinciale", "152");
  	var comunale = new Area("Comunale", "153");

//-----------------------------------------------------------------------------------

  	function areaChanged(sel)
  	{
  		var from = "";
  		if (window.from)
  			from = window.from;

  		var area = sel.value;

  		try
  		{
  			var aLocazione = document.getElementById("aLocazione");
  			if (area == "150")
  				aLocazione.style.visibility = "hidden";
  			else
  				aLocazione.style.visibility = "";
  		}
  		catch (e) { }
  		var locazione = document.getElementById("locazione");
  		locazione.src = "e_locazione.asp?task=deleteall&from=" + from;
  	}

//-----------------------------------------------------------------------------------

  	var aree = [];
  	aree[1] = [nazionale, regionale, provinciale, comunale];
  	aree[2] = [comunale];
  	aree[5] = [regionale, provinciale, comunale];
  	aree[6] = [regionale, provinciale, comunale];
  	aree[7] = [comunale];
  	aree[8] = [nazionale];
  	aree[9] = [nazionale];

//-----------------------------------------------------------------------------------

  	function populateAree(sel, ruolo, selectedValue)
  	{
  		if (!selectedValue)
  			selectedValue = window.gSelectedValue;
  
  		for (var i = sel.options.length - 1; i >= 0; i--)
  			sel.options[i] = null;
  
  		var selectedIndex = 0;
  		var aList = aree[ruolo];
  		if (aList)
  		{
  			for (i = 0; i < aList.length; i++)
  			{
  				area = aList[i];
  				if (area)
  				{
  					sel.options[sel.options.length] = new Option(area.titolo, area.id);
  					if (area.id == selectedValue)
  						selectedIndex = i;
  				}
  			}
  			if (selectedValue)
  				sel.value = selectedValue;
  		}
  	}

//-----------------------------------------------------------------------------------

  	var primaVolta = true;
  
  	function doPopulate(selectedValue)
  	{
  		var ruolo = document.forms[0].ruoli;
  		var area = document.forms[0].idArea;
  		populateAree(area, ruolo.value, selectedValue);
  		if (!window.primaVolta)
  			areaChanged(area);
  		else
  			primaVolta = false;
  	}

//-----------------------------------------------------------------------------------

  	function ruoloChanged(sel)
  	{
  		gSelectedValue = null;
  		doPopulate();
  	}

//-----------------------------------------------------------------------------------

// mostra e nascondi in Anagrafica Contatti/Azienda
  	function doDisplay(node)
  	{
  		if (node)
  		{
  			if (node.style.display == "none")
  				node.style.display = "";
  			else
  				node.style.display = "none";
  		}
  	}

//-----------------------------------------------------------------------------------

  	function getAncestor(node, tagName)
  	{
  		for (node = node.parentNode; node; node = node.parentNode)
  			if (node.tagName == tagName)
  				return node;
  		return null;
  	}

//-----------------------------------------------------------------------------------

  	function doToggle(elem, name)
  	{
  		try
  		{
  			var ancestor = getAncestor(elem, "TR");
  			doDisplay(ancestor);
  		}
  		catch (e) { alert(e.message + " - " + name); }
  	}

//-----------------------------------------------------------------------------------

  	function toggle(a)
  	{
  		var form = document.formContatto;
  		for (var i = 0; i < a.length; i++)
  		{
  			var name = a[i];
  			doToggle(form[name], name);
  		}
  	}

//-----------------------------------------------------------------------------------

  	function proprieta(elem, viewAll)
  	{
  		var s = "";
  		for (var i in elem)
  		{
  			if (viewAll || i != i.toUpperCase()) try
  			{
  				var property = elem[i];
  			
  				if (property != null || viewAll)
  				{
  					
  					var type = typeof(property);
  					if (type == "function")
  						property = "function";
  					else if (type == "string")
  						property = "\"" + property.substr(0, 40) + "\"";
  					
  					if (type != "function")
  						s += i + ": " + property + ", ";
  				}
  			}
  			catch (e) { }
  		}
  
  		if (s.length >= 2)
  			s = s.substr(0, s.length - 2);
  
  		return s;
  	}

//-----------------------------------------------------------------------------------

//Usata nella pagina e_adempimenti.asp (back)
  	function changeOrdine(pos, ordine, view){
  		var strUrl = window.location
  		strUrl = strUrl +'&idad='+ pos +'&ordine='+ ordine
  		window.location = strUrl
  	}

//-----------------------------------------------------------------------------------

  	function aggiungiAdempimentoSpot(queryString) {
  		alert(queryString);
  		winOpen('a_adempimenti.asp',800,650,'a_adempimenti','yes')
  	}

//-----------------------------------------------------------------------------------

  	function cancellaFM(id) {
  		if (confirm("Procedere con l\'eliminazione?")) {
  			document.myForm.task.value="delete";
  			document.myForm.idToRemove.value=id;
  			document.myForm.submit();
  		}
  	}

//-----------------------------------------------------------------------------------

//Usata nella pagina e_selezionaAdempimento.asp (front)
    function mostraAdempimenti(idTabella) {
      var tabella = document.getElementById(idTabella)
      if (tabella.style.display == ''){
        tabella.style.display = 'none'
      } else {
        tabella.style.display = ''
        //selDesel(idTabella);
      }
    }

//-----------------------------------------------------------------------------------

    function selDesel(id) {
		var objPrincipale = document.getElementById("r"+id);
		var objDiv = document.getElementById("div"+id);
		if (objPrincipale && objDiv) {
			var list = objDiv.getElementsByTagName("INPUT");
			for (i=0; i<list.length;i++) {
				list[i].checked=objPrincipale.checked;
			}
		}
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina e_uffDest.asp (back)
    function cancUffDest(URL) {
      if (confirm("Confermi la cancellazione?")) {
        window.location = URL
      }
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina m_sediCna.asp (back)
    function salvaSediCna() {
      var formSC  = document.m_sediCna
      var nome    = formSC.nome
      var via    = formSC.via
      if (nome!='') {
        if (via!='') {
          formSC.submit();
        } else {
          alert("Inserire la via!")
        }
      } else {
        alert("Inserire il nome della sede!")
      }
    }

//-----------------------------------------------------------------------------------

//Usata nella pagina m_uffDest.asp (back)
    function salvaUffDest() {
      var formUD    = document.m_uffDest
      var ided      = formUD.ided.value
      var via       = formUD.via.value
      var provincia = formUD.provincia.value
      var comune    = formUD.comune.value

      var idArea	= formUD.idArea.value;

  		if (idArea == -1) { alert("Selezionare l'area"); return; }
  
          if (ided != 0) {
            if (via != "") {
              if (provincia != -1) {
                if (comune) {
                  if (CheckDBValue('E-mail', 'email', 'mail', 0, 'm_uffDest')) {
                    formUD.submit();
                  }
                } else {
                  alert("Selezionare il comune")
                }
              } else {
                alert("selezionare la provincia")
              }
            } else {
              alert("Inserire la via")
            }
          } else {
            alert("Selezionare l'ente destinatario")
          }
        //}
    }

//-----------------------------------------------------------------------------------

    function displayDitta(checkbox)
  	{
  		var divDitta = document.getElementById("divDitta");
  		if (divDitta)
  		{
  			if (checkbox.checked)
  				divDitta.className = "";
  			else
  				divDitta.className = "hidden";
  		}
  	}

//-----------------------------------------------------------------------------------

    function generaCodice() {
  		document.myForm.task.value="generaCodice";
  		document.myForm.submit();		
  	}

//-----------------------------------------------------------------------------------

  	function getCap(response, idComune)
  	{
  		try
  		{
  			for (var i = 0; i < response.result.length; i++)
  				if (response.result[i].id == idComune)
  					return response.result[i].cap;
  		}
  		catch (e) { }
  						
  		return "";
  	}

//-----------------------------------------------------------------------------------

  	function caricaCap(idInputCap, idSelComune, idComune)
  	{
  		// alert("idInputCap = " + idInputCap + ", idSelComune = " + idSelComune + ", idComune = " + idComune);
  		var response = window["response_" + idSelComune];
  		var comune = document.getElementById(idInputCap);
  		var cap = document.getElementById(idInputCap);
  		// alert("response = " + response);
  		if (cap && comune && response) try
  		{
  			cap.value = getCap(response, idComune);
  		}
  		catch (e) { alert(e.message); }
  	}

//-----------------------------------------------------------------------------------

  	function caricaComuni(idSel, codProv, idComune) {
      	var request = new XMLHttpRequest();
      	var page = "/optionComuni.asp?codProv="+ codProv;
      	request.open("GET", page, false);
      	request.send(null);

//window.open(page); return;
  
      	var response = null;
        try { 
          eval("var response = " + request.responseText);}
        catch (e) {
          alert("Errore nella funzione 'caricaComuni'")}
  
      	window["response_" + idSel] = response;
  
        unpopulateSelect(idSel)
  
      	// adesso eseguo il populate
      	populateSelect(idSel, response, false, '');
        //document.getElementById(idSel).value = idComune
      	selectOption(document.getElementById(idSel), idComune);
      	if (document.getElementById(idSel).onchange)
      		document.getElementById(idSel).onchange();
      }

//-----------------------------------------------------------------------------------

  	function caricaProvince(idSel, idRegione) {
      	var request = new XMLHttpRequest();
      	var page = "/optionProvince.asp?idRegione=" + idRegione;
//window.open(page); return;
      	request.open("GET", page, false);
      	request.send(null);

  
      	var response = null;
        try { 
          eval("var response = " + request.responseText);}
        catch (e) {
          alert("Errore nella funzione 'caricaProvince'")}
    
        unpopulateSelect(idSel)
  
      	// adesso eseguo il populate
      	populateSelect(idSel, response, " ");
        //document.getElementById(idSel).value = idComune
      	//selectOption(document.getElementById(idSel), idComune);
      	if (document.getElementById(idSel).onchange)
      		document.getElementById(idSel).onchange();
      }

//-----------------------------------------------------------------------------------
  	function selAttivita(idCa,idAt, codIstat){
      var elem = window.opener.document.getElementById('classeAttivita')
      elem.value = idCa
      window.opener.caricaAttivita('attivita', idCa, idAt)
      window.opener.document.getElementById('codISTAT').value = codIstat
      winClose('',false)
    }

//-----------------------------------------------------------------------------------

  	function selAttivita2(campo, valCampo, campo2, valCampo2){
      var elem = window.opener.document.getElementById(campo)
      elem.value = valCampo
      var elem2 = window.opener.document.getElementById(campo2)
      elem2.value = valCampo2
      winClose('',false)
    }

//-----------------------------------------------------------------------------------

    function swap(id, idli) {
      var arrLi = ['contatto','ditta','sedi','mrk','bdg']
      for (i=0;i<=arrLi.length-1;i++) {
        if (arrLi[i] == idli){
          document.getElementById(arrLi[i]).className = "current";
          } else {
          document.getElementById(arrLi[i]).className = "";
          }
        }
      showLayer(id);
      cur_lyr = id;
      }

//-----------------------------------------------------------------------------------

  	function getCurLyr()
  	{
  		if (window.cur_lyr)
  			return window.cur_lyr;
  		else
  			return "ditta";
  	}

//-----------------------------------------------------------------------------------

    function showLayer(id) {
        if (document.getElementById(id).className == "hidden") {
        document.getElementById(id).className = "view";
        if (cur_lyr && cur_lyr!=id) {
        document.getElementById(cur_lyr).className = "hidden";}
        } else {
          document.getElementById(id).className = "hidden";
        }
        
      }

//-----------------------------------------------------------------------------------

	function cercaIstat(codIstat, pChiave)
	{
		var width = "800";
		if (window.CnaSir && CnaSir.popupWidth)
			width = CnaSir.popupWidth;
	
		if (codIstat || pChiave)
        {
			var win = winOpen('r_attivita.asp?codIstat=' + codIstat + '&pChiave=' + escape(pChiave), width, '600', 'ricAttivita', 'yes');
        }
		else
		{
			alert("Inserire codice istat o una parola chiave");
		}
	}

//-----------------------------------------------------------------------------------

    function cercaIstat2(codIstat, pChiave){
        var valCodIstat = document.getElementById(codIstat).value
        var valPChiave = document.getElementById(pChiave).value

        if (valCodIstat || valPChiave){
          win = winOpen('r_attivita2.asp?valPChiave='+ valPChiave +'&valCodIstat='+ valCodIstat +'&codIstat='+ codIstat +'&pChiave='+ pChiave,'800','600','ricAttivita','yes');
        } else {
          alert("Inserire codice istat o una parola chiave")
        }
      }

//-----------------------------------------------------------------------------------

	function caricaAttivita(idSel, idca, idat, sing)
	{
		if (sing)
			{sing = 'x'}
		else
			{sing = ''}
		var request = new XMLHttpRequest();
		var page = "/optionAttivita.asp?idca="+ idca +"&idat="+ idat +"&sing="+ sing
//debugger
/*
		request.open("GET", page, true);
		request.onreadystatechange = function()
		{
			if (request.readyState == 4)
				{
					var response = null;
				try {
					eval("var response = " + request.responseText); } 
				catch (e) {}
				}
		}
		request.send(null);
*/

		request.open("GET", page, false);
		request.send(null);

		if (window.xdbg2)
		{
			// window.open(page);
		}
//		window.open(page);
//		return;

		var response = null;
		try {
			eval("var response = " + request.responseText);}
		catch (e) {
			alert("Errore nella funzione 'caricaAttivita'")}

		unpopulateSelect(idSel)
		// adesso eseguo il populate
		populateSelect(idSel, response, false, '');

//		document.getElementById(idSel).value = idat
		if (window.xdbg2)
		{
			// alert("idat = " + idat);
		}	
		

		selectOption(document.getElementById(idSel), idat)

	}

//-----------------------------------------------------------------------------------

	//2007-06-08: non funziona. Ad esempio con valueToSelect = "343" può
	//essere selezionata un'opzione con valore "34"
	/*
	function selectOption(objSelect, valueToSelect)
	{
		valueToSelect = ','+ valueToSelect +','
		for (i=0;i<objSelect.options.length;i++)
			{
			if (valueToSelect.indexOf(objSelect.options[i].value) != -1 )
				{objSelect.options[i].selected = true;}
			}
	}
	*/

	function selectOption(objSelect, valueToSelect)
	{
		for (i=0;i<objSelect.options.length;i++) {
			if (objSelect.options[i].value == valueToSelect) {
				objSelect.options.selectedIndex = i
				break;
			}
		}
	}
	

//-----------------------------------------------------------------------------------

  	function populateSelect(id, data, defaultOption)
    {
    	var selIdx = data.selectedIndex;
      data = data.result

      if (defaultOption && selIdx)
        selIdx++;
    	var sel = document.getElementById(id);

    	if (sel && sel.tagName == "SELECT")
    	{
    		if (defaultOption && sel.options.length == 0)
    			sel.options[0] = new Option(defaultOption, "0");

    		if (selIdx)
    			selIdx += sel.options.length;

    		for (var i = 0; i < data.length; i++)
    			sel.options[sel.options.length] = new Option(data[i].descrizione, data[i].id);
//alert(typeof(selIdx))
//alert(selIdx)
//alert(sel.options.length)
    		if (selIdx)
    			sel.value = selIdx;
    		  //sel.options.selectedIndex = selIdx;
    		// alert("populateSelect, selIdx = " + selIdx);
    	}
    }

//-----------------------------------------------------------------------------------

  	function unpopulateSelect(idSel)
    {
    	var sel = document.getElementById(idSel);
    	if (sel && sel.tagName == "SELECT")
    	{
    		sel.options.length = 0;
    	}
    }

//-----------------------------------------------------------------------------------
/*
  	function localizzaCriterio(id) {	
    		document.myForm.id.value=id;
    		document.myForm.task.value="localizza";
    		document.myForm.submit();
  	}
*/
//-----------------------------------------------------------------------------------
/*
  	function viewInterpretazione(id){
  		document.location.href = "newInterpretazione.asp?task=view&id=" + id;
  	}
*/
//-----------------------------------------------------------------------------------
/*
	  function localizzaInterpretazione(id) {
  		document.interpretazione.idInterpretazione.value=id;
  		document.interpretazione.task.value="localizza";
  		document.interpretazione.submit();
  	}
*/
//-----------------------------------------------------------------------------------

    function cambiaArea(reload) {
  		if (reload!="") {
  			document.adempimento.task.value="cancLocalizzazione";
  			document.adempimento.submit();
  		}
  	}

//-----------------------------------------------------------------------------------

    function chkAdempimenti()
	{
		var chkUtente = document.eAdempimenti.chkUtente.value;
		var dataApertura = document.eAdempimenti.dataApertura.value;
		
		if (!chkUtente) { alert("Selezionare il cliente"); return false; }
		if (!dataApertura) { alert("Selezionare la data l'apertura"); return false; }

		document.eAdempimenti.method = "GET";
		document.eAdempimenti.submit();
    }

//-----------------------------------------------------------------------------------

    function selectCliente(){
      document.sceltaAc.submit();
    }

//-----------------------------------------------------------------------------------

    function visAdempimenti(idmo){
      var URL = "e_adMo.asp?idmo="+ idmo
      winOpen(URL,'430','500','visAdempimenti','no')
    }

//-----------------------------------------------------------------------------------

    function visAdempimentiInterp(idin){
      var URL = "e_adIn.asp?idin="+ idin
      winOpen(URL,'430','500','visAdempimenti','no')
    }

//-----------------------------------------------------------------------------------

    function visAdempimentiNormative(idno){
      var URL = "e_adNo.asp?idno="+ idno
      winOpen(URL,'430','500','visAdempimenti','no')
    }

//-----------------------------------------------------------------------------------

    function visAdempimentiCriteri(idcr){
      var URL = "e_adCr.asp?idcr="+ idcr
      winOpen(URL,'430','500','visAdempimenti','no')
    }

//-----------------------------------------------------------------------------------

    function visPratiche(idad){
      var URL = "e_prAd.asp?idad="+ idad
      winOpen(URL,'430','500','visPratiche','no')
    }

//-----------------------------------------------------------------------------------

    function modPratiche(idad){
      var URL = "m_prAd.asp?idad="+ idad
      winOpen(URL,'700','500','visPratiche','yes')
    }

//-----------------------------------------------------------------------------------

    function ridimensiona(nome) {
      var elemento = document.getElementById(nome)
      if (elemento) {
        if (elemento.style.height == "550px"){
          elemento.style.height = "150px";
  		  } else {
          elemento.style.height = "550px";
  			}
  		}
    }

    function redimPrivacy() {
      var elemento = document.getElementById('Privacy')
      if (elemento) {
        if (elemento.style.height == "180px"){
          elemento.style.height = 60
  		  } else {
          elemento.style.height = 180
  			}
  		}
    }

//-----------------------------------------------------------------------------------

  	function storicoAdempimenti(id) {
  		if (confirm("Creare uno storico dell\'adempimento scelto?")) {
  			//validaCampi('update', '1');
  			document.adempimento.task.value="update";
  			document.adempimento.storico.value="1";
  			document.adempimento.submit();
  			//document.location.href="adempimenti.asp?task=update&idad="+id+"&storico=1"
  		} else {
  			validaCampi('update', '0');
  			//document.location.href="adempimenti.asp?task=modifyParameter&idad=" + id
  		}
  	}

//-----------------------------------------------------------------------------------

  	function ricercaCliente() {
      //window.open("r_skAnagraficaContatto.asp", "", "menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=700,height=600");
      document.getElementById("anagraficaClienti").src = "r_skAnagraficaContatto.asp?rr=x"
  	}

//-----------------------------------------------------------------------------------

  	function rimuoviAdempimento(id) {
  		document.myForm.idToRemove.value = id;
  		document.myForm.task.value = "cancella";
  		document.myForm.submit();
  	}

//-----------------------------------------------------------------------------------	

  	function sostituisciAdempimento() {
  		document.myForm.task.value="update";
  		document.myForm.submit();
  	}

//-----------------------------------------------------------------------------------	

  	function associaPraticheProfili() {
  		document.myForm.task.value="update";
  		document.myForm.submit();
  	}

//-----------------------------------------------------------------------------------

	function controllaAdRaggruppamenti() {
		var i=0;
		var ok=0;
		for (i=0; i<document.myForm.raggruppamento.length; i++) {
			if (document.myForm.raggruppamento[i].checked==true) ok++; 
		}
		return ok;
	}

//-----------------------------------------------------------------------------------

	function controllaAdempimentiSingoli() {
		var ok=0;
		if (!document.myForm.idadempimenti.length) {
			// c'e' solo un adempimento selezionato
			if (document.myForm.idadempimenti.checked) ok++;
		} else {
			// c'e' n'e' piu' di uno
			for (i=0;i<document.myForm.idadempimenti.length;i++) {
				if (document.myForm.idadempimenti[i].checked) ok++;
			}
		}
		return ok;
	}

//-----------------------------------------------------------------------------------

// SIMULA: controllare se almeno un adempimento è stato selezionato
//  Usata nella pagina 'e_selezionaAdempimento.asp'

function simula()
{
	document.myForm.altriAdempimenti.value = "";

	var adempimenti = document.myForm.idadempimenti;
	if (!adempimenti)
		adempimenti = [];
	if (!adempimenti.length)
		adempimenti = [adempimenti];

	var trovato = false;
	for (var i = 0; i < adempimenti.length; i++)
	{
		if (adempimenti[i].checked)
		{
			trovato = true;
			break;
		}
	}
	
	if (!trovato)
	{
		alert("Selezionare almeno un adempimento");
		return false;
	}
	
	document.myForm.task.value = "validate";
	try
	{
		document.myForm.submit();
	}
	catch (e)
	{
		document.myForm.method = "post";
		document.myForm.submit();
	}
}


//-----------------------------------------------------------------------------------

  	function caricaComuniAlbo() {	
  		var prov = document.getElementById("prov");			
  		document.myForm.idProvincia.value=prov.value;
  		document.myForm.task.value="caricaComuni";
  		document.myForm.submit();		
  	}

//-----------------------------------------------------------------------------------

  	function salvaAnagraficaContatto() {
  		var erroriTrovati=0;
  		if (document.myForm.ditta.value=="") erroriTrovati++;
  		if (document.myForm.codFiscale.value=="") erroriTrovati++;
  		if (document.myForm.naturaGiuridica.value=="-1") erroriTrovati++;
  		if (document.myForm.via.value=="") erroriTrovati++;
  		if (document.myForm.provinciaAlboArtigiani.value=="-1") erroriTrovati++;		
  		if (document.myForm.cap.value=="") erroriTrovati++;
  		if (erroriTrovati>0) {
  			alert("Compilare tutti i campi obbligatori contrassegnati da un *");
  		} else {
  			document.myForm.task.value="save";
  			document.myForm.submit();
  		}		
  	}

//-----------------------------------------------------------------------------------

  	function aggiornaAnagraficaContatto(id) {
  		var formName = "form_" + getCurLyr();
  		var myForm = document[formName];

  		if (formName == "form_ditta")
  		{
  			var erroriTrovati=0;
  			if (myForm.ditta.value=="") erroriTrovati++;
  			if (myForm.codFiscale.value=="") erroriTrovati++;
  			if (myForm.naturaGiuridica.value=="-1") erroriTrovati++;
  			if (document.myForm.via.value=="") erroriTrovati++;
  			if (document.myForm.provinciaAlboArtigiani.value=="-1") erroriTrovati++;		
  			if (document.myForm.cap.value=="") erroriTrovati++;
  			if (erroriTrovati>0) {
  				alert("Compilare tutti i campi obbligatori contrassegnati da un *");
  			} else {
  				myForm.task.value="update";
  				myForm.idToUpdate.value=id;
  				myForm.submit();
  			}		
  		}
  	}

//-----------------------------------------------------------------------------------

  	function confermaSelezioneAdempimenti() {
  		if (!document.myForm.adempimento.length) {
  			if (document.myForm.adempimento.checked==true) {
  				document.myForm.task.value="conferma";
  				document.myForm.submit();
  			} else {
  				alert("Selezionare almeno un raggruppamento");
  			}
  		} else {
  			var i=0;
  			var ok=0;
  			for (i=0; i<document.myForm.adempimento.length; i++) {
  				if (document.myForm.adempimento[i].checked==true) ok++; 
  			}
  			if (ok==0) {
  				alert("Selezionare almeno un raggruppamento");
  			} else {
  				document.myForm.task.value="conferma";
  				document.myForm.submit();
  			}
  		}
  	}

//-----------------------------------------------------------------------------------
/*
  	function openPratica(task, action, id, sql) {
  		document.myForm.task.value=task;
  		document.myForm.action.value=action;
  		document.myForm.idpr.value=id;
  		document.myForm.sql.value=sql;
  		document.myForm.submit();
  	}
*/
//-----------------------------------------------------------------------------------

	function cercaCriterio() {
		document.myForm.task.value="cerca";
		document.myForm.submit();
	}

//-----------------------------------------------------------------------------------

	function cercaCliente() {
		document.myForm.task.value="cerca";
		document.myForm.submit();
	}

//-----------------------------------------------------------------------------------

	function cercaIstruzione() {
		document.myForm.task.value="cerca";
		document.myForm.submit();
	}

//-----------------------------------------------------------------------------------	
	
	function eliminaCriterio(id) {
		if (confirm("Procedere con l\'eliminazione?")) {
			document.myForm.task.value="cancella";
			document.myForm.id.value=id;
			document.myForm.submit();
		}		
	}

//-----------------------------------------------------------------------------------

	function eliminaContatto(idan)
	{
		if (confirm("Procedere con l'eliminazione?"))
			window.location.href = "e_skAnagraficaContatto.asp?canc=x&idan=" + idan
	}

//-----------------------------------------------------------------------------------	
	
	function eliminaIstruzione(id) {
		if (confirm("Procedere con l\'eliminazione?")) {
			document.myForm.task.value="cancella";
			document.myForm.id.value=id;
			document.myForm.submit();
		}		
	}

//-----------------------------------------------------------------------------------
/*
	function aggiornaCriterio(id) {
		document.myForm.id.value=id;
		document.myForm.task.value="update";
		document.myForm.submit();
	}
*/
//-----------------------------------------------------------------------------------
	
	function aggiornaIstruzione(id) {
		document.myForm.id.value=id;
		document.myForm.task.value="update";
		document.myForm.submit();		
	}
	
//-----------------------------------------------------------------------------------

	function salvaCriterio() {
		if (document.myForm.titolo.value=="")
		{
			alert("Inserire il titolo");
		}
		else
		{
			if
			(
				(window.Cnasir.task == "" && window.idpadre != "0") ||
				(window.Cnasir.task == "" && window.idog == "0")
			)
			{
				notificaOperazione("submitForm", "criteri");
			}
			else
			{
				document.myForm.submit();
			}
		}
	}

//-----------------------------------------------------------------------------------

	function aggiungiIstruzione() {
		if (document.myForm.titolo.value=="") {
			alert("Inserire il titolo");
		} else {
			document.myForm.task.value="insert";
			document.myForm.submit();
		}
	}

//-----------------------------------------------------------------------------------

	function associaAdempimento(idad, titolo) {
      document.formAdemp.idad.value   = idad;
      document.formAdemp.titolo.value = titolo;
      document.formAdemp.submit();
    }

//-----------------------------------------------------------------------------------

	function associaInterpretazione(idIn) {
    var winPadre = window.opener
    if (winPadre){
      winPadre.document.getElementById("interpretazioneFile").src = "e_interpretazione.asp?id="+ idIn
    }
  }

//-----------------------------------------------------------------------------------

	function associaCriterio(idCr) {
    var winPadre = window.opener
    if (winPadre){
      winPadre.document.getElementById("obbligatorietaFile").src = "l_criteri.asp?id="+ idCr
    }
  }

//-----------------------------------------------------------------------------------

  function associaModelli(idMo) {
    var winPadre = window.opener
    if (winPadre){
      winPadre.document.getElementById("modelli").src = "l_modelli.asp?id="+ idMo
    }
  }

//-----------------------------------------------------------------------------------

	function associaIstruzione(idIs) {
    var winPadre = window.opener
    if (winPadre){
      winPadre.document.getElementById("istruzioneOrganizzativa").src = "l_istruzioneOrganizzativa.asp?id="+ idIs
      }
    }

//-----------------------------------------------------------------------------------

	function associaNormativa(idNo) {
    var winPadre = window.opener
    if (winPadre){
      winPadre.document.getElementById("normativa").src = "l_normative.asp?id="+ idNo
    }
  }

//-----------------------------------------------------------------------------------

	function chkPratiche()
    {
    var chk = true
    var objSelect = e_adempimenti.document.getElementsByTagName("SELECT")

    for (i in objSelect)
		{
		if (objSelect[i].value == 0)
			{
			chk = false
			break;
			}
		}

	if (chk)
	{
		if
		(
			window.Cnasir.task == "LOCALIZZA" ||
			(window.Cnasir.task == "" && window.idog == "0")
		)
		{
			notificaOperazione("submitForm");
		}
		else
		{
			document.m_pratiche.submit();
			// alert(document.m_pratiche.method + " " + document.m_pratiche.action);
		}
	}
	else
	{
		alert("Impostare l'ordine di tutti gli adempimenti ad un valore diverso da zero!")
	}

    /*
		if (document.m_pratiche.canc.checked)
        {
	        if (confirm("Confermi la cancellazione?"))
				{document.m_pratiche.submit();}
        }
		else
        {
			{document.m_pratiche.submit();}
        }*/

    }

//-----------------------------------------------------------------------------------

		function CheckDBValue(textc, campo, rexp, obbligo, nome_form)
		{
			all	 = /((^(((\s)|(\S)){1,}))$){1,1}/g
			nome = /((^((([0-9]|[a-z]|[A-Z]|[àèéìòù])+(\'){0,1}(\s){0,1}([0-9]|[a-z]|[A-Z]|[àèéìòù]|[-_,;.])*){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
			piva = /((^(([0-9]){11,11}|(([a-z]|[A-Z]|[0-9]){16,16})))$){1,1}/g
			num=/((^(([0-9]){1,}))$){1,1}/g
			pwd=/((^(([a-z]|[A-Z]|[0-9]){5,10}))$){1,1}/g
			dec=/((^(([0-9])+(([,]){1,1}([0-9]){1,}){0,1}))$){1,1}/g; // attenzione, verificare se il sistema operativo supporta , o .

			var msgall	= textc +" è richiesto"
			var msgnome = textc +" non contiene un testo valido"
			var msgmail = textc +" non contiene un indirizzo e-mail valido"
			var msgpiva = textc +" non è in un formato valido"
			var msgnum	= textc +" deve essere completamente numerico"
			var msgpwd	= textc +" ammette solo numeri e lettere, minimo 5 caratteri e massimo 10"
			msgdec=campo+" non contiene un valore numerico decimale"

		    var ok_r = null
			var ok_o = false
			var ok_r = document[nome_form][campo].value.match(window[rexp])

			if (obbligo!=1)
				{
				if (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 chkUtenti() {
			var nome		= document.m_utenti.nome.value
			var cognome		= document.m_utenti.cognome.value
			var email		= document.m_utenti.email.value
//			var password	= document.m_utenti.password.value
//			var cPassword	= document.m_utenti.cPassword.value

			if (nome!=''){
				if (cognome!=''){
					if (email!=''){
/*
						if (password!='') {
							if (cPassword!='') {
								if (cPassword!=password){
									alert("Le due password non coincidono.");
								} else {
*/
									document.m_utenti.submit();
/*
								}
							} else {
								alert("Obbligatorio inserire la conferma della password!")
							}
						} else {
							alert("Obbligatorio inserire la password!")
						}
*/
					}else {
					}
				} else {
					alert("Obbligatorio inserire il cognome!")
				}
			} else {
				alert("Obbligatorio inserire il nome!")
			}
		}

//-----------------------------------------------------------------------------------

		function chkModelli()
		{
			var titolo = document.m_modelli.titolo.value
//			var testo = document.m_modelli.testo.value
			var canc = null;
			// document.m_modelli.canc.checked

			if (canc)
				{
				if (confirm("Confermi la cancellazione?"))
					{document.m_modelli.submit();}
				}
			else
				{
				if (titolo!='')
//					{
//					if (testo!='')
						{
							if
							(
								window.Cnasir.task == "LOCALIZZA" ||
								(window.Cnasir.task == "" && window.idog == "0")
							)
							{
								notificaOperazione("submitForm", "modelli");
							}
							else
							{
								document.m_modelli.submit();
							}
						}
//					else
//						{alert("Obbligatorio compilare il testo!")}
//					}
				else
					{alert("Obbligatorio compilare il tiolo!")}
				}
		}

//-----------------------------------------------------------------------------------

	function chkAccedi()
	{
		var username = document.login.username.value
		var password = document.login.password.value
		if (username!='' && password!=''){
			document.login.submit();
		} else {
			alert("Inserire sia username che password!")
		}
	}

//-----------------------------------------------------------------------------------

		function confermaCanc(URL) {
			if (confirm("Confermi la cancellazione?")) {
				window.location = URL;
			}
		}

//-----------------------------------------------------------------------------------

		function chkNormative()
		{
			var titolo = document.m_normative.titolo.value
			if (titolo!="")
			{
				if (window.Cnasir.task == "" && window.idog == "0")
				{
					notificaOperazione("submitForm", "normative");
				}
				else
				{
					document.m_normative.submit();
				}
			}
			else
			{
				alert("Inserire il titolo!");
			}
		}

//-----------------------------------------------------------------------------------

		function chkLink()
		{
			var eti = document.m_link.eti.value;
			var url = document.m_link.url.value;
			if (eti!='' && url!='')
				{document.m_link.submit();}
			else
				{alert("Compilare sia il campo 'Etichetta' che il campo 'URL'")}
		}

//-----------------------------------------------------------------------------------

		function winOpen(url,larg,alte,nome_win,resize)
		{
			return window.open(url,nome_win, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=" + resize + ", width=" + larg + ", height="+ alte);
		}

//-----------------------------------------------------------------------------------

		function winOpenTB(url,larg,alte,nome_win,resize)
		{
			return window.open(url,nome_win, "toolbar=yes, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=" + resize + ", width=" + larg + ", height="+ alte);
		}

//-----------------------------------------------------------------------------------
		
		function winOpenLocazioni(url, larg, alte, nome_win, resize, idName) {
			if (idName!='')	{
					var objArea = document.getElementById(idName);
					if (objArea.value=="-1") {
						alert("Prima scegliere l\'area");
					} else {
						url+="&idArea="+objArea.value;					
						win = window.open(url,nome_win, "toolbar=yes, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=" + resize + ", width=" + larg + ", height="+ alte);
						win.focus();
					}
			} else {
				win = window.open(url,nome_win, "toolbar=yes, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=" + resize + ", width=" + larg + ", height="+ alte);
				win.focus();
			}
		}

//-----------------------------------------------------------------------------------

		function selezionaTutti() {
			for (i=0; i<document.frmLocazione.locazione.length; i++)
			{
				document.frmLocazione.locazione[i].checked = 
					!document.frmLocazione.locazione[i].checked;
				document.frmLocazione.locazione[i].onclick();
			}
		}

//-----------------------------------------------------------------------------------

	function spostaLocalizzazione(idArea, livSuccessivo, task, codiceRegione, codiceProvincia) {
		// controllo quante locazioni sono state flaggate		
		var localitaFlaggate = "";
		
		if (document.frmLocazione.locazione) {
			for (i=0; i<document.frmLocazione.locazione.length; i++) {
				if (document.frmLocazione.locazione[i].checked==true)
					localitaFlaggate+=document.frmLocazione.locazione[i].value+",";
			}
		}		
		// alert("Localita\' flaggate: " + localitaFlaggate);
		document.frmLocazione.idArea.value=idArea;
		document.frmLocazione.liv.value=livSuccessivo;		
		document.frmLocazione.task.value=task;
		document.frmLocazione.codiceRegione.value=codiceRegione;
		document.frmLocazione.codiceProvincia.value=codiceProvincia;
		document.frmLocazione.locFlaggate.value+=localitaFlaggate;		
		document.frmLocazione.submit();
	}
	
//-----------------------------------------------------------------------------------

	function salvaHTML(nSes) {
		document.editorForm.task.value="salva";
		document.editorForm.nSessione.value=nSes;
		//alert(document.editorForm.nSessione.value);
		document.editorForm.submit();
		//winClose('', false);
	}

//-----------------------------------------------------------------------------------
	
	function refreshHTML(nomeSessione) {
		 var nomeIFrame = document.editorForm.nSessione.value;		 
		 var objIFrame = window.opener.document.getElementById(nomeIFrame);		 
		 objIFrame.src=objIFrame.src;
	}
	
//-----------------------------------------------------------------------------------

	function ripristinaAdempimento(id, titolo, area) {
		if (confirm("Procedere con il ripristino?")) {
			document.myForm.task.value="ripristina";
			document.myForm.titoloAdempimento.value=titolo;
			document.myForm.areaAdempimento.value=area;
			document.myForm.id.value=id;
			document.myForm.submit();
		}
	}

//-----------------------------------------------------------------------------------

	function ripristinaPratica(idpr)
	{
		if (confirm("Procedere con il ripristino?"))
		{
			window.location.href = "e_pratiche.asp?task=ripristina&idpr=" + idpr + "&tst=" + new Date().getTime();
		}
	}

//-----------------------------------------------------------------------------------

	function sbiancaCampo(campo) {
		document.getElementById(campo).value="";
	}
	
//-----------------------------------------------------------------------------------

	function salvaProfilo(task) {
		/*if (task=="salva") {*/
			if (document.myForm.nome.value=="") {
				alert("Campo nome obbligatorio");
			} else {
				if (document.myForm.ruoli.value=="-1") {
					alert("Scegliere un ruolo");
				} else {
					document.myForm.task.value=task;
					document.myForm.submit();
				}
			}
		/*
		} else {
			document.myForm.task.value=task;
			document.myForm.submit();
		}
		*/
	}

//-----------------------------------------------------------------------------------
	
	function salvaLocalizzazione() {
		document.frmLocazione.task.value="salva";
		var localitaFlaggate = "";
		
		if (!document.frmLocazione.locazione.length) {
			if (document.frmLocazione.locazione.checked==true)
				localitaFlaggate=document.frmLocazione.locazione.value;
		} else {
			for (i=0; i<document.frmLocazione.locazione.length; i++) {
				if (document.frmLocazione.locazione[i].checked==true) {
					localitaFlaggate+=document.frmLocazione.locazione[i].value+",";
				}
			}
		}
		document.frmLocazione.locFlaggate.value+=localitaFlaggate;
		if (document.frmLocazione.locFlaggate.value=="") {
			alert("Inserire almeno una scelta!");
		} else {
			document.frmLocazione.submit();
		}
	}

//-----------------------------------------------------------------------------------

	function winClose(nomeWin, ricarica)
	{
		if (nomeWin != '')
			{}
		else
			{
			if (window.opener)
				{
				if (ricarica)
					{window.opener.location = window.opener.location}
				window.opener.focus();
				}
			window.close();
			}
	}

//-----------------------------------------------------------------------------------

	function cancellaInterpretazioneFile(id) {
		if (confirm("Procedere con la cancellazione?")) {
			document.location.href="e_interpretazione.asp?id=" + id
		}
	}
	
//-----------------------------------------------------------------------------------

	function cancellaNormativa(id) {
		if (confirm("Procedere con la cancellazione?")) {
			document.location.href="l_normative.asp?task=delete&id=" + id
		}
	}
	
//-----------------------------------------------------------------------------------

	function cancellaAdempimento(id, titolo, area) {
		win = window.open('d_adempimenti.asp?id='+id+'&titolo='+escape(titolo+'')+'&area='+escape(area+''),'','menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=700,height=500');
	}

//-----------------------------------------------------------------------------------

	function winOpenOperazione(operazione, from)
	{
		var page = "popup_notifica.asp?operazione=" + operazione
		if (from)
			page += "&from=" + from;

		window.open
		(
			page,
			'notifica_operazione',
			'menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=700,height=500'
		);
	}


	function notificaOperazione(operazione, from)
	{
		var inUso = document.getElementById("inUso");
		if (!inUso) return;
		if (inUso.tagName != "INPUT") return;
		
		if (!inUso.checked)
			winOpenOperazione(operazione, from);
		else
		{
			//alert(window[operazione]); es.: setInUso, submitForm, ecc..
			window[operazione]();
		}
	}

//-----------------------------------------------------------------------------------
	function deletePratica(id, gotoPage)
	{
		if (true || confirm("Procedere con l'eliminazione?"))
		{
			var page = "d_pratiche.asp?id=" + id + "&tst=" + new Date().valueOf();
				
			winOpen(page, "600", "300", "yes").focus();
		}
	}

//-----------------------------------------------------------------------------------

	function cancellaPratica(id, titolo, area) {
		win = window.open('d_pratiche.asp?id='+id+'&titolo='+escape(titolo+'')+'&area='+escape(area+''),'','menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=700,height=500');
	}

//-----------------------------------------------------------------------------------

	function cancellaTAG(id) {
		if (confirm("Procedere con l\'eliminazione del TAG?")) {
			document.tag.task.value="cancella";
			document.tag.id.value=id;
			document.tag.submit();
		}
	}

//-----------------------------------------------------------------------------------

	function cancellaProfilo(id) {
			var msg = "ATTENZIONE! L\'eleminiazione del profilo comportera\' la disassociazione\n in automatico dello stesso in tutte le utenze.\nContinuare?";
			if (confirm(msg)) {
				document.myForm.id.value=id;
				document.myForm.task.value="cancella";
				document.myForm.submit();
			}
		}
		
//-----------------------------------------------------------------------------------

		function cancellaSelezioneProfilo(id) {
			document.myForm.task.value="cancella";
			document.myForm.id.value=id;
			document.myForm.submit();
		}
		
//-----------------------------------------------------------------------------------

		function cancellaSelezioneCriterio(id) {
			if (confirm("Procedere con la cancellazione?")) {
				window.location="l_criteri.asp?id=" + id
			}
		}

//-----------------------------------------------------------------------------------

		function cancellaSelezioneIstruzione(id)
		{
			if (confirm("Procedere con la cancellazione?"))
				{window.location="l_istruzioneOrganizzativa.asp?id=" + id}
		}

//-----------------------------------------------------------------------------------

		function deleteAdempimento(id, gotoPage)
		{
			if (true || confirm("Procedere con l'eliminazione?"))
				{
				var page = "d_adempimenti.asp?id=" + id + "&tst=" + new Date().valueOf()					
				winOpen(page, "600", "300", "yes").focus();
				}
		}

//-----------------------------------------------------------------------------------

		function annullaAdempimento(id, dataE)
		{
			if (document.myForm.date.value=="")
				{alert("Inserire la data!");}
			else
				{
				if (document.myForm.commento.value=="")
					{alert("Inserire il commento");}
				else
					{
					var d1 = new Date();
					var gg = dataE.substring(0, dataE.indexOf("/"));
					var mm = dataE.substring(dataE.indexOf("/")+1, dataE.lastIndexOf("/"));
					var aa = dataE.substring(dataE.lastIndexOf("/")+1, dataE.length);
					var d2 = new Date(aa, mm-1, gg);

					if (d2<d1)
						{alert("Inserire una data maggiore o uguale a quella odierna.");}
					else
						{
						if (confirm("Procedere con l\'eliminazione?"))
							{
							document.myForm.task.value="cancella";
							//document.myForm.id.value=id;
							document.myForm.submit();
							}
						}
					}
				}
		}

//-----------------------------------------------------------------------------------

		function calcCharLeft(f)
		{
			maxLength = 500;
			if (f.message.value.length>maxLength)
				{
				f.message.value = f.message.value.substring(0,maxLength);
				charleft = 0;
				}
			else
				{charleft = maxLength - f.message.value.length;}
			f.contatore.value = charleft;
		}

//-----------------------------------------------------------------------------------

		function textKey(f)
		{
			supportsKeys = true;
			calcCharLeft(f);
		}

//-----------------------------------------------------------------------------------

//  Usata nel file 'l_clientiSelezionati.asp'
		function cancellaCliente(id)
		{
			if (confirm("Procedere con la cancellazione?"))
				{
				document.myForm.id.value=id;
				document.myForm.task.value="delete";
				document.myForm.submit();
				}
		}

//-----------------------------------------------------------------------------------

		function cancellaLocazione(id, senzaConferma)
		{
			if (senzaConferma || confirm("Procedere con la cancellazione?"))
				{
				document.myForm.id.value=id;
				document.myForm.task.value="delete";
				document.myForm.submit();
				//document.location.href="e_locazione.asp?task=delete&id=" + id
				}
		}

//-----------------------------------------------------------------------------------

		function aggiungiLocazione(id)
		{
			document.myForm.id.value = id;
			document.myForm.task.value = "add";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function aggiornaLocazione(sel, id)
		{
			if (sel.checked)
				window.opener.locazione.aggiungiLocazione(id);
			else
				window.opener.locazione.cancellaLocazione(id, true);
		}

//-----------------------------------------------------------------------------------

		function openComune()
		{
			if (win) window.Close;
			win = window.open('comuni.asp', 'Comuni', 'height=500,width=500,status=yes,toolbar=no,scrollbars=yes');
		}

//-----------------------------------------------------------------------------------

		function openProfilo(task, id)
		{
			if (task=="")
				{
				//win = window.open('m_profili.asp', 'Profilo', 'height=600,width=800,status=yes,toolbar=no,scrollbars=yes');
				document.location.href="m_profili.asp?tst="+new Date().valueOf();
				}
			else
				{
				//win = window.open('m_profili.asp?task='+task+'&id='+id, 'Profilo', 'height=600,width=800,status=yes,toolbar=no,scrollbars=yes');
				document.location.href="m_profili.asp?task="+task+"&id="+id;
				}
		}

//-----------------------------------------------------------------------------------

		function openPopUpProfili() {
			win = window.open('s_profili.asp?task=cerca&id=&titolo=&ruoli=-1', 'Profilo', 'height=600,width=800,status=yes,toolbar=no,scrollbars=yes');
		}

//-----------------------------------------------------------------------------------

		function openEditor(nomeSessione) {
			win = window.open('/editor/editor.asp?nomeSessione='+nomeSessione, 'HTMLEditor','height=600,width=800,status=no,toolbar=no,scrollbars=yes,resizable=yes');
		}

//-----------------------------------------------------------------------------------

		function openEditor2(nomeSessione) {
			win = window.open('/editor/editor.asp?idfm='+nomeSessione, 'HTMLEditor','height=600,width=800,status=no,toolbar=no,scrollbars=yes,resizable=yes');			
		}

//-----------------------------------------------------------------------------------

		function openEditor2Visualizzazione(nomeSessione)
		{
			var width = "800";
			if (window.CnaSir && CnaSir.popupWidth)
				width = CnaSir.popupWidth;
				
			var win = window.open('/editor/editor.asp?idfm='+nomeSessione+'&task=view', 'HTMLEditor','height=600,width=' + width + ',status=no,toolbar=no,scrollbars=yes,resizable=yes');			
		}

//-----------------------------------------------------------------------------------

		function validaCampi(task, clone) {
			var erroriTrovati = 1;
			var formDati = document.adempimento

			if (formDati.titolo.value != '')
				{
				if (formDati.idtipologiaImpresa.value != -1)
					{
					if (formDati.idcittadinanza.value != -1)
						{
						if (formDati.idraggruppamento.value != -1)
							{
							if (formDati.idclassificazione.value != -1)
								{erroriTrovati = 0}
							else
								{alert("Inserire la classificazione!");}
							}
						else
							{alert("Inserire il raggruppamento!");}
						}
					else
						{alert("Inserire la cittadinanza!");}
					}
				else
					{alert("Inserire la tipologia d'impresa!");}
				}
			else
				{alert("Inserire il titolo!");}

			//se presentazioneGG è vuoto, viene considerato 0
			var presentazioneGG = parseInt(formDati.presentazioneGG.value, 10);
			if (!formDati.presentazioneGG.value)
				presentazioneGG = 0;
				
			var conclusioneProcedimentoGG = parseInt(formDati.conclusioneProcedimentoGG.value, 10);
			if (!formDati.conclusioneProcedimentoGG.value)
				conclusioneProcedimentoGG = 0;
				
			if (!erroriTrovati)
			{
				if (isNaN(presentazioneGG))
				{
					alert('"Presentazione GG" deve essere un numero');
					erroriTrovati = 1;
				}
			}
			
			if (!erroriTrovati)
			{
				if (isNaN(conclusioneProcedimentoGG))
				{
					alert('"Conclusione procedimento GG" deve essere un numero');
					erroriTrovati = 1;
				}
			}

			if (erroriTrovati == 0)
			{
				formDati.presentazioneGG.value = presentazioneGG;
				formDati.conclusioneProcedimentoGG.value = conclusioneProcedimentoGG;
			
				formDati.task.value=task;
				if (clone==1)
					{formDati.clone.value="1";}
				else
					{formDati.clone.value="0";}
				
				if
				(
					window.Cnasir.task == "LOCALIZZA" ||
					window.Cnasir.task == ""
				)
				{
					notificaOperazione("submitFormDati", "adempimenti");
				}
				else
				{
					formDati.submit();
				}
			}
		}
		
//-----------------------------------------------------------------------------------

		function submitForm()
		{
			if (document.forms.length > 0)
				document.forms[0].submit();
		}

//-----------------------------------------------------------------------------------

		function submitFormDati()
		{
			var formDati = document.adempimento;
			if (formDati)
				formDati.submit();
		}

//-----------------------------------------------------------------------------------

		function saveCitta()
		{
			document.myForm.task.value="save";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function saveComuni()
		{
			document.myForm.task.value="save";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function validaRegione()
		{
			document.myForm.task.value="comuni";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function newInterpretazione()
		{document.location.href='newInterpretazione.asp';}

//-----------------------------------------------------------------------------------

		function manageNormative(task)
		{
			document.frmNormative.task.value=task;
			document.frmNormative.submit();
		}

//-----------------------------------------------------------------------------------

		function salvaChiudiProfili()
		{
			var ok=0;
			var j=0;
			if (!document.myForm.profilo.length)
				{ // un solo elemento
				if (document.myForm.profilo.checked==true) ok++;
				}
			else
				{
				for (j=0; j<document.myForm.profilo.length; j++)
					{
					if (document.myForm.profilo[j].checked==true)
					ok++;
					}
				}

			if (ok==0)
				{alert("Selezionare almeno un profilo");}
			else
				{
				document.myForm.task.value="saveClose";
				document.myForm.submit();
				}
		}

//-----------------------------------------------------------------------------------

		function salvaTag()
		{
			if (document.myForm.tag.value=="")
				{alert("TAG mancante");}
			else
				{
				if ((document.myForm.tabella.value!="") && (document.myForm.campo.value!="") || (document.myForm.funzione.value!=""))
					{
					if (document.myForm.descrizione.value!="")
						{
						document.myForm.task.value="salva";
  						document.myForm.submit();
  						}
  					else
  						{alert("Descrizione mancante!")}
					}
				else
					{alert("Compilare la voce tabella e la voce campo oppure\nla voce funzione!")}
				}
		}

//-----------------------------------------------------------------------------------

		function salvaChiudiCriteri()
			{
			var ok=0;
			var j=0;
			if (!document.myForm.chkCriterio.length)
				{
				if (document.myForm.chkCriterio.checked==false)
					{alert("Selezionare almeno una normativa");}
				else
					{
					document.myForm.task.value="salva";
					document.myForm.submit();
					}
				}
			else
				{
				for (j=0; j<document.myForm.chkCriterio.length; j++)
					{
					if (document.myForm.chkCriterio[j].checked==true)
						{ok++;}
					}

				if (ok==0)
					{alert("Selezionare almeno una normativa");}
				else
					{
					document.myForm.task.value="salva";
					document.myForm.submit();
					}
			}
		}

//-----------------------------------------------------------------------------------

		function cercaTAG()
		{
			document.tag.task.value="cerca";
			document.tag.submit();
		}

//-----------------------------------------------------------------------------------

		function chiudiCliente()
		{
			if (!document.myForm.cliente.length)
				{
				if (document.myForm.cliente.checked==true)
					{
					document.myForm.task.value="salvaChiudi";
					document.myForm.submit();
					}
				else
					{alert("Selezionare almeno un cliente");}
				}
			else
				{
				var ok = 0;
				for (i=0; i<document.myForm.cliente.length; i++)
					{
					if (document.myForm.cliente[i].checked==true) ok++;
					}

				if (ok>0)
					{
					document.myForm.task.value="salvaChiudi";
					document.myForm.submit();
					}
				else
					{alert("Selezionare almeno un cliente");}
				}
		}

//-----------------------------------------------------------------------------------

		function validaInterpretazione()
		{
			var erroriTrovati;
			erroriTrovati = 0;
			if (document.myForm.titolo.value=="")
			{
				alert('Inserire il titolo dell\'interpretazione!');
			}
			else
			{
				if
				(
					window.Cnasir.task == "LOCALIZZA" ||
					(window.Cnasir.task == "" && window.idog == "0")
				)
				{
					notificaOperazione("submitForm", "interpretazioni");
				}
				else
				{
					document.myForm.submit();
				}
			}
		}

//-----------------------------------------------------------------------------------

		function saveProvincie()
		{
			document.myForm.task.value="save";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function validaProvincie()
		{
			document.myForm.task.value="provincie";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function deleteRecord(id)
		{
			if (confirm("Procedere con la cancellazione della voce selezionata?")){
				document.myForm.id.value=id;
				document.myForm.task.value="delete";
				document.myForm.submit();
			}
		}

//-----------------------------------------------------------------------------------

		function refreshList()
		{
			document.myForm.task.value="cerca";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function cerca()
		{
			document.myForm.task.value="cerca";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function openPopUpTipologia(task, codice, tipo, descrizione, id)
		{
			var lnk;
			if (task == "new")
				{
				if (win) win.close;
				lnk = "tipologiaPopUp.asp?task=" + task
				win = window.open(lnk, "", "menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=400,height=220");
				}
			else
				{
				lnk = "tipologiaPopUp.asp?task=" + task + "&codice=" + codice + "&tipo=" + tipo + "&descrizione=" + descrizione + "&id=" + id
				win = window.open(lnk, "", "menubar=no,location=no,resizable=no,scrollbars=no,status=no,width=400,height=220");
				}
		}

//-----------------------------------------------------------------------------------

		function saveAndClose(id)
		{
			document.myForm.task.value	= "modify";
			document.myForm.id.value	= id;
			document.myForm.close.value	= "chiudi";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function saveAndAdd(task, id)
		{
			document.myForm.action.value="SAA";
			document.myForm.task.value=task;
			document.myForm.id.value=id;
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function deleteInterpretazione(id)
		{
			var choice;
			choice = confirm("Continuare con la cancellazione dell\'interpretazione?")
			if (choice) {
				document.interpretazione.task.value="delete";
				document.interpretazione.idInterpretazione.value=id;
				document.interpretazione.submit();
			}
		}

//-----------------------------------------------------------------------------------
/*
		function modifyInterpretazione(id)
		{document.location.href="newInterpretazione.asp?task=modify&id=" + id;}
*/
//-----------------------------------------------------------------------------------

		function aggiornaInterpretazione(id)
		{
			document.myForm.task.value="update";
			document.myForm.id.value=id;
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function aggiornaTag(id)
		{
			if (document.myForm.tag.value=="")
				{alert("TAG mancante");}
			else
				{
				if ((document.myForm.tabella.value!="") && (document.myForm.campo.value!="") || (document.myForm.funzione.value!=""))
					{
					if (document.myForm.descrizione.value!="")
						{
						document.myForm.task.value="update";
						document.myForm.id.value=id;
						document.myForm.submit();
						}
					else
						{alert("Descrizione mancante!")}
					}
				else
					{alert("Compilare la voce tabella e la voce campo oppure\nla voce funzione!")}
				}
		}

//-----------------------------------------------------------------------------------

		function scriviTag(nomeSessione) {			
			var cmb = document.getElementById("tag");
			var editor = document.getElementById("editor");			
			return true;
		}

//-----------------------------------------------------------------------------------

		function aggiornaModello(id) {
			document.modello.task.value="aggiorna";
			document.modello.id.value=id;
			document.modello.submit();
		}

//-----------------------------------------------------------------------------------		

		function cancellaModelli(id) {
			if (confirm("Procedere con la cancellazione?")) {
				window.location="l_modelli.asp?id=" + id
			}
		}

//-----------------------------------------------------------------------------------

		function aggiungiNormativa() {
			window.open("trovaNormativa.asp", "Normativa", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
		}

//-----------------------------------------------------------------------------------

		function aggiungiModello() {
			win = window.open("s_modelli.asp", "Modelli", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
		}

//-----------------------------------------------------------------------------------		

		function aggiungiCriterioObb() {
			window.open("trovaCriterio.asp", "Criterio", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");		
		}

//-----------------------------------------------------------------------------------		

		function aggiungiReferente(idan) {
			var page = "m_skAnagraficaReferenteAziendale.asp?idan=" + idan + 
				"&idRef=" + document.formContatto.idRef.value + 
				"&cognomeRef=" + escape(document.formContatto.cognomeRef.value) + 
				"&nomeRef=" + escape(document.formContatto.nomeRef.value) +
				"&ruoloRef=" + document.formContatto.ruoloRef.value
			window.open(page, "Referente", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");		
		}

//-----------------------------------------------------------------------------------

		function apriReferente(idan, idar, task) {
			var page = "m_skAnagraficaReferenteAziendale.asp?idan=" + idan + "&idar=" + idar +
				"&task=" + task +
				"&idRef=" + top.document.formContatto.idRef.value +
				"&cognomeRef=" + escape(top.document.formContatto.cognomeRef.value) +
				"&nomeRef=" + escape(top.document.formContatto.nomeRef.value) +
				"&ruoloRef=" + top.document.formContatto.ruoloRef.value
			window.open(page, "Referente", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");		
		}
		
//-----------------------------------------------------------------------------------

		function aggiungiAltraSede(idan) {
			var page = "m_altraSede.asp?idan=" + idan;
			window.open(page, "Referente", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");		
		}

//-----------------------------------------------------------------------------------

		function apriAltraSede(idan, idas, task) {
			var page = "m_altraSede.asp?idan=" + idan + "&idas=" + idas + "&task=" + task;
			window.open(page, "Referente", "height=330,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");		
		}

//-----------------------------------------------------------------------------------

		function aggiungiIstruzioneOrg() {
			window.open("trovaIstruzione.asp", "Istruzione", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");		
		}

//-----------------------------------------------------------------------------------

		function aggiungiInterpretazione() {
			window.open("a_interpretazione.asp?task=select&titolo=", "Interpretazione", "height=400,width=800,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
		}

//-----------------------------------------------------------------------------------

		function cercaInterpretazione(task)	{
			document.interpretazione.task.value=task;
			document.interpretazione.submit();
		}

//-----------------------------------------------------------------------------------

//Usata nella pagina e_profili.asp (back)
		function cercaProfilo() {
			document.myForm.task.value="cerca";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function refreshInterpretazione() {			
			var objIFrameInter = window.opener.document.getElementById("interpretazioneFile");
			objIFrameInter.src=objIFrameInter.src;
		}		

//-----------------------------------------------------------------------------------

		function refreshProfili() {
			var objIFrameProfili = window.opener.document.getElementById("profili");			
			var tst = new Date().valueOf();
			objIFrameProfili.src=objIFrameProfili.src+"?tst="+tst;
		}

//-----------------------------------------------------------------------------------

		function refreshModelli() {
			var objIFrameModelli = window.opener.document.getElementById("modelli");
			objIFrameModelli.src=objIFrameModelli.src;
		}

//-----------------------------------------------------------------------------------

		function refreshNormative() {
			var objIFrameNormativa = window.opener.document.getElementById("normativa");
			objIFrameNormativa.src=objIFrameNormativa.src;
		}

//-----------------------------------------------------------------------------------

		function refreshIstruzione() {
			var objIFrameIstruzione = window.opener.document.getElementById("istruzioneOrganizzativa");
			objIFrameIstruzione.src=objIFrameIstruzione.src;
		}

//-----------------------------------------------------------------------------------

		function refreshCriterio() {
			var objIFrameCreterio = window.opener.document.getElementById("obbligatorietaFile");
			objIFrameCreterio.src=objIFrameCreterio.src;
		}

//-----------------------------------------------------------------------------------

		function refreshClienti() {
			var objIFrameClienti = window.opener.document.getElementById("anagraficaClienti");
			objIFrameClienti.src=objIFrameClienti.src;
		}

//-----------------------------------------------------------------------------------

		function refreshSession() {			
			var objIFrame = window.opener.document.getElementById("locazione");
			objIFrame.src = objIFrame.src;
		}

//-----------------------------------------------------------------------------------

		function cercaNormativa()
		{document.normativa.task.value="search";}

//-----------------------------------------------------------------------------------

		function cercaPratica(step)
		{
			var chk1 = false
			var chk2 = false

			if (step >= 1)
				{
				if (document.myForm.classeAttivita.value>0)
					{
					if (document.myForm.attivita.value>0)
						{chk1 = true}
					else
						{alert("Selezionare l'attivita")}
					}
				else
					{alert("Selezionare la classe d'attività")}
				}

			if (step == 2)
				{
				if (document.myForm.idop.value>0)
					{}
				else
					{alert("selezionare l'operazione")}
				}
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function mostraNascondi(id) {
			var objDiv = document.getElementById(id);
			if (objDiv.style) {
				if (objDiv.style.display == "none") { 
					objDiv.style.display = ""; 
				} else {
					objDiv.style.display = "none"; 
				}
			} else { 
				objDiv.visibility = "show"; 
			}
		}

//-----------------------------------------------------------------------------------

		function eliminaNormativa(id){
			document.normativa.task.value="delete";
			document.normativa.idNormativa.value=id;
			document.normativa.submit();
		}

//-----------------------------------------------------------------------------------

		function nuovaNormativa(){
      document.location.href='newNormativa.asp';}

//-----------------------------------------------------------------------------------

		function pulisciSessioneComuni()
		{
			document.adempimento.task.value="clearSession";
			document.adempimento.submit();
		}

//-----------------------------------------------------------------------------------

		function cercaModelli() {
			document.myForm.task.value="cerca";
			document.myForm.submit();
		}

//-----------------------------------------------------------------------------------

		function describeForm(form)
		{
			var str = "";
			var elems = form.elements;
			for (var i = 0; i < elems.length; i++)
			{
				var elem = elems[i];
				var item = elem.nodeName;
				if (elem.type)
					item += " type=" + elem.type;
				if (elem.name)
					item += " name=" + elem.name;
				if (elem.id)
					item += " id=" + elem.id;
				if (typeof elem.value != "undefined")
					item += " value=" + elem.value;
				if (typeof elem.checked != "undefined" && elem.checked)
					item += " checked";
				if (typeof elem.disabled != "undefined" && elem.disabled)
					item += " disabled";
				item += "\n";
				str += item;
			}
			return str;
		}

//-----------------------------------------------------------------------------------

		function cercaEmail()
		{document.e_email.submit();}

//-----------------------------------------------------------------------------------

		function salvaEmail(operazione)
		{
			var oggetto	= document.m_email.oggetto.value
			var testo	= document.m_email.testo.value
			if (oggetto == '')
				{alert("Inserire l'oggeto della mail!")}
			else
				{
				/*
				if (testo == '')
					{alert("Inserire il testo della mail!")}
				else
					{
				*/
					switch (operazione)
						{
						case 0 :	// Solo salvataggio mail
							var chkSub = true;
							document.m_email.operazione.value = 0;

							if (document.m_email.canc)
								{
								if (document.m_email.canc.checked)
									{
									if (!confirm("Confermi la cancellazione della mail?"))
										{chkSub = false;}
									}
								}
								
							if (chkSub)
								{document.m_email.submit();}
							break;

						case 1 :	// Salvataggio mail e apertura form ricerca destinatari
							document.m_email.operazione.value = 1;
							document.m_email.submit();
							break;

						case 2 :	// Ricerca destinatari
							document.getElementById('oggetto2').value	= oggetto;
							document.getElementById('testo2').value		= testo;
							document.eDest.operazione.value	= 2;
							document.eDest.submit();
							break;

						case 3 :	// Invio mail
							var chkDest = false;
							var arrDest = document.getElementsByName('destinatari');
							for (i=0;i<arrDest.length;i++)
								{
								if (arrDest[i].checked)
									{
									chkDest = true;
									break;
									}
								}

							if (chkDest)
								{
								document.getElementById('oggetto2').value	= oggetto;
								document.getElementById('testo2').value		= testo;
								document.eDest.operazione.value = 3;
								document.eDest.submit();
								}
							else
								{alert("Selezionare almeno un destinatario!");}
							break;
						} 
					//}
				}
		}

//-----------------------------------------------------------------------------------

		function cancellaEmail(idem)
		{
			if (confirm('Confermi la cancellazione?'))
				{window.location = 'm_email.asp?idem='+ idem +'&sotto=x&canc=x'}
		}

//-----------------------------------------------------------------------------------

		function printStackTrace(node)
		{
			var str = "";
			for ( ; node; node = node.parentNode)
			{
				var item = node.nodeName;
				if (node.type)
					item += " type=" + node.type;
				if (node.name)
					item += " name=" + node.name;
				if (node.id)
					item += " id=" + node.id;
				if (node.className)
					item += " class=" + node.className;
				item += "\n";
				str += item;
			}
			return str;
		}

//-----------------------------------------------------------------------------------

		function describeForm(form)
		{
			var str = "FORM name=" + form.name + " action=" + form.action + " method=" + form.method + "\n";
			var elems = form.elements;
			for (var i = 0; i < elems.length; i++)
			{
				var elem = elems[i];
				var item = elem.nodeName;
				if (elem.type)
					item += " type=" + elem.type;
				if (elem.name)
					item += " name=" + elem.name;
				if (elem.id)
					item += " id=" + elem.id;
				if (typeof elem.value != "undefined")
					item += " value=" + elem.value;
				if (typeof elem.checked != "undefined" && elem.checked)
					item += " checked";
				if (typeof elem.disabled != "undefined" && elem.disabled)
					item += " disabled";
				item += "\n";
				str += item;
			}
			return str;
		}

//-----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
