function enlarge3d(tlink,larghezza,altezza,scroll) {
	if (document.all) { 
    	var x = window.screenLeft; 
     	var y = window.screenTop; 
     	var w = window.document.body.offsetWidth; 
     	var h = window.document.body.offsetHeight; 
    } else {
   		var x = window.screenX; 
   		var y = window.screenY; 
   		var w = window.outerWidth; 
   		var h = window.outerHeight; 
 	} 
 	var left = x + Math.round((w - larghezza) / 2); 
 	var top = y + Math.round((h - altezza) / 2);
	a=window.open(tlink,"3d","width=" + larghezza + ",height=" + altezza + ",top=" + top + ",left=" + left + ",resizable=no,menubar=no,scrollbars=" + scroll);
	a.focus;
}

function enlarge3d1(tlink,larghezza,altezza,scroll) {
	if (document.all) { 
    	var x = window.screenLeft; 
     	var y = window.screenTop; 
     	var w = window.document.body.offsetWidth; 
     	var h = window.document.body.offsetHeight; 
    } else {
   		var x = window.screenX; 
   		var y = window.screenY; 
   		var w = window.outerWidth; 
   		var h = window.outerHeight; 
 	} 
 	var left = x + Math.round((w - larghezza) / 2); 
 	var top = y + Math.round((h - altezza) / 2);
	a=window.open(tlink,"3d1","width=" + larghezza + ",height=" + altezza + ",top=" + top + ",left=" + left + ",resizable=no,menubar=no,scrollbars=" + scroll);
	a.focus;
}

function enlarge3d2(tlink,larghezza,altezza,scroll) {
	if (document.all) { 
    	var x = window.screenLeft; 
     	var y = window.screenTop; 
     	var w = window.document.body.offsetWidth; 
     	var h = window.document.body.offsetHeight; 
    } else {
   		var x = window.screenX; 
   		var y = window.screenY; 
   		var w = window.outerWidth; 
   		var h = window.outerHeight; 
 	} 
 	var left = x + Math.round((w - larghezza) / 2); 
 	var top = y + Math.round((h - altezza) / 2);
	a=window.open(tlink,"3d2","width=" + larghezza + ",height=" + altezza + ",top=" + top + ",left=" + left + ",resizable=no,menubar=no,scrollbars=" + scroll);
	a.focus;
}
  		
function numeri(modulo){
	var temp = modulo.value;
	temp=temp.replace(".", ",");
	if (isNaN(temp)) {
		alert("Solo numeri sono ammessi");
		modulo.value = 0;
		modulo.select();
		return;
	}
}

function numData(modulo,tipo){
	var ok = "0";
	var temp = modulo.value;
	if ((temp.length>0)&&(isNaN(temp))) {
		alert("Solo numeri sono ammessi");
		ok = "1";
	} else {
		ok = "0";
		if ((tipo=="G")&&(temp>31)) {
			alert("Valore non valido Giorno");
			ok = "1";
		}
		if ((tipo=="M")&&(temp>12)) {
			alert("Valore non valido Mese");
			ok = "1";
		} 
		if ((tipo=="A")&&((temp.length>0)&&(temp.length < 4))) {
			alert("Valore non valido Anno");
			ok = "1";
		}
	}	
	if (ok == "1") {
		modulo.value = "";
		modulo.select();
		return;
	}
}

function ControllaData(modulo) { 
	var temp = modulo.value;
	if (temp!="") {
	    if (temp.substring(2,3) != "/" || temp.substring(5,6) != "/" || isNaN(temp.substring(0,2)) || isNaN(temp.substring(3,5)) || isNaN(temp.substring(6,10))) { 
	    	alert("Inserire la data in formato gg/mm/aaaa"); 
	 		modulo.focus(); 
	    	return false; 
	    } else if (temp.substring(0, 2) > 31) { 
	    	alert("Giorno superiore a 31"); 
	    	modulo.focus(); 
	    	return false; 
	    } else if (temp.substring(3, 5) > 12) { 
	    	alert("Mese superiore a 12"); 
	    	modulo.select(); 
	    	return false; 
	    } else if (temp.substring(6, 10) < 1900) { 
	    	alert("Anno inferiore a 1900"); 
	    	modulo.select(); 
	    	return false; 
	    } 
	}
}

function verTel(field) {
	var valid = "0123456789"
	var ok = "0";	
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "1";
	}
	if (ok == "1") {
		alert("Numero di telefono / fax non valido.");
		field.value = "";
		field.select();
		return;
  		}		
}
			
function indirizzoEmailValido(indirizzo) {
 		if (window.RegExp) {
   		var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
   		var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
   		var regnv = new RegExp(nonvalido);
   		var regv = new RegExp(valido);
   		if (!regnv.test(indirizzo) && regv.test(indirizzo)) return true;
   		return false;
	} else {
   		if(indirizzo.indexOf("@") >= 0) return true;
   		return false;
 		}
 	}

function mail(modulo) {
	if ((modulo.value.length>0)&&(!indirizzoEmailValido(modulo.value))) {
		alert("Si prega di inserire un indirizzo email valido");
		modulo.value = "";
		modulo.select();
		return false;
	}
	else
		return true;
}

function controllo(tmp) {
	var nonok = 0;
	for (i = 1; i < obbligatori.length; i++) {	
		eval ("if(!self.document.FORMIA."+obbligatori[i]+".value) nonok = 1");
	}
	if (nonok == 1)
		alert("Attenzione!!!\nTutti i campi contrassegnati con * sono obbligatori");
	else {
		if (tmp==1) {
			if (Verifica()) self.document.FORMIA.submit();
		} else
			self.document.FORMIA.submit();
	}
}

function calendario(par, par2) {
	a=window.open("calendario.asp?Valore="+par+"&NomeForm="+par2,"3d","width=220,height=220,resizable=no,menubar=no,scrollbars=no,left="+((screen.width/2)-110)+",top=200");
	a.focus();
}
