

	function move(from,to)
	{
		var elForm
		if(move.arguments.length>2)
		{
			elForm = document.forms[move.arguments[2]]
		}
		else
		{
			elForm = document.forms[0]
		}
		var selezionati = new Array()
		sel1 = elForm.elements[from]
		sel2 = elForm.elements[to]
		j=0
		sel=new Array();
		for ( i =1; i < sel1.options.length;i++)
		{
			if(sel1.options[i].selected) 
			{
				if(!checkExist(sel2,sel1.options[i].value)) 
				{
					sel2.options[sel2.options.length]=new Option(sel1.options[i].text,sel1.options[i].value)
					sel2.options[sel2.options.length-1].className=sel1.options[i].className;
				}
				sel[j]=i
				j=j+1
			}
		}
		i=0
		for(j=0;j<sel.length;j++)
		{
			sel1.options[sel[j]-i]=null
			i=i+1
		}
	}
	
	function checkExist(to,tvalue)
	{
		for(ic=1;ic<to.options.length;ic++)
		{
			if(to.options[ic].value==tvalue){
				return true;
			}
		}
		
	  return false	
	}
	
	function getIdSel(objSel,tvalue)
	{
		for(ic=1;ic<objSel.options.length;ic++)
		{
			if(objSel.options[ic].value==tvalue){
				return ic;
			}
		}
		
	  return -1;	
	}

	
	function check(to)
	{
		var elForm
		if(check.arguments.length>1)
		{
			elForm = document.forms[check.arguments[1]]
		}
		else
		{
			elForm = document.forms[0]
		}
		sel2 = elForm.elements[to]
		if(sel2.options.length>=2)
		{
			for(i=1;i<sel2.options.length;i++)
			{
				sel2.options[i].selected=true;
			}
		
		}
	}


function checkData()
{
	var elForm
	if(checkData.arguments.length>0)
	{
		
		elForm = document.forms[checkData.arguments[0]]
		
	}
	else
	{
		elForm = document.forms[0]
	}
	 
	
	var valore_alt=""
	
	for(i=0;i<obbligatoriText.length;i++)
	{
		
		
		if(elForm.elements[obbligatoriText[i]])
		{
			
			if(obbligatoriTextAlt)
			{
				nome_campo_alt=obbligatoriTextAlt[i]
			}
			else
			{
				nome_campo_alt=""
			}
			
			//verifico se esiste il campo indicato come alternativo
			if(elForm.elements[nome_campo_alt])
			{				
				objAlt=elForm.elements[nome_campo_alt]
				valore_alt=elForm.elements[nome_campo_alt].value
				if(obbligatoriTextAlt)
				{
					etichetta_alt=obbligatoriNameTextAlt[i]
					tipo_alt=obbligatoriTypeTextAlt[i]				
				}
				else
				{
					etichetta_alt=obbligatoriNameText[i]
					tipo_alt=obbligatoriTypeText[i]				
				}
				
			}
			else if(elForm.elements[nome_campo_alt+"_g"] && elForm.elements[nome_campo_alt+"_m"] && elForm.elements[nome_campo_alt+"_a"])	
			{
					objAlt=elForm.elements[nome_campo_alt+"_g"]
					if(elForm.elements[nome_campo_alt+"_g"].value!="" && elForm.elements[nome_campo_alt+"_m"].value!="" && elForm.elements[nome_campo_alt+"_a"].value!="")
					{			
						valore_alt=elForm.elements[nome_campo_alt+"_g"].value+"/"+elForm.elements[nome_campo_alt+"_m"].value+"/"+elForm.elements[nome_campo_alt+"_a"].value
					}
					else
					{
						valore_alt=""
					}
					if(obbligatoriTextAlt)
					{
						etichetta_alt=obbligatoriNameTextAlt[i]
						tipo_alt=obbligatoriTypeTextAlt[i]				
					}
					else
					{
						etichetta_alt=obbligatoriNameText[i]
						tipo_alt=obbligatoriTypeText[i]				
					}
			}
			else
			{
				objAlt=elForm.elements[obbligatoriText[i]]
				valore_alt=elForm.elements[obbligatoriText[i]].value
				etichetta_alt=obbligatoriNameText[i]
				tipo_alt=obbligatoriTypeText[i]
			}
			
			
			if(elForm.elements[obbligatoriText[i]].value == "" && valore_alt=="")
			{
				
				if(nome_campo_alt!=="")
				{
					stringaErrore =	"E' obbligatorio specificare un valore per il campo "+obbligatoriNameText[i]+"\no per il campo  "+obbligatoriNameTextAlt[i]+"!" 
				}
				else
				{
					stringaErrore =	"Il campo "+obbligatoriNameText[i]+" è obbligatorio!" 
				}
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]].focus();
				elForm.elements[obbligatoriText[i]].select();
				return false;
			}	
			
			if ((obbligatoriTypeText[i] == "number")  && (!isNumber(elForm.elements[obbligatoriText[i]].value))) 
			{
				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere numerico!" 
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]].focus();
				elForm.elements[obbligatoriText[i]].select();
				return false;
			}
			if(valore_alt!="")
			{
				if ((tipo_alt == "number")  && (!isNumber(valore_alt))) 
				{
					var stringaErrore =	"Il valore di "+etichetta_alt+" deve essere numerico!" 
					alert(stringaErrore);
					objAlt.focus();
					objAlt.select();
					return false;
				}
			}
			if ((obbligatoriTypeText[i] == "numbernegative")  && (!isNumberNegative(elForm.elements[obbligatoriText[i]].value))) 
			{
				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere numerico!" 
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]].focus();
				elForm.elements[obbligatoriText[i]].select();
				return false;
			}
			if(valore_alt!="")
			{
				if ((tipo_alt == "numbernegative")  && (!isNumberNegative(valore_alt))) 
				{
					var stringaErrore =	"Il valore di "+etichetta_alt+" deve essere numerico!" 
					alert(stringaErrore);
					objAlt.focus();
					objAlt.select();
					return false;
				}
			}
			
			if ((obbligatoriTypeText[i] == "ip")  && (!isValidIP(elForm.elements[obbligatoriText[i]].value))) 
			{
				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere un indirizzo IP!" 
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]].focus();
				elForm.elements[obbligatoriText[i]].select();
				return false;
			}
			if(valore_alt!="")
			{
				if ((tipo_alt == "ip")  && (!isValidIP(valore_alt))) 
				{
					var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere un indirizzo IP!" 
					alert(stringaErrore);
					elForm.elements[obbligatoriText[i]].focus();
					elForm.elements[obbligatoriText[i]].select();
					return false;
				}
			}	
		
			if ((obbligatoriTypeText[i] == "pwd")  && (!pwdlen(elForm.elements[obbligatoriText[i]].value))) 
			{

					var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve contenere almeno 6 caratteri!" 
					alert(stringaErrore);	
					elForm.elements[obbligatoriText[i]].focus();
					elForm.elements[obbligatoriText[i]].select();
					return false;
					
			}
			if(valore_alt!="")
			{
				if ((tipo_alt == "pwd")  && (!pwdlen(valore_alt))) 
				{
					var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+"deve contenere almeno 6 caratteri!" 
					alert(stringaErrore);
					elForm.elements[obbligatoriText[i]].focus();
					elForm.elements[obbligatoriText[i]].select();
					return false;
				}
			}	
			
			if ((obbligatoriTypeText[i] == "email") && (! isEmail(elForm.elements[obbligatoriText[i]].value))) 
			{
				elForm.elements[obbligatoriText[i]].focus();
				elForm.elements[obbligatoriText[i]].select();
				return false;
			}
			if(valore_alt!="")
			{
				if ((tipo_alt == "email") && (! isEmail(valore_alt))) 
				{
					objAlt.focus();
					objAlt.select();
					return false;
				}
			}
			
			if ((obbligatoriTypeText[i] == "string") && (! isAlphabetic(elForm.elements[obbligatoriText[i]].value))) 
			{
				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere alfabetico!" 
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]].focus();
				elForm.elements[obbligatoriText[i]].select();
				return false;
			}
			
			if(valore_alt!="")
			{
				if ((tipo_alt == "string") && (! isAlphabetic(valore_alt))) 
				{
					var stringaErrore =	"Il valore di "+etichetta_alt+" deve essere alfabetico!" 
					alert(stringaErrore);
					objAlt.focus();
					objAlt.select();
					return false;
				}
			}
		}
		
		if ((obbligatoriTypeText[i] == "data") && elForm.elements[obbligatoriText[i]+"_g"]) 
		{
			if(elForm.elements[obbligatoriText[i]+"_g"].options)
			{
				giorno=elForm.elements[obbligatoriText[i]+"_g"].options[elForm.elements[obbligatoriText[i]+"_g"].selectedIndex].value
					
				mese=parseInt(elForm.elements[obbligatoriText[i]+"_m"].options[elForm.elements[obbligatoriText[i]+"_m"].selectedIndex].value) - 1
				anno=elForm.elements[obbligatoriText[i]+"_a"].options[elForm.elements[obbligatoriText[i]+"_a"].selectedIndex].value
			}
			else
			{
				giorno=elForm.elements[obbligatoriText[i]+"_g"].value
				mese=parseInt(elForm.elements[obbligatoriText[i]+"_m"].value)-1
				anno=elForm.elements[obbligatoriText[i]+"_a"].value
			}
			data_eff=new Date(anno,mese,giorno)
			giorno_eff=data_eff.getDate()
			mese_eff=data_eff.getMonth()
			anno_eff=data_eff.getFullYear()
			if(giorno_eff!=parseInt(giorno) || mese_eff != parseInt(mese) || anno_eff != parseInt(anno))
			{
				var stringaErrore =	"La data indicata in " +obbligatoriNameText[i] + " deve essere di formato valido!\n"+
									"Il " + giorno + "/"+(mese+1)+"/"+anno+" non esiste."
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]+"_g"].focus();			
				return false;
			}			 
				
		}
		
		if ((obbligatoriTypeText[i] == "data") && elForm.elements[obbligatoriText[i]+"_g"]) 
		{
			if(elForm.elements[obbligatoriText[i]+"_g"].options)
			{
				giorno=elForm.elements[obbligatoriText[i]+"_g"].options[elForm.elements[obbligatoriText[i]+"_g"].selectedIndex].value
					
				mese=parseInt(elForm.elements[obbligatoriText[i]+"_m"].options[elForm.elements[obbligatoriText[i]+"_m"].selectedIndex].value) - 1
				anno=elForm.elements[obbligatoriText[i]+"_a"].options[elForm.elements[obbligatoriText[i]+"_a"].selectedIndex].value
			}
			else
			{
				giorno=elForm.elements[obbligatoriText[i]+"_g"].value
				mese=parseInt(elForm.elements[obbligatoriText[i]+"_m"].value)-1
				anno=elForm.elements[obbligatoriText[i]+"_a"].value
			}
			data_eff=new Date(anno,mese,giorno)
			giorno_eff=data_eff.getDate()
			mese_eff=data_eff.getMonth()
			anno_eff=data_eff.getFullYear()
			if(giorno_eff!=parseInt(giorno) || mese_eff != parseInt(mese) || anno_eff != parseInt(anno))
			{
				var stringaErrore =	"La data indicata in " +obbligatoriNameText[i] + " deve essere di formato valido!\n"+
									"Il " + giorno + "/"+(mese+1)+"/"+anno+" non esiste."
				alert(stringaErrore);
				elForm.elements[obbligatoriText[i]+"_g"].focus();			
				return false;
			}			 
				
		}
		
		//controllo di tipo data per il campo alternativo, a condizione che ci sia
		if(obbligatoriTypeTextAlt && valore_alt!="")
		{
			if(obbligatoriTypeTextAlt.length>i)
			{
				if(obbligatoriTypeTextAlt[i]== "data" && elForm.elements[obbligatoriTextAlt[i]+"_g"])
				{
					if(elForm.elements[obbligatoriTextAlt[i]+"_g"].options)
					{
						giorno=elForm.elements[obbligatoriTextAlt[i]+"_g"].options[elForm.elements[obbligatoriTextAlt[i]+"_g"].selectedIndex].value
							
						mese=parseInt(elForm.elements[obbligatoriTextAlt[i]+"_m"].options[elForm.elements[obbligatoriTextAlt[i]+"_m"].selectedIndex].value) - 1
						anno=elForm.elements[obbligatoriTextAlt[i]+"_a"].options[elForm.elements[obbligatoriTextAlt[i]+"_a"].selectedIndex].value
					}
					else
					{
						giorno=elForm.elements[obbligatoriTextAlt[i]+"_g"].value
						mese=parseInt(elForm.elements[obbligatoriTextAlt[i]+"_m"].value)-1
						anno=elForm.elements[obbligatoriTextAlt[i]+"_a"].value
					}
					data_eff=new Date(anno,mese,giorno)
					giorno_eff=data_eff.getDate()
					mese_eff=data_eff.getMonth()
					anno_eff=data_eff.getFullYear()
					if(giorno_eff!=parseInt(giorno) || mese_eff != parseInt(mese) || anno_eff != parseInt(anno))
					{
						var stringaErrore =	"La data indicata in " +obbligatoriNameTextAlt[i] + " deve essere di formato valido!\n"+
											"Il " + giorno + "/"+(mese+1)+"/"+anno+" non esiste."
						alert(stringaErrore);
						elForm.elements[obbligatoriTextAlt[i]+"_g"].focus();			
						return false;
					}		
				}
			}
		}
		
	}
	for(i=0;i<valoriObbligatori.length;i++)
	{
		if(elForm.elements[valoriObbligatori[i]])
		{

			if(elForm.elements[valoriObbligatori[i]].value != "")
			{
				
		
				if ((valoriObbligatoriType[i] == "number")  && (isNaN(elForm.elements[valoriObbligatori[i]].value))) 
				{
					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere numerico!" 
					alert(stringaErrore);
					elForm.elements[valoriObbligatori[i]].focus();
					elForm.elements[valoriObbligatori[i]].select();
					return false;
				}
				if ((valoriObbligatoriType[i] == "numbernegative")  && (!isNumberNegative(elForm.elements[valoriObbligatori[i]].value))) 
				{
					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere numerico!" 
					alert(stringaErrore);
					elForm.elements[valoriObbligatori[i]].focus();
					elForm.elements[valoriObbligatori[i]].select();
					return false;
				}
				
				if ((valoriObbligatoriType[i] == "ip")  && (!isValidIP(elForm.elements[valoriObbligatori[i]].value))) 
				{
					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere un indirizzo IP!" 
					alert(stringaErrore);
					elForm.elements[valoriObbligatori[i]].focus();
					elForm.elements[valoriObbligatori[i]].select();
					return false;
				}
				if ((valoriObbligatoriType[i] == "pwd")  && (!pwdlen(elForm.elements[valoriObbligatori[i]].value))) 
				{
					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve contenere almeno 6 caratteri!" 
					alert(stringaErrore);	
					elForm.elements[valoriObbligatori[i]].focus();
					elForm.elements[valoriObbligatori[i]].select();
					return false;
				}

				if ((valoriObbligatoriType[i] == "email") && (! isEmail(elForm.elements[valoriObbligatori[i]].value))) 
				{
					elForm.elements[valoriObbligatori[i]].focus();
					elForm.elements[valoriObbligatori[i]].select();
					return false;
				}
				if ((valoriObbligatoriType[i] == "string") && (! isAlphabetic(elForm.elements[valoriObbligatori[i]].value))) 
				{
					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere alfabetico!" 
					alert(stringaErrore);
					elForm.elements[valoriObbligatori[i]].focus();
					elForm.elements[valoriObbligatori[i]].select();
					return false;
				}
			}
		}
		if ((valoriObbligatoriType[i] == "data")) 
		{
			if(elForm.elements[valoriObbligatori[i]+"_g"])
			{
				if(elForm.elements[valoriObbligatori[i]+"_g"].options)
				{
					giorno=elForm.elements[valoriObbligatori[i]+"_g"].options[elForm.elements[valoriObbligatori[i]+"_g"].selectedIndex].value
							
					mese=parseInt(elForm.elements[valoriObbligatori[i]+"_m"].options[elForm.elements[valoriObbligatori[i]+"_m"].selectedIndex].value) - 1
					anno=elForm.elements[valoriObbligatori[i]+"_a"].options[elForm.elements[valoriObbligatori[i]+"_a"].selectedIndex].value
				}
				else
				{
					giorno=elForm.elements[valoriObbligatori[i]+"_g"].value
					mese=parseInt(elForm.elements[valoriObbligatori[i]+"_m"].value)-1
					anno=elForm.elements[valoriObbligatori[i]+"_a"].value
				}
				data_eff=new Date(anno,mese,giorno)
				giorno_eff=data_eff.getDate()
				mese_eff=data_eff.getMonth()
				anno_eff=data_eff.getFullYear()
				if(giorno!='' && mese!=0 && anno != '')
				{
					if(giorno_eff!=parseInt(giorno) || mese_eff != parseInt(mese) || anno_eff != parseInt(anno))
					{
						var stringaErrore =	"La data indicata in " +valoriObbligatoriName[i] + " deve essere di formato valido!\n"+
											"Il " + giorno + "/"+(mese+1)+"/"+anno+" non esiste."
						alert(stringaErrore);
						elForm.elements[valoriObbligatori[i]+"_g"].focus();			
						return false;
					}
				}
			}					 
					
		}
	}
	for(i=0;i<obbligatoriSelect.length;i++)
	{
		sel=elForm.elements[obbligatoriSelect[i]]
		
		if(sel && !sel.disabled)
		{
			if(sel.options)
			{

				if(sel.selectedIndex==-1)
				{
					alert("Il valore di "+ obbligatoriNameSelect[i] + " è obbligatorio!!!!")
					sel.focus();
					return false;
				}
				else
				{

					if(sel.options[sel.selectedIndex].value=="") 
					{
						alert("Il valore di "+ obbligatoriNameSelect[i] + " è obbligatorio!")
						sel.focus();
						return false;
					}
				}
			}
		}
	}
	//alert("tutto ok")
	return true;
}


function isAlphabetic(string)
{
	if(string == "")
	{
		return true;
	}

	for (k=0;k<parseInt(string.length);k++)
	{
		if ((string.charAt(k) < "9" && string.charAt(k) > "0"))
		{
			return false;
		}
	}

	return true;
}

function isNumber(number)
{
	if(number == "")
	{
		return true;
	}
	if(number.charAt(0)==".")
	{ 
		return false;
	}
	for (s=0;s<parseInt(number.length);s++)
	{
		if ((number.charAt(s) > "9" || number.charAt(s) < "0") && number.charAt(s)!=".")
		{
			return false;
		}
	}

	return true;
}

function isNumberGeneral(number)
{
	if(number == "")
	{
		return true;
	}
	if(number.charAt(0)==".")
	{ 
		return false;
	}
	for (s=0;s<parseInt(number.length);s++)
	{
		if ((number.charAt(s) > "9" || number.charAt(s) < "0") && (number.charAt(s)!="."))
		{
			return false;
		}
	}

	return true;
}

function isNumberNegative(number)
{
	if(number == "")
	{
		return true;
	}
	if(number.charAt(0)==".")
	{ 
		return false;
	}
	if(number.charAt(0)!="-" && !isNumber(number.charAt(0)))
	{ 
		return false;
	}
	for (s=1;s<parseInt(number.length);s++)
	{
		if ((number.charAt(s) > "9" || number.charAt(s) < "0") && (number.charAt(s)!=".") && (number.charAt(s)!=","))
		{
			
			return false;
		}
	}
	
	return true;
}
function pwdlen(pwd)
{
	if(pwd.length >= 6)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function isEmail(email)
{	
	emailValida = false
	if(email == "")
	{		
		return false;
	}
	indexOfAt = email.length + 10;
	for (j=0;j<parseInt(email.length) && !emailValida;j++)
	{
		if (email.charAt(j) == "@")
		{
			emailValida = true;
			indexOfAt = j
		}
	}
	
	if(emailValida) 
	{
		indexOfDot = email.lastIndexOf(".")
		
		if(indexOfDot <= (indexOfAt + 1))
		{
			
			emailValida = false;
		}
	}
	if(! emailValida)
	{
		
		alert("L'indirizzo di email non sembra corretto (controlla @ e .)")
	}
	return emailValida;
}

function isValidIP(IPvalue) {
	errorString = "";
	theName = "Indirizzo ip";
	
	var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var ipArray = IPvalue.match(ipPattern);
	
	if (IPvalue == "0.0.0.0")
	{
		errorString = errorString + theName + ': '+IPvalue+' è un indirizzo speciale e non può essere usato per queso campo.';
	}
	else if (IPvalue == "255.255.255.255")
	{
		errorString = errorString + theName + ': '+IPvalue+' è un indirizzo speciale e non può essere usato per queso campo.';
	}
	if (ipArray == null)
	{
		errorString = errorString + theName + ': '+IPvalue+' non è un indirizzo IP valido.';
	}
	else 
	{
		for (k = 0; k < 4; k++) {
			thisSegment = ipArray[k];
			if (thisSegment > 255) {
				errorString = errorString + theName + ': '+IPvalue+' non è un indirizzo IP valido.';
				k = 4;
			}
			if ((i == 0) && (thisSegment > 255)) {
				errorString = errorString + theName + ': '+IPvalue+' è un indirizzo speciale e non può essere usato per queso campo.';
				k = 4;
			}
		 }
	}
	extensionLength = 3;
	if (errorString == "")
	{
		return true;
	}
	else
	{
		alert (errorString);
		return false;
	}
}


function repl(str,car,cambio)
{
	appStr=""
	for(ck=0;ck<str.length;ck++)
	{
		if(str.charAt(ck)==car)
		{
			appStr+=cambio
		}
		else
		{
			appStr+=str.charAt(ck)
		}
	}
	return appStr;
}

function arrotonda(numero,cifre_dec)
{
	
	potenza=Math.pow(10,parseInt(cifre_dec))
		
	numero=Math.round(numero*potenza)/potenza
	
	return numero;
}


function arrotondaEuro(num)
{	num=String(num)
	if(num.length==0) 
	{
		return 0
	}
	else
	{
		appArrotondaEuro=""
		
		
		if ((num.indexOf(".")!=-1 && (num.indexOf(".")+4)<=num.length))
		{
			euro=parseInt(num.substr(num.indexOf(".")+3,1))
			
			if (euro>=5)
			{
				
				
				valore=(Math.round(parseFloat(num.substr(0,num.indexOf(".")+3))*100) + 1)/100
				
			}
			else
			{
		
				valore=parseFloat(num.substr(0,num.indexOf(".")+3))
			}
			appArrotondaEuro=valore					
			
		}
		else
		{
			
			appArrotondaEuro=parseFloat(num)
		}
		appArrotondaEuro=String(appArrotondaEuro)
		
		if(appArrotondaEuro.indexOf(".")!=-1)
		{
			if(appArrotondaEuro.substr(appArrotondaEuro.indexOf(".")+1).length==1)
			{
				appArrotondaEuro=appArrotondaEuro+"0"
			}
		}
		else
		{
			appArrotondaEuro=appArrotondaEuro+".00"
		}
	}
	
	return appArrotondaEuro
}

function repl(str,car,cambio)
{
	appStr=""
	for(ck=0;ck<str.length;ck++)
	{
		if(str.charAt(ck)==car)
		{
			appStr+=cambio
		}
		else
		{
			appStr+=str.charAt(ck)
		}
	}
	return appStr;
}
function disabledForm(form){
	for(i=0;i<form.elements.length;i++)
		form.elements[i].disabled=true
}
function setEnabled()
{
	var a = setEnabled.arguments;
	theForm=document.forms[a[0]];
	for (i=1;i<a.length;i++)
	{
		theForm.elements[a[i]].disabled = false  
	}
}

function setDisabled()
{
	var a = setDisabled.arguments;
	theForm=document.forms[a[0]];

	for (i=1;i<a.length;i++)
	{
		
		theForm.elements[a[i]].disabled = true
	}
}

function setVoid()
{
	var a = arguments;
	theForm=document.forms[a[0]];
	for (i=1;i<a.length;i++)
	{
		theForm.elements[a[i]].value="";
	}
}
function setVID(id,value)
{
	el=document.all?document.all[id]:document.getElementById(id);
	el.innerHTML=value;
}
function doBlink() {
    var blink = document.all.tags("BLINK")
    for (var i=0; i<blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)
    setInterval("doBlink()",1000)
}

function setPagina(p) {
	
		document.lista.page.value = p
		document.lista.submit()

}

function setOrdine(o) 
{
	
		document.lista.order.value = o;
		document.lista.submit()

}
var fast=null

function fastWinOpen(url,w,h)
{
	l=(screen.width-w)/2
	t=(screen.height-h)/2
	params="scrollbars=yes,resizable=yes,width="+w+",height="+h+",left="+l+",top="+t
	if (fast) 
	{
		if(!fast.closed)
			{fast.close()}
	}
	fast=window.open(url,"",params)
	
}
//funzioni per moduli
function checkChild(id,un)
{
	var mods=document.scheda.elements["moduli[]"];
	
	for(i=0;i<mods.length;i++)
	{
		idParenti=document.scheda.elements["mod_"+mods[i].value].value;
		if(idParenti==id)
		{
			mods[i].checked=un;
		}
	}

}

function checkParent(id)
{
	var mods=document.scheda.elements["moduli[]"];
	
	for(i=0;i<mods.length;i++)
	{
		
		if(mods[i].value==id)
		{
			//alert(mods[i].value);
			mods[i].checked=true;
		}
	}

}
function checkTree(obj)
{
	//alert(obj.checked);
	if(obj.checked)
	{
		idParent=document.scheda.elements["mod_"+obj.value].value;
		if(idParent!=0)
		{
			//alert(idParent);
			checkParent(idParent);
			
		}
		checkChild(obj.value,true);
	}
	else
	{
		checkChild(obj.value,false);
	}
	
}
function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}

function isBoolean(a) {
    return typeof a == 'boolean';
}

function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}

function isFunction(a) {
    return typeof a == 'function';
}

function isNull(a) {
    return a === null;
}

function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
    return typeof a == 'string';
}

function isUndefined(a) {
    return typeof a == 'undefined';
} 

function getRadioValue(obj)
{
	valore="";
	for(i=0;i<obj.length;i++)
	{
		if(obj[i].checked)
		{
			valore = obj[i].value;
			break;
		}
	}
	return valore;
}
