var AggiungiPixel=0
var ua = window.navigator.userAgent
var msie = ua.indexOf ( "MSIE" )+4
msie = ua.substr(msie, 4)
if  (isNaN(msie))	//SE NON E' UN NUMERO SETTO LA VERSIONE AD UN VALORE MINORE DELLA VERSIONE CHE SERVE PER PROCEDERE
	msie="3"
if ( eval(msie) <= eval(6) ) 
	AggiungiPixel=30

//Serve per poter selezionare i nodi nelle funzioni anche se contengono apice e doppio apice
function ValoreNodoAttributo(xObj,Nodo)
{
	try
	{
		currNode = xObj.documentElement.selectSingleNode(Nodo);	
		return currNode.text;
	}
	catch(Exception1)
	{
	return "";
	}
}


function ControllaNumericoNoDecimali(){
	//If ((Chr(KeyCode) >= "0" And Chr(KeyCode) <= "9")) Or KeyCode = 8 Then
	var ris = String.fromCharCode(event.keyCode);
	if ((ris >= "0" && ris <= "9") || event.keyCode == 8) 
	{
	}
	else
	{
	  event.returnValue = false
	}  
}

function ControllaNumericoDecimali(testo){
	valore=document.form1.item(testo).value
	//If ((Chr(KeyCode) >= "0" And Chr(KeyCode) <= "9")) Or KeyCode = 8 Or KeyCode = 44 Then
	var ris = String.fromCharCode(event.keyCode);
	
	if (event.keyCode==44)
	{
		var r, re;
		var s = valore;
		re =/,/;
		r = s.search(',');			
		if (r==-1)
		{
		}
		else
		{
			event.returnValue = false
		}				
	}
	else
	{
		if ((ris >= "0" && ris <= "9") || event.keyCode == 8 || event.keyCode == 44)  
		{
		}
		else
		{
		  event.returnValue = false
		}  
	}
}

//Lorena 27 per problemi nei passaggi dati inserisco una funzione che sarą da inserire nei campi codice
//per evitare di mettere dei caratteri che darebbero problema nei passagi di dati
function ControllaCaratteriParticolari()
{
	//i caratteri per adesso esclusi sono:
	//	'	"	£	#	&	?	+
	if (event.keyCode==39  || event.keyCode==34 || event.keyCode==163 || event.keyCode==35 || event.keyCode==38 || event.keyCode==63 || event.keyCode==43)
		{
			event.returnValue = false						
		}
}

function ControllaNumericoDecimaliConNegativi(testo){
	valore=document.form1.item(testo).value
	//If ((Chr(KeyCode) >= "0" And Chr(KeyCode) <= "9")) Or KeyCode = 8 Or KeyCode = 44 Or KeyCode = 45 Then
	var ris = String.fromCharCode(event.keyCode);
	if (event.keyCode==44) //virgola (,)
	{
		var r, re;
		var s = valore;
		re =/,/;
		r = s.search(',');			
		if (r==-1)
		{
			if (Trim(valore)!="")
			{
			}
			else
			{
				event.returnValue = false
			}
		}
		else
		{
			event.returnValue = false
		}		
	}
	else
	{
		if (event.keyCode==45)	//meno (-)
		{	
			//solo se e' il primo carattere inserito
			if (Trim(valore)=="")
			{
			}
			else
			{
				var r, re;
				var s = valore;
				re =/-/i;
				r = s.search(re);			
				if (r==-1)
				{
					NVal=ris+s
					document.form1.item(testo).value=NVal
					event.returnValue = false
				}
				else
				{
					event.returnValue = false
				}
			}		
		}
		else
		{
			if ((ris >= "0" && ris <= "9") || event.keyCode == 8 || event.keyCode == 44 || event.keyCode == 45)  
			{
			}
			else
			{
			  event.returnValue = false
			}  
		}
	}
}

function CollegaPagina(NomePagina)
{	
	parent.Menu.document.body.style.cursor = "wait"
	parent.Menu.document.location.replace(NomePagina);
}

function ControllaNumericoX(carattere)
{
	//44= , 46= . 47= /
	var ris = String.fromCharCode(event.keyCode);
	if ((ris >= "0" && ris <= "9") || event.keyCode == 8 || event.keyCode == carattere) {
	}
	else
	  event.returnValue = false
}

function chiudi()
{
	window.close()
}

function disabilitamouse(){
return;
	//DISABILITA IL PULSANTE DESTRO DEL MOUSE
	function clickIE() {
		if (document.all) {
			return false;
		}
	}
	function clickNS(e) 
	{
		if (document.layers||(document.getElementById&&!document.all)) {
			if (e.which==2||e.which==3) {
				return false;
			}
		}
	}
	if (document.layers) 
	{
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=clickNS;
	}
	else
	{
		document.onmouseup=clickNS;document.oncontextmenu=clickIE;
	}

	document.oncontextmenu=new Function("return false")
	
}

//DISABILITA I TASTI BACKSPACE, ESC, F5, F6
//da richiamare nel onkeydown del body (di tutte le pagine)
function disabilitaTasti(){
	var ris = event.keyCode
	//  27 esc - 116 f5 - 117 f6- 122 f11
	if ((ris == 27) ||(ris == 116) ||(ris == 117) ||(ris == 122) ) {
		event.returnValue = false
		event.keyCode = 0 
	}
}

function PulisciCampiGenerica(){
	document.body.style.cursor = "wait"
	document.form1.submit();
}

function Trim(orgString){
  return LTrim(RTrim(orgString))
}

function LTrim(orgString){
  return orgString.replace(/^\s+/,'')
}

function RTrim(orgString){
  return orgString.replace(/\s+$/,'')
}
//______________________________________________________________________________________

function ControllaOre(campo){
	if (document.all.item(campo).value != ""){
		if (document.all.item(campo).value > 23){
			alert(CaricaMess("E11",document.form1.LinguaPagina.value))			
			document.all.item(campo).value=""
			document.all.item(campo).focus()
		}
	}
}
//______________________________________________________________________________________

function ControllaMinuti(campo){
	if (document.all.item(campo).value != ""){
		if (document.all.item(campo).value > 59){			
			alert(CaricaMess("E12",document.form1.LinguaPagina.value))		
			document.all.item(campo).value=""
			document.all.item(campo).focus()
		}
	}
}
//______________________________________________________________________________________

function caricamento(i)
{
	if (i==99)
		return
	k=i;
	if (k==8)
		{
			for (d=1;d<8;d++)
				document.getElementById(d).style.background="ffffff";//#
			k=1;
		}
	else
	{
		document.getElementById(i).style.background="#28457f";
		k++;
	}
	setTimeout("caricamento(k)",300);
}

function evidenziariga(nRiga,Colore)
{

//SELEZIONO O DESELEZIONO LA RIGA	
	
	if (document.getElementById(nRiga).style.backgroundColor=="#ffcc66")
		{
			document.getElementById(nRiga).style.backgroundColor=Colore
			var i;			
			//CANCELLAZIONE RIGHE DESELEZIONATE DALLA RIGHE DA CANCELLARE*******************
			vettorerighe2=""
			stringarighe=document.all.item("righedacancellare").value		
			vettorerighe=stringarighe.split(";")
			vettorerighe=vettorerighe.sort()
			contatore=vettorerighe.length
			for (i=0;i<contatore;i++)
				{
					if (vettorerighe[i]!=nRiga)
						{
							if (vettorerighe2==""){
								vettorerighe2=vettorerighe[i];
								}
							else
								vettorerighe2=vettorerighe2+";"+vettorerighe[i];
						}
				}
								
			document.all.item("righedacancellare").value=vettorerighe2
			//***************************************************************************
		}
	else
		{
			document.getElementById(nRiga).style.backgroundColor="#FFCC66"
			
			//MEMORIZAZIONE RIGHE SELEZIONATE**********************
			stringarighe=document.all.item("righedacancellare").value
			if (stringarighe=="")
				stringarighe=nRiga;
			else
				stringarighe=stringarighe +";"+ nRiga;			
			document.all.item("righedacancellare").value=stringarighe
			//****************************************************
		}
		

}

function FunTraduci(pagina,Orig)
{	
	pagina2=pagina+"?XML="+Orig
	var param = new Array(4);

	param[0] = pagina2;
	param[1] = 725;
	param[2] = 370;
	param[3] = Orig;
	//param[4] = Orig;
	
	
	var width = 700 
	var height = 340 
	
	var sFeatures;
	sFeatures = "dialogHeight:" + height +"px;"
	sFeatures += "dialogWidth:" + width +"px;"
	sFeatures += "status:no;scroll:no;center:yes;"
	
	//Finestra = window.open (pagina2,'Traduz','height=400,width=700,toolbar=no,location=no,directories=no,status=no,menubar=no,titlebar=yes,scrollbars=no,resizable=no,left=0,top=60');  
	valore = showModalDialog("SupportoModale.asp",param,sFeatures);

	
}

function FunTraduciPerStampe(pagina,Orig)
{	
	pagina2=pagina+"?XML="+Orig
	var param = new Array(4);

	param[0] = pagina2;
	param[1] = 705;
	param[2] = 370;
	param[3] = Orig;
	//param[4] = Orig;
	
	
	var width = 700 
	var height = 340 
	
	var sFeatures;
	sFeatures = "dialogHeight:" + height +"px;"
	sFeatures += "dialogWidth:" + width +"px;"
	sFeatures += "status:no;scroll:no;center:yes;"
	
	//Finestra = window.open (pagina2,'Traduz','height=400,width=700,toolbar=no,location=no,directories=no,status=no,menubar=no,titlebar=yes,scrollbars=no,resizable=no,left=0,top=60');  
	valore = showModalDialog("../SupportoModale.asp",param,sFeatures);
}

function ContaCaratteriKeyPress(campo,lunghezza)
{
 var testo = document.form1.item(campo).value
 if (testo.length >= lunghezza) 
	event.returnValue = false 
}

//Apre finestra del calendario
//parametri in ingresso
//nome delle 3 text che servono a formare la data
function ApriCalendario(gg,mm,aa)
	{	
	if (document.form1.item(gg).readOnly)
		return
	
	pagina2 = "Calendario.asp"
	var param = new Array(4);

	param[0] = pagina2
	param[1] = 185
	param[2] = 268
	param[3] = CaricaMess("E2010",document.form1.LinguaPagina.value)

	var width = param[1]
	var height = param[2]
	
	var sFeatures;
	sFeatures = "dialogHeight:" + height +"px;"
	sFeatures += "dialogWidth:" + width +"px;"
	sFeatures += "status:no;scroll:no;center:yes;"
	
	valore = showModalDialog("SupportoModale.asp",param,sFeatures);
			
	if (valore != undefined)
		{
		var vettData, strData;
		var strData = Trim(valore);
		vettData= strData.split("/");
		document.form1.item(gg).value=vettData[0]
		document.form1.item(mm).value=vettData[1]
		document.form1.item(aa).value=vettData[2]
		document.form1.item(aa).onblur()
		}
			
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function PulisciDate(txtGG,txtMM,txtAA)
{
if (document.form1.item(txtGG).readOnly!=true)
	{
		document.form1.item(txtGG).value = ""
		document.form1.item(txtMM).value = ""
		document.form1.item(txtAA).value = ""
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function PulisciDate(txtGG,txtMM,txtAA)
{
if (document.form1.item(txtGG).readOnly!=true)
	{
		document.form1.item(txtGG).value = ""
		document.form1.item(txtMM).value = ""
		document.form1.item(txtAA).value = ""
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function PulisciOra(txthh,txtmm)
{
if (document.form1.item(txthh).readOnly!=true)
	{
		document.form1.item(txthh).value = ""
		document.form1.item(txtmm).value = ""
	}
}

 
function SelezionatoSelect(NomeSelect)
	{
		valueSelected=""
		for (i=0;i<document.getElementsByName(Trim(NomeSelect)).length;i++)
		{
		 	if (document.getElementsByName(NomeSelect)[i].selected==true)
		 	{					
				valueSelected=document.getElementsByName(NomeSelect)[i].value									
			}
		}		
		return (valueSelected);					
	}
function ValoreSelezionatoOption(NomeOption)
	{
		valueSelected=""
		for (i=0;i<document.getElementsByName(Trim(NomeOption)).length;i++)
		{
		 	if (document.getElementsByName(NomeOption)[i].checked==true)
		 	{					
				valueSelected=document.getElementsByName(NomeOption)[i].value																		
			}
		}
		return (valueSelected);					
	}
		
function SelezionatoOption(NomeOption)
	{
		for (i=0;i<document.getElementsByName(Trim(NomeOption)).length;i++)
		{
		 	if (document.getElementsByName(NomeOption)[i].checked==true)
		 	{					
				return (true);									
			}
		}
		return (false);					
	}
	
function SelezionaOption(NomeOption,ValoreOption)
	{
		for (i=0;i<document.getElementsByName(Trim(NomeOption)).length;i++)
		{
		 if (Trim(document.getElementsByName(NomeOption)[i].value)==Trim(ValoreOption))
				{
					if (document.getElementsByName(NomeOption)[i].disabled!=true)	
						{
						if (document.getElementsByName(NomeOption)[i].checked!=true)					
							document.getElementsByName(NomeOption)[i].checked=true					
						}
				}
		}

	}

function VerificaOption(NomeOption,ValoreOption)
	{
		for (i=0;i<document.getElementsByName(Trim(NomeOption)).length;i++)
		{
		 if (Trim(document.getElementsByName(NomeOption)[i].value)==Trim(ValoreOption))
				{
						if (document.getElementsByName(NomeOption)[i].checked!=true)					
							return (false);					
						else
							return (true);						
				}
		}

	}	
function AbilitazioneOption(NomeOption,ValoreOption)
	{
		for (i=0;i<document.getElementsByName(Trim(NomeOption)).length;i++)
		{
		 if (Trim(document.getElementsByName(NomeOption)[i].value)==Trim(ValoreOption))
				{
						if (document.getElementsByName(NomeOption)[i].disabled!=true)					
							return (false);					
						else
							return (true);						
				}
		}

	}		
function SelezionaDeselezionaOption(NomeOption,ValoreOption)
	{
		fuoco=document.activeElement.id		
		for (i=0;i<document.getElementsByName(Trim(NomeOption)).length;i++)
		{
		 if (Trim(document.getElementsByName(NomeOption)[i].value)==Trim(ValoreOption))
				{
					if (document.getElementsByName(NomeOption)[i].disabled!=true)	
						{
							if (NomeOption.toUpperCase()!=fuoco.toUpperCase())
							{
								if (document.getElementsByName(NomeOption)[i].checked!=true)					
									document.getElementsByName(NomeOption)[i].checked=true
								else
									document.getElementsByName(NomeOption)[i].checked=false
							}					    
						}
				}
		}

	}
	
function evidenziaUnaSolariga(nRiga,Colore,coloreSelez)
{

//SELEZIONO O DESELEZIONO LA RIGA	
	if (document.getElementById(nRiga).style.backgroundColor==coloreSelez)
		{					
			ColoraRigheConStessoID(nRiga,document.all.item("VecchioColore").value)		
			document.all.item("righedacancellare").value=""
			document.all.item("VecchioColore").value=""
		}
	else
		{
			if (document.all.item("righedacancellare").value=="")
			{
				ColoraRigheConStessoID(nRiga,coloreSelez)	
				document.all.item("righedacancellare").value=nRiga
				document.all.item("VecchioColore").value=Colore
			}
			else
			{
				vecchiaRiga=document.all.item("righedacancellare").value
				ColoraRigheConStessoID(vecchiaRiga,document.all.item("VecchioColore").value)
				ColoraRigheConStessoID(nRiga,coloreSelez)	
				document.all.item("righedacancellare").value=nRiga
				document.all.item("VecchioColore").value=Colore		
			}
		}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//FUNZIONE CHE COLARA PIł RIGHE CON LO STESSO IDENTIFICATIVO
function ColoraRigheConStessoID(nRiga,Colore)
{
	var coll = document.all.item(nRiga);
	contatore=coll.length
	if (contatore>0)
	{
		for(i=0;i<contatore;i++)
		{
			coll(i).style.backgroundColor=Colore
		}
	}
	else
		document.getElementById(nRiga).style.backgroundColor=Colore
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function Verifica_Ore_Min(Arrivo_Da,txOre,txMin)
{
if (document.getElementById(txOre).value != "")
	{		
	if (document.getElementById(txOre).value == "0" || document.getElementById(txOre).value == "00")
		{
		document.getElementById(txOre).value=""
		}
	else
		{
		var testo = document.getElementById(txOre).value
		if (testo.length==1) 
			{
			document.getElementById(txOre).value="0" + document.getElementById(txOre).value
			}		
		if (document.getElementById(txMin).value != "")
		//si Ore, si Minuti
			{
			var testo1 = document.getElementById(txMin).value
			if (testo1.length==1) 
				{
				document.getElementById(txMin).value="0" + document.getElementById(txMin).value
				}
			}			
		}
	}
else
	{
		if (document.getElementById(txMin).value != "" && document.getElementById(txMin).value != "0" && document.getElementById(txMin).value != "00")
		//no Ore, si Minuti
			{
			if (Arrivo_Da == txMin)
				{
				alert(CaricaMess("E44" ,document.form1.LinguaPagina.value) + " " + CaricaMess("E45" ,document.form1.LinguaPagina.value))
				document.all.item(txOre).focus()
				}
			}
		else
			{
			document.getElementById(txOre).value =""
			document.getElementById(txMin).value =""
			}
	}
}


