function mandaMail(mail,nome)
{
  var i=mail.length; 
  var change = eval("/§/ig");
  var change2 = eval("/Â/ig");
  var n=eval("/_/ig");
  nom=nome.replace(n,"'");
  var mm="";
  i=i-1;
  for (var x = i; x >=0; x--)
  {
    mm+=(mail.charAt(x)); 
  }
  T=mm.split("@");
  mm=T[1]+"@"+T[0];
  mm=mm.replace(change, ".");
  t=mm.replace(change2, "");
  location.href="mailto:"+nom+" <"+t+">";
}

function modifica(numero)
{
    var f=document.getElementById("file_"+numero).value;
    var c=document.getElementById("commento_"+numero).value;
    var d=document.getElementById("down_"+numero).value;
    var p=document.getElementById("passFile_"+numero).value;
    var i=document.getElementById("insegnamento_"+numero).value;
    m="Modifica File";
    alert ("gestione_archivio/materiali_salva.php?invia="+m+"&file="+f+"&commento="+c+"&down="+d+"&insegnamento="+i+"&passFile="+p);
    Ajax("gestione_archivio/materiali_salva.php?invia="+m+"&file="+f+"&commento="+c+"&down="+d+"&insegnamento="+i+"&passFile="+p,"div__"+numero);
}

function Ajax(pagina,id){
var xmlHttp;
    try{    
        xmlHttp=new XMLHttpRequest();
    }
    catch (e){
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e1){
            try{
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e2){
            try {   
                    req=new ActiveXObject("Msxml2.XMLHTTP.4.0");   
                } catch (e3)
               { alert("No AJAX!?");
                return false;
            }
        }
    }
    }

xmlHttp.onreadystatechange=function(){
    if((xmlHttp.readyState==4)||(xmlHttp.readyState==200)){
        document.getElementById(id).innerHTML=xmlHttp.responseText;
    }
}
xmlHttp.open("GET",pagina,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlHttp.send(null);
}



function Ajax2(pagina,id){
var xmlHttp;
    try{    
        xmlHttp=new XMLHttpRequest();
    }
    catch (e){
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e1){
            try{
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e2){
            try {   
                    req=new ActiveXObject("Msxml2.XMLHTTP.4.0");   
                } catch (e3)
               { alert("No AJAX!?");
                return false;
            }
        }
    }
    }

xmlHttp.onreadystatechange=function(){
    if((xmlHttp.readyState==4)||(xmlHttp.readyState==200)){
        document.getElementById(id).innerHTML=xmlHttp.responseText;
    }
}

st="&sigla=";
c=document.getElementById('sigla').value;
st+=c+"&laurea=";
c=document.getElementById('laurea').value;
st+=c;

xmlHttp.open("POST",pagina,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
xmlHttp.send(st);
}


function colora(val,c)
{
  var col=document.getElementById(val);
  col.style.background=c;
  return false;
}

function decolora(val,c)
{
  var col=document.getElementById(val);
  col.style.background=c;
  return false;
}

function controllaForm(form) 
{
var strEmail = form.elements[0].value; 		// Valore del campo txtEmail
var booAccetto = form.elements[1].checked; 	// Valore del campo chkAccetto
				
if ( ( /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(strEmail) ) && ( booAccetto ) ) 
    {
      return true; // Invio la form
	  } else {
		         alert("Attenzione:\nControllare tutti i campi"); // Messaggio di errore
		         return false; // Non invio la form				
	       	}
}


function ab()
{
c="save";
f="mail2";

   v = document.getElementById(f);

    if (v.value=="on") 
      {
        document.getElementById(c).disabled=false;
      }
    else if (v.value=="off") 
      { 
        document.getElementById(c).disabled=true;
      }
  return false;
}


function at()
{
c="save";
f="fileup";

   v = document.getElementById(f);

    if (v.value!="") 
      {
        document.getElementById(c).disabled=false;
      }
    else if (v.value=="") 
      { 
        document.getElementById(c).disabled=true;
      }
  return false;
}

function attivaPass(val)
{
 if (val==1) 
  {
    document.getElementById("passFile1").style.display="";
    document.getElementById("passFile2").style.display="";
  }
 else
  {
    document.getElementById("passFile1").style.display="none";                                                         
    document.getElementById("passFile2").style.display="none";
  }
}







  function addCoordinatore()
  {
    uc = document.getElementById("ucoordinatoreGruppoAdd").value;
    c  = document.getElementById("coordinatore").value;
    
    if (c=="-1")
        {
            if (uc!="")
                document.getElementById("elencoC").value="Coordinatore =-1§"+uc;
            else document.getElementById("elencoC").value="";         
        }
    else document.getElementById("elencoC").value="Coordinatore ="+c;
    
    document.getElementById("coordinatore").value=-1;
    
  }

  function addPartecipante()
  {
    uc = document.getElementById("utenteGruppoAdd").value;
    c  = document.getElementById("partecipante").value;
    
    if (c=="-1")
        {
            if (uc!="")
                document.getElementById("elencoP").value =document.getElementById("elencoP").value + "Partecipante =-1§"+uc+"\r\n";         
        }
    else document.getElementById("elencoP").value +="Partecipante ="+c+"\r\n";
    
    document.getElementById("partecipante").value=-1;
  }

  function addCoordinatore2()
  {
    uc = document.getElementById("ucoordinatoreGruppoAdd").value;
    c  = document.getElementById("coordinatore").value;
    
    if (c=="-1")
        {
            if (uc!="")
                document.getElementById("elencoC").value="Coordinatore =-1|"+uc;
            else document.getElementById("elencoC").value="";         
        }
    else document.getElementById("elencoC").value="Coordinatore ="+c;
    
    document.getElementById("coordinatore").value=-1;
    
  }

  function addPartecipante2()
  {
    uc = document.getElementById("utenteGruppoAdd").value;
    c  = document.getElementById("partecipante").value;
    
    if (c=="-1")
        {
            if (uc!="")
                document.getElementById("elencoP").value =document.getElementById("elencoP").value + "Partecipante =-1|"+uc+"\r\n";         
        }
    else document.getElementById("elencoP").value +="Partecipante ="+c+"\r\n";
    
    document.getElementById("partecipante").value=-1;
  }

  function cancella(forms)
  {
  if (confirm("Vuoi cancellare il campo selezionato?"))
    {
    forms.operazione.value='Cancella';
    forms.submit()
    }
  }
  
  function cancellaR(forms)
  {
  if (confirm("Vuoi cancellare il campo selezionato?"))
    {
    forms.operazioneR.value='Cancella';
    forms.submit()
    }
  }
