// *****************************************************************************************

//displayid 

//se il campo della form "abilitante" ha il valore uguale a "valore" il campo "condizionato"
//viene reso visibile e compilabile, altrimenti viene inizializzato a null e nascosto

function displayid(abilitante, valore, condizionato, nomeform){
		if (!nomeform){nomeform='0'}
 		chiamante=document.forms[0];
 		elementi_chiamante=chiamante.elements;
 		//prova=elementi_chiamante[abilitante].value==valore;
 		//alert(abilitante+'-'+elementi_chiamante[abilitante].value+'=='+valore+'>>'+prova); 
 		if (elementi_chiamante[abilitante][elementi_chiamante[abilitante].selectedIndex].value==valore) {//alert('mostro '+condizionato);
 			Mostra(condizionato);}
 		else {
 			elementi_chiamante[condizionato].value='';
 			//alert('nascondo '+condizionato);
 			Nascondi(condizionato);
 		}	
}

function displayid_cond(abilitante, valore, abilitante1, valore1, condizionato, nomeform){
		if (!nomeform){nomeform='0'}
 		chiamante=document.forms[0];
 		elementi_chiamante=chiamante.elements;
 		//prova=elementi_chiamante[abilitante].value==valore;
 		//alert(elementi_chiamante[abilitante].value+'=='+valore+'>>'+prova); 
 		if (parseInt(elementi_chiamante[abilitante][elementi_chiamante[abilitante].selectedIndex].value)==parseInt(valore) && parseInt(elementi_chiamante[abilitante1].value)==parseInt(valore1)) {//alert('mostro '+condizionato);
 			Mostra(condizionato);}
 		else {
 			elementi_chiamante[condizionato].value='';
 			//alert('nascondo '+condizionato);
 			Nascondi(condizionato);
 		}	
}


function displayid_cond_check(abilitante, condizionato, nomeform){
		if (!nomeform){nomeform='0'}
 		chiamante=document.forms[0];
 		elementi_chiamante=chiamante.elements;
 		//prova=elementi_chiamante[abilitante].value==valore;
 		//alert(elementi_chiamante[abilitante].value+'=='+valore+'>>'+prova); 
 		if (elementi_chiamante[abilitante].checked) {//alert('mostro '+condizionato);
 			Mostra(condizionato);}
 		else {
 			elementi_chiamante[condizionato].value='';
 			//alert('nascondo '+condizionato);
 			Nascondi(condizionato);
 		}	
}

function displayidcheck(abilitante, condizionato, nomeform){
		if (!nomeform){nomeform='0'}
 		chiamante=document.forms[0];
  	elementi_chiamante=chiamante.elements;
 		if (elementi_chiamante[abilitante].checked) document.getElementById(condizionato).style.display='';
 		else {
 			elementi_chiamante[condizionato].value='';
 			document.getElementById(condizionato).style.display='none';
 		}	
}

function show_values() {
var w = window.open("",                    // URL (nessuno)
                       "RIASSUNTO",        // nome
                       "resizable,status,scrollbars,menubar"); // caratteristiche
// alert('HO APERTO LA FINESTRA');
var d = w.document;    // Per fare prima a scrivere

// alert('HO DEFINITO f ED el');
d.write('<HTML><HEAD><TITLE></TITLE></HEAD><BODY bgcolor=white>')
var f=w.opener.document.forms[0];
el=f.elements;
eln=el.length;
// alert('Numero campi '+eln)
// doc=op.window;
// d.write('<script language=javascript>');
// d.write('<center><b><font face=arial size=5> LISTA VARIABILI</font></b></center>');
d.write('<TABLE WIDTH="90%" border=1>');
for (i=0;i<eln;i++) {
nome=el[i].name;
tipo=el[i].type;
if (tipo=='select-one') {
j=el[i].selectedIndex;valore=el[i][j].value;
cella4='<TD height=3><FONT FACE=ARIAL SIZE=1>SELECTED INDEX= '+j+'</FONT><br></TD>'+"\n";} // fine if
else {valore=el[i].value} // fine else
if (tipo=='radio' || tipo=='checkbox') {
selez=el[i].checked;
cella4='<TD height=3><FONT FACE=ARIAL SIZE=1>CHECKED= '+selez+'</FONT><br></TD>'+"\n";} // fine if
if (tipo!='select-one' && tipo!='radio' && tipo!='checkbox') {
cella4='<TD height=3><font face=arial size=1 color=white>na<br></font></TD>'} // fine if
cella0='<TD height=3><FONT FACE=ARIAL SIZE=1>'+i+'</FONT><br></TD>'+"\n";
cella1='<TD height=3><FONT FACE=ARIAL SIZE=1>'+nome+'</FONT><br></TD>'+"\n";
cella2='<TD height=3><FONT FACE=ARIAL SIZE=1>VALORE= '+valore+'</FONT><br></TD>'+"\n";
cella3='<TD height=3><FONT FACE=ARIAL SIZE=1>TYPE= '+tipo+'</FONT><br></TD>'+"\n";
riga='<TR>'+cella0+cella1+cella2+cella3+cella4+'</TR>'+"\n";
d.write(''+riga);
} // fine for
d.write('</TABLE>'+"\n");
// d.write('<center><b><font face=arial size=5> FINE LISTA VARIABILI</font></b></center>');
d.write('<form><CENTER><INPUT TYPE=BUTTON VALUE="CHIUDI" onclick="self.close();"></CENTER></form>'+"\n");
d.write('</BODY></HTML>');
d.close();
} // fine show_values
// *****************************************************************************************

// *****************************************************************************************
// Javascript TOOLS per la visualizzazione delle variabili inviate al server
// VERSIONE 0.1b
// by ANDREA CASSA, 9 Novembre 1998
// *****************************************************************************************

// *****************************************************************************************
function force_focus() {
if (!(window.focus())) {window.focus()}
setTimeout("force_focus2()",1000);
return 0;
} // fine funzione
// *****************************************************************************************

// *****************************************************************************************
function force_focus2() {
if (!(window.focus())) {window.focus()}
setTimeout("force_focus()",1000);
return 0;
} // fine funzione
// *****************************************************************************************

// *****************************************************************************************
      
// *****************************************************************************************

function congela() {
alert('Non puoi modificare manualmente questo campo!\n'+'Per favore, usare i pulsanti Sfoglia, Ricerca e Cancella');
return 0;
} // fine funzione

// *****************************************************************************************

function sbianca() {
var i_sb, nome_campo, arg_l;
if (sbianca.arguments.length) {
for (i_sb=0;i_sb<sbianca.arguments.length;i_sb++) {
nome_campo=sbianca.arguments[i_sb];
document.forms[0].elements[nome_campo].value='';
} // fine for
} // fine if 
else {return false}
return 0;
} // fine funzione

function radioclear (nome) {
el=document.forms[0].elements;
num_bot=el[nome].length; // **************************************************** numero di bottoni
// ***************************************************************************** Netscape (<=4.6) restituisce num_bot=null per array di radio con 1 solo elemento
if (num_bot==null) { // ******************************************************** C'e' un solo radio e si sta usando NS<=4.6
check=el[nome].checked; // ************************************************** La proprieta' checked del radio singolo
if (check) {el[nome].checked=false} // ************************************** c'e' un solo bottone ed e' selezionato, lo sbianco
return true // ***************************************************************** ritorno true
} // *************************************************************************** fine if in num_bot
// ***************************************************************************** Se arriva qui o l'array e' di piu' elementi o non si sta usando Netscape
for (ind=0;ind<num_bot;ind++) {// ********************************************** Percorro il ciclo dei radio omonimi
if (el[nome][ind].checked){el[nome][ind].checked=false} // ********************* se ne trovo uno selezionato ritorno 0
} // *************************************************************************** fine ciclo
return true;
} // fine funzione


function prepara_parametri() {
var f=document.forms[0];
var parametri='';
el=f.elements;
eln=el.length;
for (ii=0;ii<eln;ii++) {
nome=el[ii].name;
tipo=el[ii].type;
//if (tipo=='select-one') {
//	jj=el[ii].selectedIndex;
//	valore=el[ii][jj].value;
//} // fine if
//else {
//	valore=el[ii].value} // fine else
//if (tipo=='radio' || tipo=='checkbox') {
//	valore=radiovalue(nome,'0');
//} // fine if
if (tipo=='hidden'){
	valore=el[nome].value;
	parametri+=nome+'='+valore+'&';
}
} // fine for
return parametri;
}

function prepara_decode() {
	for (k=0;k<document.forms.length;k++){
	var f=document.forms[k];
	el=f.elements;
	eln=el.length;
//      alert("somo qui");
		for (i=0;i<eln;i++) {
		nome=el[i].name;
		tipo=el[i].type;
                // alert(nome+' '+tipo+' ');

			if (nome.substring(0,2)=='D_'){
				nomeselect=nome.substring(2,nome.length);
				if (el[nomeselect]){
					valore='';
					if (el[nomeselect].type=='select-one'){
						j=el[nomeselect].selectedIndex;
						if (j>=0) {
							valore=el[nomeselect][j].text;
							el[nome].value=valore;
						}
						// alert (nome+'='+valore);
					}else if (el['DESC_'+nomeselect] && el['S_'+nomeselect] && el['S_'+nomeselect].type=='select-multiple'){
						valore=el['DESC_'+nomeselect][0].text;
						el[nome].value=valore;
						//alert (nome+'='+valore);
					}else if (el['S_'+nomeselect] && el['S_'+nomeselect].type=='select-multiple'){
						valore=el['S_'+nomeselect][0].text;
						el[nome].value=valore;
						//alert (nome+'='+valore);
					}else if (el['DESC_'+nomeselect] && el['DESC_'+nomeselect].type=='select-multiple'){
						valore=el['DESC_'+nomeselect][0].text;
						el[nome].value=valore;
						//alert (nome+'='+valore);
					}else if (el['DESC_'+'D_'+nomeselect] && el['DESC_'+'D_'+nomeselect].type=='select-multiple'){
						valore=el['DESC_'+'D_'+nomeselect][0].text;
						el[nome].value=valore;
						//alert (nome+'='+valore);
					}
					
				}
			}
			if (el['I'+nome] && el['I'+nome].type.substring(0,6)=='select' && (el[nome].type=='text' || el[nome].type=='hidden') ){
				//alert('Sono qui');
				el[nome].value=el['I'+nome][el['I'+nome].selectedIndex].text;
			}
			//if ((tipo=='text' || tipo=='hidden' || tipo=='textbox') && (el[nome].value.substr(0,5)=='_____' || el[nome].value.substr(0,5)=='-----')){
			//	el[nome].value='';
			//}
		}
	}
}

//function prepara_checkbox_onload() {
//	for (k=0;k<document.forms.length;k++){
//	var f=document.forms[k];
//	el=f.elements;
//	eln=el.length;
//		for (i=0;i<eln;i++) {
//		nome=el[i].name;
//		tipo=el[i].type;
//			if (tipo=='checkbox'){
//				alert (nome+'-'+el[nome].checked+'-'+el[nome].value);
//				if (el[nome].checked && !el[nome].value){
//					el[nome].checked=false;
//				}
//			}
//		}
//	}
//}

function precompila_tendine(nome_campo_hidden,nomeform) {
  if (!nomeform){nomeform='0';}
  chiamante=document.forms[nomeform];
  elementi_chiamante=chiamante.elements;

if (elementi_chiamante[nome_campo_hidden]){
	if (elementi_chiamante[nome_campo_hidden].value !=''){
		elementi_chiamante['S_'+nome_campo_hidden][0].text=elementi_chiamante[nome_campo_hidden].value;
	}
}
return 0;
}

function precompila_tendine_auto() {
	for (k=0;k<document.forms.length;k++){
	var f=document.forms[k];
	var tipi;
	el=f.elements;
	eln=el.length;
		for (i=0;i<eln;i++) {
		nome=el[i].name;
		tipo=el[i].type;
		//tipi=tipi+tipo+'\\n';
			if (el['S_'+nome] && (el['S_'+nome].type=='select-one' || el['S_'+nome].type=='select-multiple')){
				if (el[nome].value !=''){
					el['S_'+nome][0].text=el[nome].value;
				}
			}
			if (el['DESC_'+nome] && (el['DESC_'+nome].type=='select-one' || el['DESC_'+nome].type=='select-multiple')){
				if (el[nome].value !=''){
					if (nome.substr(0,3)=='ID_'){
						alert ('D_'+nome.substr(3,nome.length));
						el['DESC_'+nome][0].text=el['D_'+nome.substr(3,nome.length)].value;
					}else if (el['D_'+nome]) {
						el['DESC_'+nome][0].text=el['D_'+nome].value;
					}else {
						el['DESC_'+nome][0].text=el[nome].value;
					}
				}
			}
		}
	}
	//alert (tipi);
return 0;
}


function detect_browser(){
// Browser Detection
browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion); 
if (browser_name == "Netscape" && browser_version >= 3.0) { roll ='true'; }
else if (browser_name == "Microsoft Internet Explorer" && browser_version >= 4.0) { roll = 'true'; }
else { roll = 'false'; }
// Preload images, if browser supports mouseovers
if (roll == 'true') {
	var imglist = new Array ("/images/sfoglia_on.gif","/images/cerca_on.gif","/images/cancella_on.gif", "/images/naviga_on.gif");
	var imgs = new Array();
	var count;
	if (document.images){
       		for (count=0; count<imglist.length; count++){
       			imgs[count]=new Image(); imgs[count].src=imglist[count];
        	}
        }
}
// Use this code if you are only doing one mouseover
}
function msover1(img,ref) {if (roll=='true') {document.images[img].src = ref;}}
function msout1(img,ref)  {if (roll=='true') {document.images[img].src = ref;}}
function apri_window (source,nome) {
	//newwin = window.open(source,nome, 'width=450,height=425,scrollbars=yes')
	//apre sempre UNA SOLA finestra
	var newwin = window.open(source,'window1', 'width=450,height=425,scrollbars=yes')
	if (!window.opener) {newwin.opener = self}
}
function apri_windowc (source,nome) {
	var newwin = window.open(source,'window2', 'left=0,screenX=0,top=0,screenY=0,width=790,height=500,scrollbars=yes,toolbar=yes,resizable=yes');
	if (!window.opener) {newwin.opener = self}
	newwin.focus();
}
function apri_windowb (source,nome) {
	var newwin = window.open(source,'window3', 'left=0,screenX=0,top=0,screenY=0,width=790,height=500,scrollbars=yes,toolbar=yes,resizable=yes');
	if (!window.opener) {newwin.opener = self}
	newwin.focus();
}

function apri_window_big (source,nome) {
	//newwin = window.open(source,nome, 'width=450,height=425,scrollbars=yes')
	//apre sempre UNA SOLA finestra
	var newwin = window.open(source,'window4', 'width=790,height=500,scrollbars=yes')
	if (!window.opener) {newwin.opener = self}
}

function sbianca_s(descrizione,dimensione,nomeform,stringavuota) {
  if (!nomeform){nomeform='0'}
  chiamante=document.forms[nomeform];
  elementi_chiamante=chiamante.elements;

  if (dimensione=='1'){
	elementi_chiamante[descrizione][0].value='';
	elementi_chiamante[descrizione][0].text=stringavuota;
  }else {
  	var i,j,k;
  	var vettV=new Array();
  	var vettT=new Array();
  	var eliminati=0;
  	for (i=0;i<elementi_chiamante[descrizione].options.length;i++){
  		if (elementi_chiamante[descrizione][i].selected && elementi_chiamante[descrizione][i].value){
  			eliminati++;
			elementi_chiamante[descrizione][i].value='';
			elementi_chiamante[descrizione][i].text='';
  		}else if (elementi_chiamante[descrizione][i].value) {
  			vettV[i]=elementi_chiamante[descrizione][i].value;
  			vettT[i]=elementi_chiamante[descrizione][i].text;
  		}
  	}
	if (eliminati>0 && elementi_chiamante[descrizione].options.length>1){
  		//Inizio Parte aggiunta da testare
  		elementi_chiamante[descrizione].options.length=1;
  		j=0;
  		for (k=0;k<i;k++){
  			if (vettV[k] && vettT[k]){
  				elementi_chiamante[descrizione].options.length++;
  				elementi_chiamante[descrizione][j].value=vettV[k];
				elementi_chiamante[descrizione][j].text=vettT[k];
				j++; 			
  			}
		}
		//Fine Parte aggiunta da testare
    	}
  	if (!eliminati){alert('Selezionare gli elementi che si vuole eliminare,\nquindi cliccare su Cancella!');}
	if (elementi_chiamante[descrizione].options.length<=1 && elementi_chiamante[descrizione][0].value==''){
		elementi_chiamante[descrizione][0].text=stringavuota;
	}
  }
  return 0;
}

function apri_window_small (source) {
        var newwin;
        newwin = window.open(source,'window0','width=450,height=500,scrollbars=yes')
        if (!window.opener) {
                newwin.opener = self
        }
}


function diff_2_date(nomedata,dataconfronto,nomedatasistema,datasistema,nomeform){
  var rcf;
  rcf=diff_date_vs_sysdate(nomedata,dataconfronto);
 if (!rcf){
  rcf=diff_date_vs_sysdate(nomedatasistema,datasistema);
 }
 if (!rcf){
  rcf=diff_date_vs_sysdate(nomedata,dataconfronto,nomedatasistema,datasistema);
 }
 return rcf;
}

function diff_date_vs_sysdate(nomedata,dataconfronto,nomedatasistema,datasistema,nomeform){
  if (!nomeform){nomeform='0'}
  if (!datasistema){datasistema='SYSDATE'}
  if (!nomedatasistema){nomedatasistema='data odierna'}
f=document.forms[0];
el=f.elements;
if (datasistema=='SYSDATE' || (!el[datasistema+'D'] && !el[datasistema+'M'] && !el[datasistema+'Y']) && (el[datasistema].value.length!=8)){
	var datasys=el[datasistema].value.substr(6,4)+el[datasistema].value.substr(3,2)+el[datasistema].value.substr(0,2);
}else{
	var datasys=el[datasistema].value.substr(4,4)+el[datasistema].value.substr(2,2)+el[datasistema].value.substr(0,2);
}

var datacons=el[dataconfronto].value;
if (!el[dataconfronto+'D'] && !el[dataconfronto+'M'] && !el[dataconfronto+'Y']){
	datacons=datacons.substr(6,4)+datacons.substr(3,2)+datacons.substr(0,2);
}else{
datacons=datacons.substr(4,4)+datacons.substr(2,2)+datacons.substr(0,2);
}


//if (el[datasistema+'RC']){
//alert (el[datasistema+'RC'].value);
//}
if (el[datasistema+'RC'] && el[datasistema+'RC'].value=='CONTIN'){
	return 0
}
//alert ('data1 '+dataconfronto+' '+datacons+' - data2 '+dataconfronto+' '+datasys);
if (datacons>datasys && datasys!=''){
	//alert (datacons+'-'+datasys);
	if (el[dataconfronto+'M']){el[dataconfronto+'M'].focus();}
	else if (el[datasistema+'M']){el[datasistema+'M'].focus();}
	alert ('Attenzione!\n'+nomedata+' successiva alla '+nomedatasistema+'.\nModificare e inviare nuovamente!');
	rc=1;
}else {rc=0}
return rc;
}

function errore(nome_form,lungh_ta){
var lungh=nome_form.value.length;
if(lungh >(lungh_ta-1)) {
	alert('Attenzione: e\' stato raggiunto il limite dei caratteri da inserire:');//'

	nome_form.value=nome_form.value.substr(0,lungh_ta-1);
	return false;
}
return true;
}

function showMenu(varname,_v)
{
var isIE=document.all?true:false;
var isNS4=document.layers?true:false;
var isNS6=!isIE&&document.getElementById?true:false;
var h = "hidden"; 
var v = "visible"; 

  if(isIE)
    window.document.all.varname.style.visibility = _v?v:h;
  if(isNS6)
    document.getElementById(varname).style.visibility=_v?v:h;
  if(isNS4)
  {
    alert("This script will not run for NS4 because this DIV is positioned relatively and not absolutely!");
	/*
	 * This code would run if the DIV was positioned absolutely.
     * document.varname.hidden=_v?"true":"false";
	 */
  }
}


function controllaDateAnno(datamin,nomedatamin,datamax,nomedatamax,operatore) {
	tmp = new String(document.forms[0].SYSDATE.value);
	oggi = new Date(tmp.substr(6,4), eval(eval(tmp.substr(3,2))-1), tmp.substr(0,2));	
	var datamin_p=datamax_p='';
	if (document.forms[0].elements[datamax+'D']){
		datamax_p=document.forms[0].elements[datamax+'D'].value+'/'+document.forms[0].elements[datamax+'M'].value+'/'+document.forms[0].elements[datamax+'Y'].value;
		datamax = new Date(document.forms[0].elements[datamax+'Y'].value,eval(eval(document.forms[0].elements[datamax+'M'].value)-1),document.forms[0].elements[datamax+'D'].value);
	}else if (document.forms[0].elements[datamax]){
		//alert (document.forms[0].elements[datamax].value.substr(6,4)+'-'+eval(eval(document.forms[0].elements[datamax].value.substr(3,2))-1)+'-'+document.forms[0].elements[datamax].value.substr(0,2));
		datamax_p=document.forms[0].elements[datamax].value;
		datamax = new Date(document.forms[0].elements[datamax].value.substr(6,4),eval(eval(document.forms[0].elements[datamax].value.substr(3,2))-1),document.forms[0].elements[datamax].value.substr(0,2));
	}
	if (document.forms[0].elements[datamin+'D']){
		datamin_p=document.forms[0].elements[datamin+'D'].value+'/'+document.forms[0].elements[datamin+'M'].value+'/'+document.forms[0].elements[datamin+'Y'].value;
		datamin = new Date(document.forms[0].elements[datamin+'Y'].value,eval(eval(document.forms[0].elements[datamin+'M'].value)-1),document.forms[0].elements[datamin+'D'].value);
	}else if (document.forms[0].elements[datamin]){
		//alert (document.forms[0].elements[datamin].value.substr(6,4)+'-'+document.forms[0].elements[datamin].value.substr(3,2)+'-'+document.forms[0].elements[datamin].value.substr(0,2));
		datamin_p=document.forms[0].elements[datamin].value;
		datamin = new Date(document.forms[0].elements[datamin].value.substr(6,4),eval(eval(document.forms[0].elements[datamin].value.substr(3,2))-1),document.forms[0].elements[datamin].value.substr(0,2));
	}
	//alert (datamin+'+'+datamax+'-'+datamin_p+'+'+datamax_p+'+'+oggi);
	if (datamax>=oggi) {
		alert (nomedatamax+' '+datamax_p+' is not consistent with today date, please check');
		//document.forms[0].elements[datamax+'D'].focus();
		return false;	
	}
	
	if (datamin>oggi) {
		alert (nomedatamin+' '+datamin_p+' is not consistent with today date, please check');
		//document.forms[0].elements[datamin+'D'].focus();
		return false;	
	}
	
	if (datamin >= datamax) {
		alert (nomedatamax+' '+datamax_p+' is not consistent with '+nomedatamin+' '+datamin_p+', please check');
		//document.forms[0].elements[datamin+'D'].focus();
		return false;	
	}
	//var datamin = new Date(document.forms[0].elements['DOBY'].value,eval(eval(document.forms[0].elements['DOBM'].value)-1),document.forms[0].elements['DOBD'].value);
	//var y = document.forms[0].elements[datamax+'Y'].value;
	//var m = document.forms[0].elements[datamax+'M'].value;
	//var d = document.forms[0].elements[datamax+'D'].value;
	//var etaminima = new Date((y-18), (m-1), d);
	//
	//if (datamin<=etaminima){
	//	alert ('The patient must be less than 18 years old');	
	//	document.forms[0].elements[nomedatamin+'D'].focus();
	//	return false;
	//}
	
	return true;
}

function sbianca_radio_checkbox() {
	for (k=0;k<document.forms.length;k++){
	var f=document.forms[k];
	var el=f.elements;
	var eln=el.length;
	var vet_pass=new Array();
//      alert("somo qui");
		for (i=0;i<eln;i++) {
		nome=el[i].name;
		tipo=el[i].type;
                // alert(nome+' '+tipo+' ');
			if (tipo=='radio'){
				if (!radiovalue(nome,k) && radiovalue(nome,k)!='0'){
					for (ii=0;ii<eln;ii++) {
						nome1=el[ii].name;
						tipo1=el[ii].type;
						if (tipo1=='hidden' && nome1=='' && el[i].name!='' && vet_pass[nome] != '1'){
							el[ii].name=nome;
							el[i].name='dummy';
							vet_pass[nome]=1;
						}
					}
				}
			}
			if (tipo=='checkbox'){
				if (!el[nome].checked){
					for (ii=0;ii<eln;ii++) {
						nome1=el[ii].name;
						tipo1=el[ii].type;
						if (tipo1=='hidden' && nome1=='' && el[i].name!='' && vet_pass[nome] != '1'){
							el[ii].name=nome;
							el[i].name='dummy';
							vet_pass[nome]=1;
						}
					}
				}
			}
		}
	}
}

function Mostra(sezione){
 document.getElementById(sezione).style.display="";
}
function Nascondi(sezione){
 document.getElementById(sezione).style.display="none";
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function sbianca_sel_reg(campo,confronto,inizio,fine){
	for(ii=1;ii<el[campo].length;ii++){
		//alert(el[campo][ii].value);
	}
return 0;
}

function precompila_resistenza(nomecontrollo){
	if (window.opener.document.forms[0].elements['MR'+nomecontrollo].value!=''){
	arr=window.opener.document.forms[0].elements['MR'+nomecontrollo].value.split(', ');
	len=arr.length;
	for (i=0;i<len;i++){
		nomefield='c'+arr[i];
		if (document.forms[0].elements[nomefield]) document.forms[0].elements[nomefield].checked=true;
	}
}
}

function compila_resistenza(nomecontrollo){
	field=document.forms[0].length-2;
	first=true;
	string=string_js=string_s=new String('');
	for (i=0;i<=field;i++) {
	if (document.forms[0][i].checked){
		if (first) {
			string=document.forms[0][i].value;
			first=false;
		}
		else {
			string+=', '+document.forms[0][i].value;
			}
		}
	}
	
f=document.forms[0];
el=f.elements;
specifiche='A=ON&L=0&F=0';

	window.opener.document.forms[0].elements['MR'+nomecontrollo].value=string;
	window.close();
}	


function precompila_resistenza_sw(nomecontrollo){
	if (window.opener.document.forms[0].elements['IS_'+nomecontrollo].value!=''){
	arr=window.opener.document.forms[0].elements['IS_'+nomecontrollo].value.split(', ');
	len=arr.length;
	for (i=0;i<len;i++){
		arr2=arr[i].split('#');
		//nomefield='c'+arr[i];
		nomefield='c'+arr2[0];
		//alert (nomefield);
		if (document.forms[0].elements[nomefield]) document.forms[0].elements[nomefield].checked=true;
		
		arr3=arr2[1].split('|');
		
		nomefield='s'+arr2[0];
		//alert (nomefield+'-'+arr3[0]);
		if (arr3[0]!='' && document.forms[0].elements[nomefield]) document.forms[0].elements[nomefield][arr3[0]].selected=true;
		
		nomefield='f'+arr2[0];
		if (arr3[1] && document.forms[0].elements[nomefield]){
		//alert (arr3[1] +'-'+ document.forms[0].elements[nomefield]);
			for (ii=0;ii<document.forms[0].elements[nomefield].length;ii++){
				if (document.forms[0].elements[nomefield][ii].value==arr3[1]){
					document.forms[0].elements[nomefield][ii].selected=true;
				}
			}
		}
	}
}
}

function compila_resistenza_sw(nomecontrollo){
	field=document.forms[0].length-2;
	first=true;
	string=string_js=string_s=new String('');
	for (i=0;i<=field;i++) {
	if (document.forms[0][i].checked){
		if (first) {
			string=document.forms[0][i].value;
			string_s=document.forms[0][i].value+'#'+document.forms[0][i+1][document.forms[0][i+1].selectedIndex].value+'|'+document.forms[0][i-1][document.forms[0][i-1].selectedIndex].value;
			//string_js='<<si###'+document.forms[0][i+1].name+'###Interpretazioni software '+document.forms[0][i+1].name+'>>';
			first=false;
		}
		else {
			string+=', '+document.forms[0][i].value;
			string_s+=', '+document.forms[0][i].value+'#'+document.forms[0][i+1][document.forms[0][i+1].selectedIndex].value+'|'+document.forms[0][i-1][document.forms[0][i-1].selectedIndex].value;
			
			//string_js+='<<si###'+document.forms[0][i+1].name+'###Interpretazioni software '+document.forms[0][i+1].name+'>>';
			}
		}
	}
	
f=document.forms[0];
el=f.elements;
specifiche='A=ON&L=0&F=0';

	window.opener.document.forms[0].elements['D_IS'+nomecontrollo].value=string;
	window.opener.document.forms[0].elements['IS_'+nomecontrollo].value=string_s;
	//alert (string);
	//alert (string_s);
	//alert (string_js);
	window.close();
}	



function valorizza_sel_user(sorgente,destinazione){
	if (document.forms[0].elements[sorgente] && document.forms[0].elements[destinazione]){
	 //alert(document.forms[0].elements[destinazione].selectedIndex);
	 if (!document.forms[0].elements[destinazione].selectedIndex){
		for(ii=1;ii<document.forms[0].elements[destinazione].length;ii++){
			//alert (document.forms[0].elements[sorgente].value+'-'+document.forms[0].elements[destinazione][ii].value);
			if (document.forms[0].elements[sorgente].value==document.forms[0].elements[destinazione][ii].value){
				document.forms[0].elements[destinazione][ii].selected=true;
				//next;
			}
		}
	 }
	}
return 0;
}

function valorizza_text_user(sorgente,destinazione){
	if (document.forms[0].elements[sorgente] && document.forms[0].elements[destinazione]){
		if (document.forms[0].elements[destinazione].value==''){
				document.forms[0].elements[destinazione].value=document.forms[0].elements[sorgente].value;
			}
		}
return 0;
}


function sbianca_province(sorgente,destinazione,passato,nomeform,stringavuota) {
  if (!nomeform){nomeform='0'}
  chiamante=document.forms[nomeform];
  elementi_chiamante=chiamante.elements;

  	var i,j,k;
  	if (!passato){
  		//var vettV=new Array();
  		//var vettT=new Array();
  		for (i=0;i<elementi_chiamante[destinazione].options.length;i++){
  			vettV[i]=elementi_chiamante[destinazione][i].value;
  			vettT[i]=elementi_chiamante[destinazione][i].text;
  			vettVdim=i;
  		}
  	}		
  		//Inizio Parte aggiunta da testare
  		elementi_chiamante[destinazione].options.length=1;
  		j=1;
  		for (k=0;k<vettVdim;k++){
  			if (vettV[k] && vettT[k] && elementi_chiamante[sorgente][elementi_chiamante[sorgente].selectedIndex].value==vettV[k].substr(0,2)){
  				elementi_chiamante[destinazione].options.length++;
  				elementi_chiamante[destinazione][j].value=vettV[k];
					elementi_chiamante[destinazione][j].text=vettT[k];
					j++; 			
  			}
		}
		//Fine Parte aggiunta da testare
  return 0;
}



function controlla_d1_d2(d1,d2,msg)
{
 D1 = new Date(d1.substr(4,4), eval(eval(d1.substr(2,2))-1), d1.substr(0,2));	
 D2 = new Date(d2.substr(4,4), eval(eval(d2.substr(2,2))-1), d2.substr(0,2));	
 //alert (d1+'-'+d2);
 if (d1 =='' || d2 =='' || D2>=D1)
  {
    return true;
  }
 if (msg) alert(msg);
 return false;	
}

