
function apridocs() {
	var stile = "top=200, left=200, width=600, height=480, status=no, menubar=no, toolbar=no, scrollbar=no";
	url="readdocs/index.php";
	window.open(url,'', stile);
  }

function downloaddocs(req) {
	var stile = "top=600, left=800, width=100, height=100, status=no, menubar=no, toolbar=no, scrollbar=no";
	url="readdocs/download.php" + req;
	window.open(url,'', stile);
  }


function confirmLink(theLink, confirmMsg )
{
    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }
    return is_confirmed;
} 


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 con un messaggio di errore

function controlla(f){
 var msg;
 var empty_fields ="";

            for (var i=0;i<f.length;i++) {
		var e=f.elements[i];
                if (e.obbligatorio || e.almenouno)   {
			if ((e.value==null) || (e.value=="") || isBlank(e.value)) {
				   if (e.almenouno) {
						altri=false;
						es=f.elements[i+e.item];
						if ((es.value!=null) && (es.value!="") && !isBlank(es.value)) altri=true;
						if (!altri) empty_fields +="\n          " + e.tip;
				} else {
				 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") && (!e.nocontrol)) {
                 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;
} 

function aprifine(url, name, w, h) {
  popupWin =window.open(url,name,'width='+w+',height='+h+',left=20,top=10,scrollbars=yes,resizable=yes');
                             }
