function CtrlCar(nome)
{
var posizione;
var negati= new Array("<",">","'","\"","?","&","=");
for (var i=0;i<negati.length;i++)
{	var lung=document.getElementById(nome).value.length
	for (var j=0;j<lung;j++)
   {
	posizione=document.getElementById(nome).value.indexOf(negati[i]);
	if ( posizione != -1)
		{alert("Attenzione! Il carattere ' "+negati[i]+" ' non è ammesso.");
	 	 document.getElementById(nome).value=document.getElementById(nome).value.substring(0,posizione)+document.getElementById(nome).value.substring(posizione+1);
		};
   }
}
}
function ControllaLogin(){
if ((document.forms[0].nome.value == "") ||
    (document.forms[0].cognome.value == "") ||
	(document.forms[0].username.value == "") ||   
	(document.forms[0].email.value == ""))
    {alert("Attenzione! Un campo non è stato specificato.");
     return false}
}
function ControllaLoginScuole(){
if ((document.forms[0].username.value == "") ||   
	(document.forms[0].password.value == ""))
    {alert("Attenzione! Un campo non è stato specificato.");
     return false}
}
function ControllaLoginStudenti()
{
if ((document.forms[1].username.value == "") ||
    (document.forms[1].password.value == ""))
    {alert("Attenzione! Un campo non è stato specificato.");
     return false}
document.forms[1].action=document.forms[1].action+"&as="+document.forms[0].as.value;
}
function ControllaRegistrazioneStudenti()
{
if ((document.forms[0].fiscale.value == "") ||
    (document.forms[0].username.value == "") ||
	(document.forms[0].email.value == ""))
    {alert("Attenzione! Un campo non è stato specificato.");
     return false}
}


function ControllaTesto(){
if (document.forms[0].testo.value == "")
	{alert("Attenzione! Testo della comunicazione non inserito");
	  return false}
else return confirm("Confermi la registrazione della comunicazione ?");
}
function EliminaTesto(){
   return confirm("Confermi la cancellazione della comuncazione ?")
}
function ctrlAnno(a)
{
if (a>2008) 
	{
	alert ("Attenzione! Non è ancora disponibile l'archivio che supporta l'anno scolastico selezionato.");
	document.forms[0].as.options[0].selected=true;
	document.forms[0].as.focus();
	}
}
function Ctrl_radio(m) 
{
if (m=="scelta2") {document.forms[0].liceo.disabled=false;document.forms[0].liceo.focus();document.forms[0].professionale.disabled=true};
if (m=="scelta3") {document.forms[0].professionale.disabled=false;document.forms[0].professionale.focus();document.forms[0].liceo.disabled=true};
if (m=="scelta4") {document.forms[0].liceo1.disabled=false;document.forms[0].liceo1.focus();document.forms[0].professionale1.disabled=true};
if (m=="scelta5") {document.forms[0].professionale1.disabled=false;document.forms[0].professionale1.focus();document.forms[0].liceo1.disabled=true};
document.forms[0].Continua.disabled=false;
}
function ControllaAnagrafe(){
if ((document.forms[0].classe.value == "") ||
    (document.forms[0].denominazione.value == ""))
    {alert("Attenzione! Tutti i dati sono obbligatori.");
     return false}
else	 
   if (confirm("Confermi il caricamento del documento "+document.forms[0].classe.value+" ?")) 
	   {document.forms[0].action=document.forms[0].action+"&denominazione="+document.forms[0].denominazione.value;
		return true 
	   }
	else return false
}
function Studente(m)
{
var studente=document.forms[0].studente.value;
document.getElementById(m).href=document.getElementById(m).href.substring(0,document.getElementById(m).href.indexOf("&studente"))+"&studente="+studente;
}
function ControllaApprendimento()
{
var risposta=confirm("Confermi la data e l'attribuzione dei livelli di padronanza nell'uso delle competenze acquisite per lo studente "+document.forms[0].studente.options[document.forms[0].studente.selectedIndex].text+" ?");
if (risposta==true) {document.forms[0].action=document.forms[0].action+'&CF_stud='+document.forms[0].studente.value;}return risposta;
}
function ControllaCompetenze()
{
 return confirm("Sei sicuro di voler esaminare le competenze attribuite allo studente "+document.forms[0].studente.options[document.forms[0].studente.selectedIndex].text+" ?");
}
function Abilita_check(m)
{
document.getElementById(m).style.visibility="visible";
document.getElementById(m).focus();
document.getElementById(m).value=document.getElementById(m).value
}
function Disabilita_check(m)
{
document.getElementById(m).style.visibility="hidden";
}
function Valuta(m)
{
document.getElementById(m).value=document.getElementById(m).value;
}
function ControllaOrientamento()
{
var risposta=confirm("Confermi l'attribuzione del Consiglio di Orientamento per lo studente "+document.forms[0].studente.options[document.forms[0].studente.selectedIndex].text+" ?");
if (risposta==true) {document.forms[0].action=document.forms[0].action+'&ID_stud='+document.forms[0].studente.value;}
return risposta;
}
function ControllaRiorientamento()
{
var risposta=confirm("Confermi l'attribuzione del Consiglio di Riorientamento per lo studente "+document.forms[0].studente.options[document.forms[0].studente.selectedIndex].text+" ?");
if (risposta==true) {document.forms[0].action=document.forms[0].action+'&ID_stud='+document.forms[0].studente.value;}
return risposta;
}
function ControllaInterpersonale()
{
var totale=0;
for (var i=3;i<23;i++)
	{ if (document.forms[0].elements[i].value=="")
			{alert("Attenzione, una o più risposte risultano vuote");
	 			return false;
		    }
	  totale=totale+document.forms[0].elements[i].value;
	};
if (totale==0)
	{alert("Attenzione, tutte le risposte risultano nulle");
	 			return false;
	};
return confirm("Confermi l'attribuzione delle risposte e la data ?")
}
function CtrlCifra(nome)
{
var lung=document.getElementById(nome).value.length;
for (var i=0;i<=lung;i++)
	if (isNaN(document.getElementById(nome).value.charAt(i)))
		{alert("Attenzione! Il carattere '"+document.getElementById(nome).value.charAt(i)+"' non è ammesso.");
	 	 document.getElementById(nome).value=document.getElementById(nome).value.substring(0,i)+document.getElementById(nome).value.substring(i+1);i--;
	};
}
function CtrlCheck(m)
{
var cont=0;
for(var i=1;i<21;i++)
{if (document.getElementById(i).checked)
    {cont=cont+1;}
};
if (cont>5)
{alert("Attenzione! Non si possono selezionare più di 5 opzioni");
 document.getElementById(m).checked=false;}
}
function Licenziare()
{
document.forms[0].strClasse.value=document.forms[0].classe.options[document.forms[0].classe.selectedIndex].text;
}
function RegistraStudente(id)
{
if (document.getElementById(id).href.indexOf("as=")== -1) {
document.getElementById(id).href=document.getElementById(id).href+"as="+document.forms[0].as.value;}
}
