<!--
var oAttrib=['id', 'name', 'value', '_label', '_type', '_req', '_min', '_max', '_ToUp', '_ToLow', '_FirstUp', '_Number', '_Integer', '_BadChar', '_oldVal'];
var attr;

function addbookmark()
{
	if(document.all)
	var imgFav = new Image();
	imgFav.src=bookmarkurl+'images/app.ico';
	window.external.AddFavorite(bookmarkurl,bookmarktitle);
}

function homepage()
{
	if(document.all)
	document.body.style.behavior='url(#default#homepage)';
	document.body.setHomePage(bookmarkurl); 
}

function fnOver()
{
	event.srcElement.style.cursor = 'hand';
}

function fnOut()
{
	event.srcElement.style.cursor = '';
}

function wOpen(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

function resizeToMax()
{
	window.resizeTo(screen.availWidth, screen.availHeight);
}

function validateForm(f)
{
	rds=document.getElementsByName('rd_consenso_privacy');
	for (var i=0;i<rds.length;i++)
	{
		if(rds[i].checked)
		{
			if(rds[i].value=='no') {
				alert('Per proseguire &egrave; necessario acconsentire\nal trattamento dei dati personali\nai sensi dell\'art. 23 D. Lgs 196/2003');
				return(false);
			}
		}
	}
	var as=0;
	for (var i=0;i<f.length;i++)
	{
		e=f.elements[i];
		if(!e.getAttribute('disabled') && !e.getAttribute('readonly'))
		{
			switch (e.type)
			{
				case 'checkbox' :
				{
					if(!chekChekBox(e))
					{
						return false;
					}
					break;
				}
				case 'radio' :
				{
					if(!chekRadioBox(e))
					{
						return false;
					}
					break;
				}
				case 'select-one' :
				{
					if(!chekComboBox(e))
					{
						return false;
					}
					break;
				}
				case 'text' :
				{
					if(!chekInput(e))
					{
						return false;
					}
					break;
				}
				case 'textarea' :
				{
					if(!chekInput(e))
					{
						return false;
					}
					break;
				}
			}
		}
	}
	return(extractCombo(f));
}

function chkBadFile(e)
{
	var v=e.value;
	if(v.lastIndexOf('.')<=0)
	{
		msgErr(e,'Seleziona un file con estensione valida.');
		return false;
	}
	var ext=v.substr(v.lastIndexOf('.')+1,v.length-v.lastIndexOf('.'));
	if((ext!='txt') && (ext!='doc'))
	{
		msgErr(e,'Tipo di file non consentito.\nInviare solo documenti in formato \'.doc\' o \'.txt\'.');
		return false;
	}
	return true;
}

function changeBadChar(e)
{
	var v=e.value;
	e.setAttribute('value',v.replace('\'','\'\''))
}

function checkBadChar(e)
{
	var v=e.value;
	for(j=0;j<v.length;j++)
	{
		// [",|,\,>,<]
		if( (v.charAt(j) == '"') || (v.charAt(j) == '|') || (v.charAt(j) == '\\') || (v.charAt(j) == '<') || (v.charAt(j) == '>'))
		{
			return false;
		}
	}
	return true;
}

function checkValidChar(v)
{
	for(j=0;j<v.length;j++)
	{
		// [a-z,A-Z,0-9,'-','_','.',' ','#','@','*']
		if( (v.charAt(j) < '0') || ((v.charAt(j) > '9') && (v.charAt(j) < 'A')) || ((v.charAt(j) > 'Z') && (v.charAt(j) < 'a')) || (v.charAt(j) > 'z') )
		{
      		if ( (v.charAt(j) != '-') && (v.charAt(j) != '_') && (v.charAt(j) != '.') && (v.charAt(j) != ' ') && (v.charAt(j) != '#') && (v.charAt(j) != '*') && (v.charAt(j) != '@') )
      		return false;
		}
	}
	return true;
}

function checkValidWinPathChar(v)
{
	for(j=0;j<v.length;j++)
	{
		// [a-z,A-Z,0-9,'-','_','.',' ','\','/',':']
		if( (v.charAt(j) < '0') || ((v.charAt(j) > '9') && (v.charAt(j) < 'A')) || ((v.charAt(j) > 'Z') && (v.charAt(j) < 'a')) || (v.charAt(j) > 'z') )
		{
      		if ( (v.charAt(j) != '-') && (v.charAt(j) != '_') && (v.charAt(j) != '.') && (v.charAt(j) != ' ') && (v.charAt(j) != '\\') && (v.charAt(j) != '/') && (v.charAt(j) != ':') )
      		return false;
		}
	}
	return true;
}

function chekChekBox(e)
{
	if(e.getAttribute(oAttrib[5])=='true')                                               //oAttrib[5]='_req'
	{
		if(!e.getAttribute('checked'))
		{
			msgErr(e,oAttrib[5]);
			return false;
		}
 	}
    return true;
}

function chekRadioBox(e)
{
	if(e.getAttribute(oAttrib[5])=='true')                                               //oAttrib[5]='_req'
	{
		rds=document.getElementsByName(e.name);
		for (var i=0;i<rds.length;i++)
		{
			if(rds[i].getAttribute('checked'))
			{
				return true;
			}
		}
		msgErr(e,oAttrib[5]);
		return false;
	}
	return true;
}

function chekComboBox(e)
{
	if(e.getAttribute(oAttrib[5])=='true')                                               //oAttrib[5]='_req'
	{
		if(e.options[e.selectedIndex].value.length==0)
		{
			msgErr(e,oAttrib[5]);
			return false;
		}
	}
	return true;
}

function chekInput(e)
{
	switch (e.getAttribute(oAttrib[4]))			//oAttrib[4]='_type'
	{
		case 'String' :
		{
			if(!checkBadChar(e))
			{
	           msgErr(e,oAttrib[13]);			//oAttrib[13]='_BadChar'
	           return false;
			}
			return(checkString(e));
			break;
		}
		case 'Number' :
		{
			return checkNumber(e);
			break;
		}
		case 'Date' :
		{
			return checkDate(e);
			break;
		}
		//case 'DateTime' :
		//{
			//return checkDateTime(e);
		//	break;
		//}
		//case 'Time' :
		//{
			//return checkTime(e);
		//	break;
		//}
		case 'Cap' :
		{
			return checkCap(e);
			break;
		}
		case 'Phone' :
		{
			return checkPhone(e);
			break;
		}
		case 'Mail' :
		{
			return checkMail(e);
			break;
		}
		case 'Url' :
		{
			return checkUrl(e);
			break;
		}
		case 'WinPath' :
		{
			return isWinPath(e);
			break;
		}
	}
	return true;
}

function checkString(e)
{
/*
alert('id='+e.id);
alert('req='+(e.getAttribute(oAttrib[5])=='true'));
alert('val='+e.getAttribute(oAttrib[2]));
alert('value='+e.value);
alert('value='+e.getAttribute('value'));
*/
	if(e.getAttribute(oAttrib[5])=='true')													//oAttrib[5]='_req'
	{
	   if(is_null(e.value))
	   {
	       msgErr(e,oAttrib[5]);
	       return(false);
	   }
    }

	if(e.value.length>0)                                                 //oAttrib[2]='_value'
	{
		if(e.getAttribute(oAttrib[6]).length>0)												//oAttrib[6]='_min'
		{
			if(TooSmall(e.value.length,e.getAttribute(oAttrib[6])))
			{
				msgErr(e,oAttrib[6]);
				return(false);
			}
		}

		if(e.getAttribute(oAttrib[7]).length>0)												//oAttrib[7]='_max'
		{
			if(TooLong(e.value.length,e.getAttribute(oAttrib[7])))
			{
				msgErr(e,oAttrib[7]);
				return(false);
			}
		}
	}

	if(e.getAttribute(oAttrib[8])=='true')                                                 //oAttrib[8]='_ToUp'
	{
	   e.setAttribute('value', e.value.toUpperCase());
	}
		
	if(e.getAttribute(oAttrib[9])=='true')                                                 //oAttrib[9]='_ToLow'
	{
	   e.setAttribute('value', e.value.toLowerCase());
	}

	if(e.getAttribute(oAttrib[10])=='true')                                                 //oAttrib[10]='_FirstUp'
	{
	   e.setAttribute('value', strFirstUp(e.value));
	}
	return(true);
}

function checkNumber(e)
{
	if(e.getAttribute(oAttrib[5])=='true')                                         //oAttrib[5]='_req'
	{
	   if(is_null(e.value))
	   {
	       msgErr(e,oAttrib[5]);
	       return false;
	   }
    }

	if(e.value.length>0)                                        //oAttrib[2]='_value'
	{
	   if(!is_number(e.value))
	   {
	       msgErr(e,oAttrib[11]);                                                  //oAttrib[11]='_Number'
	       return false;
	   }
	   
	   if(e.getAttribute(oAttrib[6]).length>0)										//oAttrib[6]='_min'
	   {
			if(TooSmall(e.value,e.getAttribute(oAttrib[6])))
			{
				msgErr(e,oAttrib[6]);
				return false;
			}
	   }

	   if(e.getAttribute(oAttrib[7]).length>0)										//oAttrib[7]='_max'
	   {
			if(TooLong(e.value,e.getAttribute(oAttrib[7])))
			{
				msgErr(e,oAttrib[7]);
				return false;
			}
	   }
	   
	   if(e.getAttribute(oAttrib[12])=='true')                                    //oAttrib[12]='_Integer'
	   {
	       if(!is_integer(e.value))
	       {
	           msgErr(e,oAttrib[12]);
	           return false;
	       }
	   }
	}    
	return true;
}

function checkDate(e)
{
	if(e.getAttribute(oAttrib[5])=='true')                                         //oAttrib[5]='_req'
	{
	    if(is_null(e.value))
	    {
	        msgErr(e,oAttrib[5]);
	        return false;
	    }
    }

	if(e.value.length>0)                                        //oAttrib[2]='_value'
	{
		var partOfDate = e.value.split("/")
		var d = partOfDate[0]
		var m = partOfDate[1] - 1
		var y = partOfDate[2]

		var val= new Date(y, m, d);
		if (d!=val.getDate() || m!=val.getMonth() || y!=val.getFullYear())
		{
			msgErr(e,'Inserire una data valida nel formato (gg/mm/aaaa).');
			return false;
		}

		var maxArr= e.getAttribute(oAttrib[7]).split("/");
		d = maxArr[0]
		m = maxArr[1] - 1
		y = maxArr[2]
		var max= new Date(y, m, d);
		if(e.getAttribute(oAttrib[7]).length>0)										//oAttrib[7]='_max'
		{
			if(val.valueOf()>max.valueOf())
			{
				msgErr(e,oAttrib[7]);
				return false;
			}
		}

		var minArr= e.getAttribute(oAttrib[6]).split("/");
		d = minArr[0]
		m = minArr[1] - 1
		y = minArr[2]
		var min= new Date(y, m, d);
		if(e.getAttribute(oAttrib[6]).length>0)										//oAttrib[6]='_min'
		{
			if(val.valueOf()<min.valueOf())
			{
				msgErr(e,oAttrib[6]);
				return false;
			}
		}
		e.value=giorno(val)+'/'+mese(val)+'/'+anno(val);
		//document.all('txt'+e.id).value=val.toDateString().substr(val.toDateString().indexOf(' '),val.toDateString().length-val.toDateString().indexOf(' '));
	}
	return true;
}

function checkDateTime(e)
{
}

function checkTime(e)
{
}

function checkCap(e)																	//zip italian only
{
	if(e.getAttribute(oAttrib[5])=='true')												//oAttrib[5]='_req'
	{
	   if(is_null(e.value))
	   {
	       msgErr(e,oAttrib[5]);
	       return false;
	   }
	}
	if(e.value.length>0)                                                 //oAttrib[2]='_value'
	{
		if((TooSmall(e.value.length,5))||(TooLong(e.value.length,5)))								// 5 caratteri
		{
			switch (lang)
			{
				case	'en-EN','en-US' :
				{
					s='CAP: Must set 5 numeric chars!';
					break;
				}
				case	'it-IT' :
				{
					s='CAP: Obbligatorio 5 caratteri numerici!';
					break;
				}
			}	
			msgErr(e,s);
			return false;
		}
		if(!is_number(e.value))										//deve essere un nr
		{
			msgErr(e,oAttrib[11]);
			return false;
		}
		if(!is_integer(e.value))										//deve essere un nr intero
		{
			msgErr(e,oAttrib[12]);
			return false;
		}
    }
	return true;
}

function checkPhone(e)
{
	if(e.getAttribute(oAttrib[5])=='true')												//oAttrib[5]='_req'
	{
		if(is_null(e.value))
		{
			msgErr(e,oAttrib[5]);
			return false;
		}
	}
	if(e.value.length>0)                                                 //oAttrib[2]='_value'
	{
		if(TooSmall(e.value.length,e.getAttribute(oAttrib[6])))				//oAttrib[6]='_min'
		{
			msgErr(e,oAttrib[6]);
			return false;
		}
		if(TooLong(e.value.length,e.getAttribute(oAttrib[7])))				//oAttrib[7]='_max'
		{
			msgErr(e,oAttrib[7]);
			return false;
		}
		if(!is_number(e.value))										//deve essere un nr
		{
			msgErr(e,oAttrib[11]);
			return false;
		}
		if(!is_integer(e.value))										//deve essere un nr intero
		{
			msgErr(e,oAttrib[12]);
			return false;
		}
	}
	return true;
}

function ValidatePhone(e)
{
	var Pos, NumChars, V;
	V=e.value;                                                 //oAttrib[2]='_value'
	if(V.length>11)
	{
		return false;
	}
	else
	{
		for(Pos=0;Pos<V.length;Pos++)
		{
			if(!is_number(V.toUpperCase()))
			{
				if(!isspace(V.toUpperCase()))
					return false;
			}
		}
	}
	return true;
}
    
function checkMail(e)
{
	if(e.getAttribute(oAttrib[5])=='true')												//oAttrib[5]='_req'
	{
		if(is_null(e.value))
		{
			msgErr(e,oAttrib[5]);
			return false;
		}
	}
	if(e.value.length>0)                                                 //oAttrib[2]='_value'
	{
		var emailStr=e.value
		var msg = new Array(6);
		switch (lang)
		{
			case 'en-EN','en-US':
			{
				msg[0] = 'Email address seems incorrect (check @ and .\'s)';
				msg[1] = 'The username doesn\'t seem to be valid.';
				msg[2] = 'Destination IP address is invalid!';
				msg[3] = 'The domain name doesn\'t seem to be valid.';
				msg[4] = 'The address must end in a three-letter domain, or two letter country.';
				msg[5] = 'This address is missing a hostname!';
				break;
			}
			case 'it-IT':
			{
				msg[0] = 'L\'indirizzo e-mail sembra errato (controlla @ e .’s)';
				msg[1] = 'Lo UserName nel campo email sembra non essere valido.';
				msg[2] = 'L\'indirizzo IP nel campo email non è valido.';
				msg[3] = 'Il nome del dominio nell’indirizzo email sembra non essere valido.';
				msg[4] = 'L\'indirizzo email deve terminare con un dominio di tre lettere, o un paese di due lettere.';
				msg[5] = 'Nell\'indirizzo email manca l\'hostname!';
				break;
			}
		}
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);

		if (matchArray==null)
		{
			msgErr(e,msg[0]);
			return false;
		}

		var user=matchArray[1];
		var domain=matchArray[2];

		// See if "user" is valid 
		if (user.match(userPat)==null)
		{
    		// user is not valid
			msgErr(e,msg[1]);
    		return false;
		}

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null)
		{
    		// this is an IP address
	  		for (var i=1;i<=4;i++)
	  		{
	    		if (IPArray[i]>255);
	    		{
					msgErr(e,msg[2]);
					return false;
	    		}
    		}
//    		return true;
		}

		var domainArray=domain.match(domainPat)
		if (domainArray==null)
		{
 			msgErr(e,msg[3]);
   			return false;
		}

		var atomPat=new RegExp(atom,"g");
		var domArr=domain.match(atomPat);
		//var len=domArr.length;
		var len=domArr[domArr.length-1].length;
		//if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
		if (len<2 || len>3)
		{
 			msgErr(e,msg[4]);
   			return false;
		}

		//if (len<2)
		if (domArr.length<2)
		{
 			msgErr(e,msg[5]);
   			return false;
		}
	}
	return true;
}

function checkUrl(e)
{
	var msg='';
	switch (lang)
	{
		case 'en-EN','en-US':
		{
			msg = 'Please enter correct URL, invalid sintax!';
			break;
		}
		case 'it-IT':
		{
			msg = 'L’indirizzo URL non è valido!';
			break;
		}
	}

	if(e.getAttribute(oAttrib[5])=='true')												//oAttrib[5]='_req'
	{
		if(is_null(e.value))
		{
			msgErr(e,oAttrib[5]);
			return false;
		}
	}
	if(e.value.length>0)                                                 //oAttrib[2]='_value'
	{
		if (!isURL(e.value))
		{
			msgErr(e,msg);
			return false;
		}
	}
	return true;
}

function isURL (url)
{
	var urlPattern=(/^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^;"<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^;"<>()\[\]{}\s\x7f-\xff]+)*)?/); 
      return urlPattern.test(s.toLowerCase()); 

}

function isWinPath(e)
{
	if(!checkString(e) || !checkValidWinPathChar(e.value))
	{
	    msgErr(e,oAttrib[13]);
	    return false;
	}
	return true;
}

function checkIP (e,IP)
{
	var msg='Indirizzo IP non valido!';
	IPArray=IP.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);

   	if (IPArray!=null)
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
				//alert(msg);
				msgErr(e,msg);
				return false;
			}
		}
		return true;
	}
	else
	{
		//alert(msg);
		msgErr(e,msg);
		return false;
	}
}

function strFirstUp(s)
{
	var st='';
	var te=trimEnd(s);
	var arr;
	arr=te.split(" ");
	for (var i=0;i<arr.length;i++)
	{
		st+=arr[i].substring(0,1).toUpperCase()+arr[i].substring(1,arr[i].length).toLowerCase()+' ';
	}
	return(trimEnd(st));
}

function trimEnd(s)
{
	if(s.substr(s.length-1,1)==' ')
	{
		return(trimEnd(s.substr(0,s.length-1)));
	}
	else
	{
		return(s);
	}
}

function is_null(s)
{
	if ((s=="") || (s==null)) {
		return true;
	} else {
		return false;
	}
}

function is_number(n)
{
//	if(e.value.search(/[^0-9]/)!=-1)
	if(n.search(/[^0-9]/)!=-1)
	{
		return false;
	}
	return true;
}

function is_integer(n)
{
    if(isNaN(parseInt(n))) return false;
	return true;
}

function anno(d)
{
	var yyyy = d.getYear();
	if(yyyy < 100)
		yyyy = "19" + yyyy;
	if(yyyy >= 100 && yyyy < 1000)
		yyyy = 1900 + yyyy;

	return yyyy;
}

function mese(d)
{
	var mm = d.getMonth()+1;
	if(mm < 10)
		mm = "0" + mm;
	
	return mm;
}

function giorno(d)
{
	var dd = d.getDate();
	if(dd < 10)
		dd = "0" + dd;
	
	return dd;
}

function is_data(d, m, y)
{
	var G=parseInt(d);
	var M=parseInt(m);
	var A=parseInt(y);
//	if ((is_number(G) == false) || (is_number(M) == false) || (is_number(A) == false)) return false;
	if ((!is_number(G)) || (!is_number(M)) || (!is_number(A))) return false;
	if (((G < 1) || (G > 31)) || ((M < 1) || (M > 12)) || ((A.length < 4) || (A < 1970))) return false;
	if (((M == 4) || (M == 6) || (M == 9) || (M == 11)) && (G == 31)) return false;
	if ((M == 2) && ((G > 29) || ((G == 29) && ((A/4) != parseInt(A/4))))) return false;
	return true;
}

function DATA()
{
	var f = document.contest;
	var G = f.GG.value;	
	var M = f.MM.value;
	var A = f.AAAA.value;

	if (!is_null(G) && !is_null(M) && !is_null(A))
	{
		if (G.length < 2) f.GG.value = "0" + f.GG.value;
		if (M.length < 2) f.MM.value = "0" + f.MM.value;
		return(is_data(f.GG.value, f.MM.value, f.AAAA.value));
	}
	return false;
}

function TooLong(v,n)
{
    return (v.valueOf()-n.valueOf())>0;
}

function TooSmall(v,n)
{
    return (n.valueOf()-v.valueOf())>0;
}

function msgErr(e,attr)
{
    var str='';
	if(lang=='en-EN'||lang=='en-US')
	{
        str='The field "'+e.getAttribute(oAttrib[3]);
        switch (attr)
	        {
	        case '_req' :
		        {
		            str+='", is required.';
		            break;
		        }
	        case '_min' :
		        {
		            str+='" have value is under minimum,  value= '+e.value+' - min= '+e.getAttribute(oAttrib[6]);
		            break;
		        }
	        case '_max' :
		        {
		            str+='" have value is over maximum,  value= '+e.value+' - max= '+e.getAttribute(oAttrib[7]);
		            break;
		        }
	        case '_Number' :
		        {
		            str+='" is not a number.';
		            break;
		        }
	        case '_Integer' :
		        {
		            str+='" required integer number, no decimal value.';
		            break;
		        }
	        case '_BadChar' :
		        {
		            str+='" contain a invalid char.';
		            break;
		        }
			default:
				{
					str=attr;
					break;
				}
	        }
	}
	if(lang=='it-IT')
	{
        str='Il campo "'+e.getAttribute(oAttrib[3]);
        switch (attr)
	        {
	        case '_req' :
		        {
		            str+='", e\' obbligatorio.';
		            break;
		        }
	        case '_min' :
		        {
		            str+='" ha un valore sotto il minimo,  valore= '+e.value+' - minimo= '+e.getAttribute(oAttrib[6]);
		            break;
		        }
	        case '_max' :
		        {
		            str+='" ha un valore oltre il massimo,  valore= '+e.value+' - massimo= '+e.getAttribute(oAttrib[7]);
		            break;
		        }
	        case '_Number' :
		        {
		            str+='" deve essere un numero.';
		            break;
		        }
	        case '_Integer' :
		        {
		            str+='" deve essere un numero intero, senza decimali.';
		            break;
		        }
	        case '_BadChar' :
		        {
		            str+='" contiene caratteri non validi.';
		            break;
		        }
			default:
				{
					str=attr;
					break;
				}
	        }
	}
	if(e.getAttribute(oAttrib[3])=='Provincia') {
		str = 'Il campo "Sigla Provincia" deve essere una sigla di due lettere.';
	}
	alert(str);
	e.focus();
	setErrInputBgColor(e);
}

function findObj(n, d)
{
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)
	{
  		x=d.all[n];
	}	 
	for (i=0;!x&&i<d.forms.length;i++)
	{
		x=d.forms[i][n];
	}
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
	{
  		x=findObj(n,d.layers[i].document);
	}
	return x;
}

var strNewValString, strNewValNumber, strValue;
function chkNewVal(e)
{
	if((e.getAttribute(oAttrib[14]).length>0)&&(e.value.length==0))
	{
		switch (lang)
		{
			case 'it-IT' :
			{
				strNewValString='Il campo \''+e.getAttribute(oAttrib[3])+'\' non si puo\' cancellare.\nE\' necessario un valore di testo.';
				strNewValNumber='Il campo \''+e.getAttribute(oAttrib[3])+'\' non si puo\' cancellare.\nE\' necessario un numero.';
				break;
			}
			case 'en-EN','en-US' :
			//default:
			{
				strNewValString='The field \''+e.getAttribute(oAttrib[3])+'\'.\nIs require a word.';
				strNewValNumber='The field \''+e.getAttribute(oAttrib[3])+'\'.\nIs require a number.\nSet to \'Zero\'.';
				break;
			}
		}
		e.value=e.getAttribute(oAttrib[14]);		//_oldValue
		e.style.backgroundColor='red';
		e.focus();
        switch (e.getAttribute(oAttrib[4]))
	    {
			case 'String' :
		    {
				//e.value='Min: '+e.getAttribute(oAttrib[6])+' Max: '+e.getAttribute(oAttrib[7])+' char.';
				msgErr(e,strNewValString);
		        break;
		    }
			case 'Number' :
		    {
				//e.value='From: '+e.getAttribute(oAttrib[6])+' To: '+e.getAttribute(oAttrib[7])+' number value.';
				msgErr(e,strNewValNumber);
		        break;
		    }
	    }
	}
}

function ctlDisplay(ctl,vis)
{
	var e=findObj(ctl);
	e.style.display=vis;
}

function ctlEnable(ctl,bool)
{
	var e=findObj(ctl);
	e.disabled=!bool;
	e.readonly=!bool;
}

function setChkBox(ctl,chk)
{
	var e=findObj(ctl);
	e.checked=chk;
}

function setCombo(cmb,val)
{
	var e=findObj(cmb);
	var oColl=e.options;
	if(oColl.length>0) {
		for (var ii=0;ii<oColl.length;ii++) {
			if(oColl[ii].value==val) {
				e.selectedIndex=oColl[ii].index;
				return(true);
			}
		}
	}
}

function extractCombo(frm)
{
	var f=findObj(frm.id);
	var pref='cmb';
	var eName='';
	var txtName='';
	var txt;
	for (var ii=0;ii<f.length;ii++)
	{
		e=f.elements[ii];
		eName=e.id;
		if(eName.substr(0,3)==pref)
		{
			if(e.getAttribute(oAttrib[5])=='true')												//oAttrib[5]='_req'
			{
				if(is_null(e.options[e.selectedIndex].value))
				{
					msgErr(e,oAttrib[5]);
					return false;
				}
			}
			txtName='txt'+e.id.substr(3,eName.length);
			txt=findObj(txtName);
			txt.value=e.options[e.selectedIndex].value;
		}
	}
	return(true);
}

function setDefInputBgColor(e)
{
	e.style.backgroundColor=defInputBgColor;
}

function setErrInputBgColor(e)
{
	e.style.backgroundColor=errInputBgColor;
}

function setOpenerInput(fl)
{
	opener.window.document.frm.allegato.readOnly=false;
	opener.window.document.frm.allegato.value=fl;
	opener.window.document.frm.allegato.style.backgroundColor='Gainsboro';
	opener.window.document.frm.allegato.readOnly=true;
	window.close();
}

function validuser(u,m)
{
	userExists=false;
	for(i=0;i<userArray.length;i++)
	{
		if(userArray[i].toUpperCase()==u.toUpperCase())
		{
			userExists=true;
		}
	}
	if(userExists)
	{
		alert(m);
	}
	return !userExists;
	setErrInputBgColor(u);
}

function validpwd()
{
	var e=findObj('txtUserPwd','');
	var ee=findObj('txtConfirmUserPwd','');
	if (e.value=='')
	{
		alert(txt2);
		e.focus();
		setErrInputBgColor(e);
		return(false);
	}
	if (e.value!=ee.value)
	{
		alert(txt3);
		ee.focus();
		setErrInputBgColor(ee);
		return(false);
	}
	else
	{
		return(true);
	}
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}

function dotFormatted(amount)
{
	var delimiter = "."; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + ',' + d; }
	amount = minus + amount;
	return amount;
}

function SetCookie() {
if(arguments.length < 2) { return; }
var n = arguments[0];
var v = arguments[1];
var d = 0;
if(arguments.length > 2) { d = parseInt(arguments[2]); }
var exp = '';
if(d > 0) {
	var now = new Date();
	then = now.getTime() + (d * 24 * 60 * 60 * 1000);
	now.setTime(then);
	exp = '; expires=' + now.toGMTString();
	}
document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;
}

var doc=window.document;
doc.write('<META name="WebAgency" content="eMotionLab">\n');
doc.write('<META name="site" content="www.eMotionLab.it">\n');
doc.write('<META name="Author" content="Guido DE GASPERIS">\n');
doc.write('<META name="eMail" content="GDeGaspe'+'ris@eM'+'otionLab.'+'it">\n');

function ReadCookie(n) {
	var cookiecontent = new String();
	if(document.cookie.length > 0) {
		var cookiename = n+ '=';
		var cookiebegin = document.cookie.indexOf(cookiename);
		var cookieend = 0;
		if(cookiebegin > -1) {
			cookiebegin += cookiename.length;
			cookieend = document.cookie.indexOf(";",cookiebegin);
			if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
			cookiecontent = document.cookie.substring(cookiebegin,cookieend);
			}
		}
	return unescape(cookiecontent);
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	/*var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)*/
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		alert("Inserire la data nel formato : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		alert("Inserire un valore valido per il mese.")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		alert("Inserire un valore valido per il giorno.")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		alert("Inserisci un numero di 4 cifre compreso tra "+minYear+" e "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		alert("Inserisci una data valida.")
		return false
	}
return true
}

// -->
