﻿// File JScript

function cambiaselect(id) {
var link = document.getElementById('pdf_'+id+'').value;
//window.open(link, '_blank');
location.href = link
}//cambiaselect

function controllopartecipanti(num, corso) {
    var numero = document.getElementById(''+num+'partecipanti'+corso).value;
   if (numero.length == 1) {
   numero = '0' + numero
   }
    var procedi = false 
    if (numero > num) {
    document.getElementById('errorepartecipanti'+corso).style.display = "";
   return false 
    } 
    if ((numero == '') ) {
    //document.getElementById('errorepartecipanti'+corso).style.display = "";
   return true
    }
    if (numero <= num) {
    document.getElementById('errorepartecipanti'+corso).style.display = "none"; 
   return true 
    } 
}//end controllopartecipanti

function inviaiscrizione() {
    var conta = document.forms[0].length;
    var i = 0; 
    var corsi = 0
    var partecip = 0  
    conta = conta -1;
    for (i<0; i<conta; i++) {
      var valore = document.forms[0].elements[i].value;
      var nome = document.forms[0].elements[i].name;
      var corsoid = nome.split("partecipanti")
        //alert("i = " + i + " valore = " + valore + " nome = " + nome + " corsoid = " + corsoid[1] + " partecipantitotale = " + corsoid[0]);
        if (controllopartecipanti(corsoid[0], corsoid[1]) == true) {
            if (valore != '') {
            corsi = corsi + "-" + corsoid[1];
            partecip = partecip + "-" + valore;
            //alert("corsi = " + corsi + " partecipanti = " + partecip);
            }//end if
        }//end if
    }//end for
    if ((corsi != 0) && (partecip != 0)) {
        document.location.href = 'dati.aspx?corsi=' + corsi + '&partecip=' + partecip + ''; 
    } else {
         document.getElementById("messaggio").style.display = "";
    }//end if
    //alert(conta);
}//end inviaiscrizione
