<!--
function inputFocus(obj) {
/*	obj.style.borderStyle="solid";
	obj.style.borderWidth="thin";
	obj.style.borderColor="red"; */		
	//obj.style.backgroundColor = "#FFFFCC";
	if (obj.readOnly == 0) {
		obj.style.backgroundColor = "#FFFFCC";
	}
}


function inputNormal(obj) {
/*	obj.style.borderStyle="";
	obj.style.borderWidth="";
	obj.style.borderColor=""; */
	obj.style.backgroundColor = "";
	lastname = obj.name;
}


function setCookie(NameOfCookie, value, expiredays) { 
	var ExpireDate = new Date (); 
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); 
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); 
} 


function getCookie(NameOfCookie){ 
    if (document.cookie.length > 0) {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin); 
      if (end == -1) end = document.cookie.length; 
        return unescape(document.cookie.substring(begin, end)); 
    } 
  } 
  return null; 
} 


function delCookie(NameOfCookie) { 
	if (getCookie(NameOfCookie)) { 
		document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 
	} 
} 


function Init() { 
	mensx = getCookie('MenuSxId');
//	mendx = getCookie('MenuDxId'); 
	if ((mensx!=null) && (mensx!=0)) {
		apri(mensx);
	}
//	if ((mendx!=null) && (mendx!=0)) {
//		apriDX(mendx);
//	}
} 


// Controllo della validità della data inserita
// Franco Bonanzi - franco@bonanzi.net
//
// Per eseguire il controllo aggiungere al campo della form:
// onBlur="return chkData(this)" 
function chkData(form) {
	campo = form.name;
	data = form.value;
	if (data != "") {
		var re = new RegExp("^(\\d{2})/(\\d{2})/(\\d{4})$", ""); 
		var aryMesi = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");  
		var dt = data.match(re);   
		if (!dt) {
			alert("La data va inserita nel formato gg/mm/aaaa");      
			document.getElementById(campo).focus();
			return false;    
		}  
		mese = dt[2];  
		giorno = dt[1];  
		anno = dt[3];   
		if (mese < 1 || mese > 12) {      
			alert("Specificare un mese compreso tra 1 e 12");
			document.getElementById(campo).focus();
			return false;    
		}   
		// Determina il numero massimo di giorni nel mese  
		// Il calendario in uso è quello Gregoriano (introdotto da Papa Gregorio XIII nel 1582)  
		// ed ha un ciclo di 400 anni con 97 anni bisestili anziché 100.  
		// Il 1600 era bisestile, 1700, 1800 e 1900 no, il 2000 lo è, 2100, 2200, 2300 no etc.  
		if (mese == 2) maxDay = (!(anno % 4) && ((anno % 100) || !(anno % 400))) ? 29 : 28;  
		else maxDay = (mese == 4 || mese == 6 || mese == 9 || mese == 11) ? 30 : 31;   
		if (giorno < 1 || giorno > maxDay) {
			alert("Il mese di " + aryMesi[mese - 1] + " " + anno + " non ha " + giorno + " giorni\nSpecificare un giorno compreso tra 1 e " + maxDay);
			document.getElementById(campo).focus();
			return false;
		}
		return true;
	}
}


// Controllo della validità della email inserita
// Franco Bonanzi - franco@bonanzi.net
//
// Per eseguire il controllo aggiungere al campo della form:
// onBlur="return chkMail(this)" 
function chkMail(form) {
	if (form.value != "") {
		var re = new RegExp(/^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/);
		if (!re.test(form.value)) {
			alert("La mail inserita non è valida");
			document.getElementById(form.name).focus();
			return false;
		}
		else {
			return true;
		}
	}
}


// Controllo della validità del numero inserito
// Franco Bonanzi - franco@bonanzi.net
//
// Per eseguire il controllo aggiungere al campo della form:
// onBlur="return chkNumero(this)" 
function chkNumero(form) {
	if (form.value != "") {
		var re = new RegExp(/^[-+]?([0-9])+((\.[0-9]+)+|(\,[0-9]+)?)$/);
		if (!re.test(form.value)) {
			alert("Formati numerici accettati:\n12345 oppure 12345 ;\n12345.67 oppure 12345,67");
			document.getElementById(form.name).focus();
			return false;
		}
		else {
			return true;
		}
	}
}


// Controllo della validità del Codice Fiscale
// Franco Bonanzi - franco@bonanzi.net
//
// Per eseguire il controllo aggiungere al campo della form:
// onBlur="return chkCF(this)" 
function chkCF(form) {
	if (form.value != "") {
		cf = form.value;
		var validi, i, s, set1, set2, setpari, setdisp, cf;
		validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
		setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
		s = 0;	
		cf = cf.toUpperCase();
		
		if (cf.length != 16) {
			alert("La lunghezza del codice fiscale non è\n"
			+"corretta: il codice fiscale dovrebbe essere lungo\n"
			+"esattamente 16 caratteri.");
			document.getElementById(form.name).focus();
			return false;			
		}
		else {
			if (cf.length != 16) {
				for( i = 0; i < 16; i++ ) {
					if (validi.indexOf(cf.charAt(i)) == -1) {
						alert("Il codice fiscale contiene un carattere non valido `" +
						cf.charAt(i) +
						"'.\nI caratteri validi sono le lettere e le cifre.");
						document.getElementById(form.name).focus();
						return false;
	
					}
				}
			}
		}

		
		for (i = 1; i <= 13; i += 2) {
				s += setpari.indexOf(set2.charAt(set1.indexOf(cf.charAt(i))));
		}
		
		for (i = 0; i <= 14; i += 2) {
			s += setdisp.indexOf(set2.charAt(set1.indexOf(cf.charAt(i))));
		}
	
		if (s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0)) {
			alert("Il codice fiscale non è corretto:\n"+
			"il codice di controllo non corrisponde.");
			document.getElementById(form.name).focus();
			return false;
		}
		else {
//			alert("Il Codice Fiscale è Corretto");
			return true;
		}
	}
}


// Controllo della validità della Partita IVA
// Franco Bonanzi - franco@bonanzi.net
//
// Per eseguire il controllo aggiungere al campo della form:
// onBlur="return chkPIVA(this)" 
function chkPIVA(pi) {
	if (form.value != "") {
		pi = form.value;
		validi = "0123456789";
		s = 0;
		if (pi.length != 11) {
			alert("La lunghezza della partita IVA non è\n" +
			"corretta: la partita IVA dovrebbe essere lunga\n" +
			"esattamente 11 caratteri.\n");
		}
		else {
			for( i = 0; i < 11; i++ ) {
				if( validi.indexOf( pi.charAt(i) ) == -1 )
					alert("La partita IVA contiene un carattere non valido `" +
					pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n");
				}
				
				for (i = 0; i <= 9; i += 2) {
					s += pi.charCodeAt(i) - '0'.charCodeAt(0);
				}
				
				for( i = 1; i <= 9; i += 2 ){
					c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
					if( c > 9 )  c = c - 9;
					s += c;
				}
				
				if ((10 - s%10)%10 != pi.charCodeAt(10) - '0'.charCodeAt(0)) {
					alert("La partita IVA non è valida:\n" +
					"il codice di controllo non corrisponde.\n");
					document.getElementById(form.name).focus();
					return false;
					
				}
				else {
					//alert("La Partita IVA è Corretta");
					return true;
				}
		}
	}
}
//-->