function controllaProgetto(form){

//titolo
	if(trim(form.titolo_progetto.value) == ""){
		alert("Inserire il titolo del progetto");
		form.titolo_progetto.focus();
		return false;
	}	
//file progetto
	if(form.allegato_progetto.value == ""){
		alert("Inserire l'allegato di progetto");
		form.allegato_progetto.focus();
		return false;
	}	
//files dichiarazione
	if(form.allegato_dichiarazione.value == ""){
		alert("Inserire l'allegato di dichiarazione");
		form.allegato_dichiarazione.focus();
		return false;
	}	
   return true;
}
function controllaProgetto2(form){

//titolo
	if(trim(form.titolo_progetto.value) == ""){
		alert("Inserire il titolo del progetto");
		form.titolo_progetto.focus();
		return false;
	}	
//file progetto
	if(form.allegato_progetto.value == ""){
		alert("Inserire l'allegato di progetto");
		form.allegato_progetto.focus();
		return false;
	}	
   return true;
}

function controllaAnagrafica(form){


//dirigente

//nome
	if(trim(form.nome_dir.value) == ""){
		alert("Inserire il nome del dirigente");
		form.nome_dir.focus();
		return false;
	}	
//cognome
	if(trim(form.cognome_dir.value) == ""){
		alert("Inserire il cognome del dirigente");
		form.cognome_dir.focus();
		return false;
	}	
//telefono
	if(trim(form.telefono_dir.value) == ""){
		alert("Inserire il telefono del dirigente");
		form.telefono_dir.focus();
		return false;
	}	
	if(!isNumeric(form.telefono_dir.value)){
		alert("Il telefono deve essere formato solo da cifre'.");
		form.telefono_dir.focus();
		return false;
	}

	

//email
   if(trim(form.email_dir.value) == ""){
       alert("Inserire l'indirizzo email del dirigente");
       form.email_dir.focus();
       return false;
   }else{
       if(!checkEmail(form.email_dir.value)){
           alert("Inserire un indirizzo email valido.");
           form.email_dir.focus();
           return false;
       }
   }
//fine dirigente

//persona di contatto

//nome
	if(trim(form.nome_con.value) == ""){
		alert("Inserire il nome del contatto");
		form.nome_con.focus();
		return false;
	}	
//cognome
	if(trim(form.cognome_con.value) == ""){
		alert("Inserire il cognome del contatto");
		form.cognome_con.focus();
		return false;
	}	
//telefono
	if(trim(form.telefono_con.value) == ""){
		alert("Inserire il telefono del contatto");
		form.telefono_con.focus();
		return false;
	}
	if(!isNumeric(form.telefono_con.value)){
		alert("Il telefono deve essere formato solo da cifre.");
		form.telefono_con.focus();
		return false;
	}

		

//email
   if(trim(form.email_con.value) == ""){
       alert("Inserire l'indirizzo email del contatto");
       form.email_con.focus();
       return false;
   }else{
       if(!checkEmail(form.email_con.value)){
           alert("Inserire un indirizzo email valido.");
           form.email_con.focus();
           return false;
       }
   }
//fine persona di contatto



   return true;
}


function checkEmail(email) {
   var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   if (!filter.test(trim(email))) {
       return false;
   }else{
       return true;
   }
}

function isNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

   if(sText.length == 0){
       IsNumber = false;
   }
 
   for (i = 0; i < sText.length && IsNumber == true; i++){
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) {
           IsNumber = false;
       }
   }
  return IsNumber;
}


function isNumeric2(sText){
   var ValidChars = "0123456789/";
   var IsNumber=true;
   var Char;

   if(sText.length == 0){
       IsNumber = false;
   }
 
   for (i = 0; i < sText.length && IsNumber == true; i++){
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) {
           IsNumber = false;
       }
   }
  return IsNumber;
}

function isNumeric3(sText){
   var ValidChars = "0123456789/";
   var CompulsoryChars = "/";
   var IsNumber=true;
   var Char;

   if(sText.length == 0){
       IsNumber = false;
   }
 
   for (i = 0; i < sText.length && IsNumber == true; i++){
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) {
           IsNumber = false;
       }
   }
	if(sText.indexOf(CompulsoryChars) == -1){
		IsNumber = false;
	}
  return IsNumber;
}

function isText(sText){
   var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var IsNumber=true;
   var Char;

   if(sText.length == 0){
       IsNumber = false;
   }
 
   for (i = 0; i < sText.length && IsNumber == true; i++){
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) {
           IsNumber = false;
       }
   }
  return IsNumber;
} 



// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) {
	//return btn[cnt].value;
	return true;
    }else {
	//return null;
	return false;	
    }
}
//funzioni per levare gli spazi
function trim(stringa){
	while (stringa.substring(0,1) == ' '){
		stringa = stringa.substring(1, stringa.length);
	}
	while (stringa.substring(stringa.length-1, stringa.length) == ' ')	{
		stringa = stringa.substring(0,stringa.length-1);
	}
	return stringa;
}

function leftTrim(stringa){
	while (stringa.substring(0,1) == ' '){
		stringa = stringa.substring(1, stringa.length);
	}
	return stringa;
}

function rightTrim(stringa){
	while (stringa.substring(stringa.length-1, stringa.length) == ' '){
		stringa = stringa.substring(0,stringa.length-1);
	}
	return stringa;
}

//fine funzioni di controllo dei form

function controllaReti(form){
	
	var conta_reti = 0;

	if(trim(document.getElementById('scuola[0][provincia]').value) == ""){
		alert("Inserire la provincia");
		return false;
		}
	if(trim(document.getElementById('scuola[0][tipologia]').value) == ""){
		alert("Inserire la tipologia");
		return false;
		}
	if(document.getElementById('scuola[0][codice_meccanografico]') == null){
		alert("Inserire almeno una scuola");
		return false;
	}else{
		if(trim(document.getElementById('scuola[0][codice_meccanografico]').value) == ""){
			alert("Inserire il codice meccanografico");
			return false;
		}else{
			//scuola inserita la conto per sapere se sono entro il numero minimo
			conta_reti++;
		}
	}
			


	var maxReti = document.getElementById("numeroReti").value;

	for(var i=1;i<=maxReti;i++){
		if(document.getElementById('scuola['+i+']') != "" && document.getElementById('scuola['+i+']') != null){
			if(/*trim(document.getElementById('classe'+i+'[classe]').value) == "" && */
				trim(document.getElementById('scuola['+i+'][provincia]').value) == "" &&
				trim(document.getElementById('scuola['+i+'][tipologia]').value) == "" &&
				trim(document.getElementById('scuola['+i+'][codice_meccanografico]').value) == "" 
				){
				//non faccio nulla
			}else{
				if(trim(document.getElementById('scuola['+i+'][provincia]').value) == ""){
					alert("Inserire la provincia");
					return false;
					}
				if(trim(document.getElementById('scuola['+i+'][tipologia]').value) == ""){
					alert("Inserire la tipologia");
					return false;
					}
				if(document.getElementById('scuola['+i+'][codice_meccanografico]') == null){
					alert("Inserire il codice meccanografico");
					return false;
				}else{
					if(trim(document.getElementById('scuola['+i+'][codice_meccanografico]').value) == ""){
						alert("Inserire il codice meccanografico");
						return false;
					}else{
						//scuola inserita la conto per sapere se sono entro il numero minimo
						conta_reti++;
					}
				}
				
			}
		}
	}

	//controllo che le scuole inserite siano almeno 2
	if(conta_reti < 2){
		alert("Attenzione devono essere inserite almeno 2 scuole!");
		return false;
	}


	return true;
}

function controllaFormCorsiDocenti(){

	var maxCorsi = document.getElementById("numeroCorsi").value;

	for(var i=0;i<=maxCorsi;i++){
		if(document.getElementById('corsi[corso'+i+']') != "" && document.getElementById('corsi[corso'+i+']') != null){
			if(trim(document.getElementById('corsi[corso'+i+'][corso]]').value) == "" 
				&& trim(document.getElementById('corsi[corso'+i+'][del]]').value) == "" 
				&& trim(document.getElementById('corsi[corso'+i+'][ente]]').value) == "" 
				&& trim(document.getElementById('corsi[corso'+i+'][n_docenti]]').value) == ""){

			}else{
				if(trim(document.getElementById('corsi[corso'+i+'][corso]]').value) == ""){alert("Inserire il corso");return false;}
				if(trim(document.getElementById('corsi[corso'+i+'][del]]').value) == ""){
					alert("Inserire la data");
					return false;
				}else{
					if(!isNumeric3(trim(document.getElementById('corsi[corso'+i+'][del]]').value))){
						alert("Inserire la data nel formato anno/anno");
						return false;	
					}

				}
				if(trim(document.getElementById('corsi[corso'+i+'][ente]]').value) == ""){alert("Inserire l'ente");return false;}
				if(trim(document.getElementById('corsi[corso'+i+'][n_docenti]]').value) == "0"){alert("Inserire il numero di docenti");
					return false;
				}else{
					if(!isNumeric(trim(document.getElementById('corsi[corso'+i+'][n_docenti]]').value))){
						alert("Il numero di docenti deve essere in cifre");
						return false;
					}
				}
			}
		}
	}

	var maxDocenti = document.getElementById("numeroDocenti").value;

	for(var i=0;i<=maxDocenti;i++){
		if(document.getElementById('docenti[docente'+i+']') != "" && document.getElementById('docenti[docente'+i+']') != null){
			if(trim(document.getElementById('docenti[docente'+i+'][docente]]').value) == "" 
				&& trim(document.getElementById('docenti[docente'+i+'][corso]]').value) == ""  
				&& trim(document.getElementById('docenti[docente'+i+'][ente]]').value) == ""){

			}else{
				if(trim(document.getElementById('docenti[docente'+i+'][docente]]').value) == ""){alert("Inserire il docente");return false;}
				if(trim(document.getElementById('docenti[docente'+i+'][corso]]').value) == ""){alert("Inserire il corso");return false;}
				if(trim(document.getElementById('docenti[docente'+i+'][ente]]').value) == ""){alert("Inserire l'ente");return false;}
				}
			}
		}
	

	return true;
}

function controllaFormTitoli(){

	var maxEsperienze = document.getElementById("numeroEsperienze").value;
	var maxFonti = document.getElementById("numeroFonti").value;

	foundFonti = false;

	for(var i=0;i<=maxEsperienze;i++){
		if(document.getElementById('esperienze[esperienza'+i+']') != "" && document.getElementById('esperienze[esperienza'+i+']') != null){
			if(trim(document.getElementById('esperienze[esperienza'+i+'][titolo]]').value) == "" && 
				trim(document.getElementById('esperienze[esperienza'+i+'][esperienza]]').value) == "0" && 
				trim(document.getElementById('esperienze[esperienza'+i+'][anno_scolastico]]').value) == "" && 
				trim(document.getElementById('esperienze[esperienza'+i+'][descrizione]]').value) == ""){}
			else{
				if(trim(document.getElementById('esperienze[esperienza'+i+'][titolo]]').value) == ""){alert("Inserire il titolo");return false;}
				if(trim(document.getElementById('esperienze[esperienza'+i+'][esperienza]]').value) == "0"){alert("Inserire l'esperienza");return false;}
				if(trim(document.getElementById('esperienze[esperienza'+i+'][anno_scolastico]]').value) == ""){
					alert("Inserire l'anno scolastico");return false;
				}else{
					if(!isNumeric3(trim(document.getElementById('esperienze[esperienza'+i+'][anno_scolastico]]').value))){
						alert("Inserire l'anno scolastico nel formato anno/anno");
						return false;	
					}
				}
				if(trim(document.getElementById('esperienze[esperienza'+i+'][descrizione]]').value) == ""){alert("Inserire la descrizione");return false;}
			}
		}
	}

	return true;
}


function addRete(){
	var ni = document.getElementById('retiDiv');
	var numi = document.getElementById('numeroReti');
	var num = numi.value;
	var num2 = (num-1)+2;
	numi.value = num2;
	var newdiv = document.createElement('div');
	var divIdName = 'scuola['+num2+']';
	newdiv.setAttribute('id',divIdName);
	newdiv.innerHTML = '<br/>\n\t\t\t\t\t\t\t\t<label for=\"'+divIdName+'[provincia]\">provincia*</label><i>(selezionare EE per estero)</i><span id=\"'+divIdName+'[sel_provincia]\" name=\"'+divIdName+'[sel_provincia]\" ></span><br/><br/>\n\t\t\t\t\t\t\t\t<label for=\"'+divIdName+'[tipologia]\">tipologia*</label>\n\r<span id=\"'+divIdName+'[sel_tipologia]\" name=\"'+divIdName+'[sel_tipologia]\" onchange=\"resetCodici('+num2+')\"></span><br><br>\n\r<div id="'+divIdName+'[lista_codici]"></div><div style="float:right;">\n\t\t\t\t\t\t\t\t\t<a href="javascript:;" onclick="removeElement(\''+divIdName+'\',\'retiDiv\');"><img src="../images/delete.png" alt="Elimina classe" title="Elimina classe"/></a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<br clear="all"/>\n\t\t\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t\t\t<!--<a href="#" onclick="svuotaForm(\''+divIdName+'\');return false;"><img src="../images/svuota.png" alt="cancella i dati" title="cancella i dati"></a>\n\t\t\t\t\t\t\t\t\t\t--><br clear="all"/>\n\t\t\t\t\t\t\t\t<hr/>';
	ni.appendChild(newdiv);
	
	resetProvince(num2);
	resetTipologie(num2);
	
}
function addClasse(){
	var ni = document.getElementById('classiDiv');
	var numi = document.getElementById('numeroClassi');
	var num = numi.value;
	var num2 = (num-1)+2;
	numi.value = num2;
	var newdiv = document.createElement('div');
	var divIdName = 'classe'+num2;
	newdiv.setAttribute('id',divIdName);
	newdiv.innerHTML = '\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<label for="'+divIdName+'[classe]" class="lab1">Classe</label>\n\t\t\t\t\t\t\t\t<input id="'+divIdName+'[classe]" name="'+divIdName+'[classe]" value=\"1\" size="16" maxlength="30" type="text" readonly/>\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<label for="'+divIdName+'[sezione]" class="lab2">Sezione</label>\n\t\t\t\t\t\t\t\t<input id="'+divIdName+'[sezione]" name="'+divIdName+'[sezione]" size="16" maxlength="16" type="text">\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<label for="'+divIdName+'[sede]" class="lab2">Sede</label>\n\t\t\t\t\t\t\t\t<select id="'+divIdName+'[sede]" name="'+divIdName+'[sede]">\n\t\t\t\t\t\t\t\t\t<option value="0"> - </option>\n\t\t\t\t\t\t\t\t\t<option value="1">Centrale</option>\n\t\t\t\t\t\t\t\t\t<option value="2">Succursale</option>\n\t\t\t\t\t\t\t\t\t<option value="3">Sezione staccata</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<label for="'+divIdName+'[n_alunni]" class="lab2">Numero alunni</label>\n\t\t\t\t\t\t\t\t<input id="'+divIdName+'[n_alunni]" name="'+divIdName+'[n_alunni]" size="3" maxlength="3" type="text">\n\t\t\t\t\t\t\t\t<div style="float:right;">\n\t\t\t\t\t\t\t\t\t<a href="javascript:;" onclick="removeElement(\''+divIdName+'\',\'classiDiv\');"><img src="../images/delete.png" alt="Elimina classe" title="Elimina classe"/></a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<br clear="all"/>\n\t\t\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t\t\t<a href="#" onclick="svuotaForm(\''+divIdName+'\');return false;"><img src="../images/svuota.png" alt="cancella i dati" title="cancella i dati"></a>\n\t\t\t\t\t\t\t\t\t\t<br/><br/>\n\t\t\t\t\t\t\t\t\t\t<br clear="all"/>\n\t\t\t\t\t\t\t\t<hr/>';
	ni.appendChild(newdiv);
}



function removeElement(divNum,divMadre) {
	var d = document.getElementById(divMadre);
	var olddiv = document.getElementById(divNum);
	d.removeChild(olddiv);
}


function svuotaForm(idForm){
	var div = document.getElementById(idForm);
	var fields = div.getElementsByTagName('input');
	var fieldsArea = div.getElementsByTagName('textarea');
	var fieldsSelect = div.getElementsByTagName('select');
	for(var i=0; i<fields.length; i++){
		if(fields[i].type != "reset"){
			fields[i].value = "";
		}
	}

	for(var j=0; j<fieldsArea.length; j++){
		fieldsArea[j].value = "";
	}

	for(var k=0; k<fieldsSelect.length; k++){
		fieldsSelect[k].value = 0;
	}
}

function hideDiv(el) {
	document.getElementById(el).style.visibility = 'hidden';
}

function showDiv(el) {
	document.getElementById(el).style.visibility = 'visible';
}








//ini beppe

  function carica_des()
 {   var server="";root="/cittadinanzaecostituzione/formulario";
    // alert(server+root+"/functions.php?funz=carica_des");
	  myRequest=CreateXmlHttpReq(Handler_des);
      myRequest.open("GET",server+root+"/functions.php?funz=carica_des");
      myRequest.send(null); 
      return;
 }



function scuole_per_regione(root,usdi,regio)
 {   var server="";
     //alert(server+root+"/functions.php?funz=mostra_scuole_usr&usdi="+usdi+"&regio="+regio);
	  myRequest=CreateXmlHttpReq(Handler_dati);
      myRequest.open("GET",server+root+"/functions.php?funz=scuole_per_regione&usdi="+usdi+"&regio="+regio+"&root="+root);
      myRequest.send(null); 
      return;
 }

//ini beppe
function scuole_per_regione2(root,usdi,regio)
 {   var server="";
     //alert(server+root+"/functions.php?funz=mostra_scuole_usr&usdi="+usdi+"&regio="+regio);
	  myRequest=CreateXmlHttpReq(Handler_dati);
      myRequest.open("GET",server+root+"/functions.php?funz=scuole_per_regione2&usdi="+usdi+"&regio="+regio+"&root="+root);
      myRequest.send(null); 
      return;
 }





function scuole_finanziate(root)
 {   var server="";
     //alert(server+root+"/functions.php?funz=scuole_finanziate");
	  myRequest=CreateXmlHttpReq(Handler_dati);
      myRequest.open("GET",server+root+"/functions.php?funz=scuole_finanziate");
      myRequest.send(null); 
      return;
 }

 function  Handler_des() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("descrittori"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	   //  alert(myRequest.responseText); 
		 }
                         }

function  Handler_dati() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("mostra_dati"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	   //  alert(myRequest.responseText); 
		 }
                         }

function dati_scuole_rete(codice_scuola,root)
 {   var server="";
     // alert(server+root+"/functions.php?funz=dati_scuole_rete&codice_scuola="+codice_scuola+"&root="+root);
	  myRequest=CreateXmlHttpReq(Handler_dati_scuola_rete);
      myRequest.open("GET",server+root+"/functions.php?funz=dati_scuole_rete&codice_scuola="+codice_scuola+"&root="+root);
      myRequest.send(null); 
      return;
 }


function per_regione(root)
 {   var server="";
     // alert(server+root+"/functions.php?funz=per_regione&root="+root);
	  myRequest=CreateXmlHttpReq(Handler_per_regione);
      myRequest.open("GET",server+root+"/functions.php?funz=per_regione&root="+root);
      myRequest.send(null); 
      return;
 }

function  Handler_per_regione() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("mostra_doppioni"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	 //    alert(myRequest.responseText); 
		 }
                         }









function  Handler_dati_scuola_rete() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("mostra_scuole"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	 //    alert(myRequest.responseText); 
		 }
                         }

function conta_doppioni(root,a)
 {   var server="";
     // alert(server+root+"/functions.php?funz=conta_doppioni&root="+root+"&scuole_rete="+a);
	  myRequest=CreateXmlHttpReq(Handler_dati_doppioni);
      myRequest.open("GET",server+root+"/functions.php?funz=conta_doppioni&root="+root+"&scuole_rete="+a);
      myRequest.send(null); 
      return;
 }
function  Handler_dati_doppioni() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
   	 e=document.getElementById("mostra_doppioni"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	
		 }
                         }





function voto_punti(codice_scuola,root)
{   var server="";
   alert("operazione non permessa");return;
   //e=document.getElementById("punti");  alert(e.value);//ok va bene
    var b=new Array(4);
     //tot=Number(document.punteggio.punti.value);
	 totale="";
		Array[0]=document.punteggio.punti1.value;Array[1]=document.punteggio.punti2.value;
		Array[2]=document.punteggio.punti3.value;Array[3]=document.punteggio.punti4.value;
        
		if(Number(Array[0])>30){alert("1 out of range");return;}
	    if(Number(Array[1])>30){alert("3 out of range");return;}
	    if(Number(Array[2])>20){alert("4 out of range");return;}
	    if(Number(Array[3])>20){alert("5 out of range");return;}
	   
	   for(a=0;a<4;a++){
     //if(Array[a].length == 0){alert("metti un voto");return;}
	 if(!isNumeric(Array[a])){alert("il voto deve essere numerico");return;}
		//totale+=Number(Array[a]);               
	    totale=totale+Array[a]+";";
					   } 
	    totnum=Number(Array[0])+ Number(Array[1])+Number(Array[2])+Number(Array[3]);
		document.getElementById("punti").value=totnum ;
       //alert(totale);
	  if(totale>100){alert("voto out of range");return;}
	//alert(server+root+"/functions.php?funz=punteggio&codice_scuola="+codice_scuola+"&punti="+totale+"&root="+root);
	  myRequest=CreateXmlHttpReq(Handler_punti);
      myRequest.open("GET",server+root+"/functions.php?funz=punteggio&codice_scuola="+codice_scuola+"&punti="+totale+"&root="+root);
      myRequest.send(null); 
      return;
 }

function registra_note_livello_area(codice_scuola,root)
{   var server="";
       alert("operazione non permessa");return;
		note=document.punteggio.note_comm.value;
		e=document.getElementById("livello");aa=e.selectedIndex;
	 	livello= e[aa].text;
	    livello_value= e[aa].value;
		
	    e=document.getElementById("area");aa=e.selectedIndex;
	 	area= e[aa].text;
	    area_value= e[aa].value;
        segnalazione='0';if(document.punteggio.segnalazione.checked==true)segnalazione='1';
	//alert(server+root+"/functions.php?funz=note_livello_area&codice_scuola="+codice_scuola+"&note="+note+"&livello="+livello+"&area="+area+"&root="+root);
	  myRequest=CreateXmlHttpReq(Handler_note_livello_area);
      myRequest.open("GET",server+root+"/functions.php?funz=note_livello_area&codice_scuola="+codice_scuola+"&note="+note+"&livello="+livello+"&area="+area+"&segnalazione="+segnalazione+"&root="+root);
      myRequest.send(null); 
      return;
 }

   function registra_finanziato(codice_scuola,root,unodue)
{   var server="";	
			 alert("operazione non permessa");return;
        finanziato='0';
		if (unodue=='1')finanziato='1';
		if (unodue=='2')finanziato='2';
		//if(document.punteggio.finanziato.checked==true)finanziato='1';
	//alert(server+root+"/functions.php?funz=note_livello_area&codice_scuola="+codice_scuola+"&note="+note+"&livello="+livello+"&area="+area+"&root="+root);
	  myRequest=CreateXmlHttpReq(Hregistra_finanziato);
      myRequest.open("GET",server+root+"/functions.php?funz=registra_finanziato&codice_scuola="+codice_scuola+"&finanziato="+finanziato+"&root="+root);
      myRequest.send(null); 
      return;
 }

   function  Hregistra_finanziato() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("registra_finanziato"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	   //  alert(myRequest.responseText); 
		 }
                         }




function  Handler_note_livello_area() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("mostra_note_livello_area"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	   //  alert(myRequest.responseText); 
		 }
                         }



function  Handler_punti() {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
     e=document.getElementById("mostra_punti"); 
	 e.style.visibility = 'visible';
	 e.innerHTML=myRequest.responseText;  
	   //  alert(myRequest.responseText); 
		 }
                         }



function graduatoria(root,usdi)
 {   var server="";	
    //alert("operazione non permessa");return;
     // alert(server+root+"/functions.php?funz=cgraduatoria&root="+root);
	  if(usdi=="MIN")  {
	  var sel=document.getElementById('regione');
      var aa=sel.selectedIndex;
  	  usdi=sel[aa].value; 
	  }
	 
	  	// alert(server+root+"/functions.php?funz=graduatoria&root="+root+"&usdi="+usdi);
	  myRequest=CreateXmlHttpReq(Handler_dati);
      myRequest.open("GET",server+root+"/functions.php?funz=graduatoria&root="+root+"&usdi="+usdi);
      myRequest.send(null); 
      
	  return;
 }


 function graduatoria2(root,usdi)
 {   var server="";	
	  if(usdi=="MIN")  {
	  var sel=document.getElementById('regione');
      var aa=sel.selectedIndex;
  	  usdi=sel[aa].value; 
	  }
	 
	  myRequest=CreateXmlHttpReq(Handler_dati);
      myRequest.open("GET",server+root+"/functions.php?funz=graduatoria2&root="+root+"&usdi="+usdi);
      myRequest.send(null); 
      
	  return;
 }
  
 function descrittori(root,des)
 {   var server="";	
    //alert("operazione non permessa");return;
      // alert(server+root+"/functions.php?funz=descrittori&root="+root+"&des="+des);
	  // des = des.replace("'","\'");

	  myRequest=CreateXmlHttpReq(Handler_dati);
     
	  myRequest.open("GET",server+root+"/functions.php?funz=descrittori&root="+root+"&des="+des);
      myRequest.send(null); 
      return;
 }
	






function lancia_regione(root,usdi)
   {  
	  var sel=document.getElementById('regione');
      var aa=sel.selectedIndex;
  	  scuole_per_regione(root,sel[aa].value,sel[aa].text);   
	  }
function lancia_regione2(root,usdi)
   {  
	  var sel=document.getElementById('regione');
      var aa=sel.selectedIndex;
  	  scuole_per_regione2(root,sel[aa].value,sel[aa].text);   
	  }



function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
 }


  function esci(a){
	              if(a==0)e=document.getElementById("mostra_dati"); 
	              if(a==1){
					  e=document.getElementById("mostra_doppioni"); 
				      e.style.visibility = 'hidden';
                      e=document.getElementById("mostra_scuole");
				        }
				      e.style.visibility = 'hidden'; 
  }
 //fine beppe
