
function aprifine(url, name, w, h) {
  popupWin =window.open(url,name,'width='+w+',height='+h+',left=20,top=10,scrollbars=yes,resizable=yes');
                             }


function isBlank(s) {
for (var j=0;j<s.length;j++) {
     var c=s.charAt(j);
     var rtn=String.fromCharCode(13);
     var crg=String.fromCharCode(10);
     if ((c !=' ') && (c !='\n') && (c != '\t') && (c != rtn) && (c != crg)) return false;
 }
return true;
}

// funzione che controlla se i campi obbligatori sono stati compilati
// ritorna, in caso contrario, una finestra di alert

function controlla(f){
 var msg;
 var empty_fields ="";

             for (var i=0;i<f.length;i++) {
		var e=f.elements[i];
                 if ( e.obbligatorio )   {
			if ((e.value==null) || (e.value=="") || isBlank(e.value)) {
			empty_fields +="\n          " + e.tip;
			}
		   }
		} // for
		
                if (!empty_fields) return true;
		else {
			msg="il modulo non è stato compilato correttamente\n";
	        	msg+="i seguenti campi obbligatori risultano vuoti:" + empty_fields + "\n";
			alert(msg);
		}
		return false;
 } 


// questa funzione controlla che almeno una scelta sia stata fatta nel form


function controlla_almeno_uno(f){
var msg;
var no_empty_fields =0;

for (var i=0;i<f.length;i++) {
var e=f.elements[i];

if ((e.type!="submit") && (e.type!="reset")) {

                 if ((e.value!=null) && (e.value!="") && (!isBlank(e.value))) {
                       	no_empty_fields = 1;
			return true;
			}
		} // for
}
                if (!no_empty_fields) 
		 {
			msg="Nel modulo non è stata introdotto nessun criterio di ricerca!\n";
	        	msg+="Bisogna introdurre almeno un criterio!";
			alert(msg);
		}

 return false;
} 
