
	//Funzioni per il passaggio automatico da una casella alla successiva
function muovi(da,a,ex,lung){ 
     var start = document.curr.elements[da];
	 var end = document.curr.elements[a];
	if (ex==1){
          if (start.value.length == lung)
	      end.focus();
	}  
	else{
	      end.focus()
	}
    }

	//Funzione per controllare la mail
function checkmail(dati) {
	if (document.curr.e_mail.value != "") {
	if ((document.curr.e_mail.value.indexOf("@") == -1) || (document.curr.e_mail.value.indexOf(".") == -1) || (document.curr.e_mail.value.length < 7)) {
			alert("E-mail non valida");
			document.curr.e_mail.focus();
		}
	}
}


//validatore della data
/*
function giorno2(campogiorno, val){

	lughezza = new String(val);

	if (lunghezza.length != 2){
		alert("giorno non valido");
		document.curr.elements[campogiorno].focus();
	}
}

function chkData2(val,campogiorno,campomese){
	
	var g =document.curr.elements[campogiorno].value;
	
	if(val > 0 && val <= 12 && g != ""){
		var anno = new Array("31","29","31","30","31","30","31","31","30","31","30","31");
		var c =anno[val-1];
		
		
		if (g > c || g == 0 || g == ""){
			alert("Giorno non valido");
			/*document.curr.elements[campogiorno].value = '';
			//document.curr.elements[campomese].value = '';
			document.curr.elements[campogiorno].focus();
		}
		
	}else if((val < 0 || val > 12 || val = "") && g != ""){	
		alert("Mese non valido");
		//document.curr.elements[campomese].value = '';
		document.curr.elements[campomese].focus();

	}else if(g == ""){
		giorno2(document.curr.elements[campogiorno].value);
	}
	
}


function cifreAnno(numAnno){
	if (document.forms[0].mese.value == ""){
		document.forms[0].mese.focus();
	}else if(document.forms[0].giorno.value == ""){
		document.forms[0].giorno.focus();
	}else{
		cifraanno = new String(numAnno);
		vero = cifraanno.length;
		if(vero != 4){
			alert("inserire la data nel formato (gg/mm/aaaa)");
			document.forms[0].anno.focus();
			document.forms[0].anno.select();
		}
	}
}

*/

//mi mostra al click su una checkbox la select correlata
//parametri 
//left:il numero del campo checkbox
//right:il numero del campo select da mostrare
function show(left,right){ 
     var startq = document.curr.elements[left];
	 var endq = document.curr.elements[right];
	if (startq.checked==true){
	      endq.text = 'sufficiente';
		  endq.value = '1';
          endq.style.display = '';
	}  
	else{
	      endq.text='';
		  endq.value=0;
	      endq.style.display='none';
	}
    }

function nonull(num){ 
     var myfield = document.curr.elements[num];
	
	if (myfield.value==0){
	    myfield.value='1';          
	}  
	
    }
function check_studio(campo,step){ 
     var studio_corrente = document.curr.elements[campo];
	 var dip_def=33
	 var lau_def=100
	 
	if (step==1){
	var elementari = document.curr.elements[campo-1];
          elementari.checked=true;
	}  
	if (step==2){
	var elementari = document.curr.elements[campo-2];
          elementari.checked=true;
	var medie = document.curr.elements[campo-1];
          medie.checked=true;
	}  
    if (step==3){
	var elementari = document.curr.elements[campo-3];
          elementari.checked=true;
	var medie = document.curr.elements[campo-2];
          medie.checked=true;
	var diploma = document.curr.elements[campo-1];
	if (diploma.value==20){
	   diploma.value=dip_def;
	   diploma.text='altro';
	   diploma.selected=true;
	   studio_corrente.value=lau_def;
	   studio_corrente.text='Non conseguita';
	   studio_corrente.selected=true;
	   diploma.focus();
	   alert('Per poter selezionare una laurea é necessario inserire prima il diploma superiore conseguito.')
	}
	
	}  
    }


function checkflag2(da, a, on, tot){

	var da,a, on, tot;

	if(da == tot || document.forms[0].elements[(da+1)].checked != true){
		if(on){
			for(da;da>=a;da--){
				document.forms[0].elements[da].checked = true;
			}
		}
	}else if(document.forms[0].elements[(da)].checked){
		for(da;da>=0;da--){
			document.forms[0].elements[da].checked = true;
		}
	}
}

// =====================================================================
// INIZIO - cerca il carattere errato nel campo e lo sostituisce col nuovo
	function sust(str, char, charSost, num){

		var str, char, newChar, n;

		var newString = new String();
		var s = new String(str);
		var c = new String(char);
		var cS = new String(charSost);
		var lung = s.length;


			for(n=0; n<lung; n++){
				if (s.charAt(n) == c.charAt(0)){
					newString += cS.charAt(0);
				}else{
					newString += s.charAt(n);
				}
			}
		return (newString);
//	document.forms[0].elements[num].value = newString;
	}
// FINE
// =====================================================================

// =====================================================================
// INIZIO - ripete l'azione x tutti i campi del form
	function tuttieinvia(char, charSost){
		
		var num, str, newstr, char, charSost;

		var totField = document.forms[0].elements.length - 1;

		for( num=0; num<totField; num++){
			str = document.forms[0].elements[num].value;
			newstr = sust( str, char, charSost, num);
			document.forms[0].elements[num].value = newstr;			
		}
		   document.forms[0].submit();
	}
// FINE
// =====================================================================
function semprevero(questo,quale){
	var quale, questo;
	if (document.forms[0].elements[quale].checked){
		document.forms[0].elements[questo].checked = true;
		alert("Se si è disponibili al trasferimento in tutta Italia\nquesto campo deve rimanere selezionato\nSe si desidera modificare la disponibilità occorre deselizionare prima l'opzione 'tutta Italia'")
	}
}


function scuole(o,s,u){

	var o, s, u;
	var obbligo = document.forms[0].elements[o];

	var superiori = document.forms[0].elements[s];
	var universita = document.forms[0].elements[u];

	var sv = superiori.options[superiori.selectedIndex].value;
	var uv = universita.options[universita.selectedIndex].value;

	if(uv != 100 && sv == 20){
		alert("Per poter selezionare una laurea é necessario inserire prima il diploma superiore conseguito.");
		if (obbligo.checked != true){
			//alert("Per poter selezionare un diploma superiore é necessario selezionare il campo scuola dell'obbligo");
			obbligo.checked = true;
		}
		universita.options[0].selected = true;
		superiori.focus();
	}else if(sv != 20){
		if (obbligo.checked != true){
			//alert("Per poter selezionare un diploma superiore é necessario selezionare il campo scuola dell'obbligo");
			obbligo.checked = true;
		}
		universita.focus();
	}

}




function checkpass(){
	var us = document.forms[0].elements[0].value;
	var ps = document.forms[0].elements[1].value;
	var cps = document.forms[0].elements[2].value;
	if (us.length<5 || ps.length<5 ||cps.length<5){
	alert('la lunghezza della username e della password deve essere di almeno 5 caratteri');
	return false;
	}
	if(us && ps && cps){
		if(us != "" && ps == cps){
			document.forms[0].submit();
		}else {
			alert("Le password inserite non sono uguali!");
			document.forms[0].elements[1].value='';
			document.forms[0].elements[2].value='';
			document.forms[0].elements[1].focus();
		}
	}else{
		alert("Inserire una username e una password");
	}

}




function novuoto(accetto){
	var accetto;
	if(accetto){
		document.forms[0].submit();
	}else{
		alert("Devi autorizzare punto.Lavoro al trattamento dei dati personali.");
	}
}


function textCounter(field, countfield) {
   var maxlimit = 15;
   if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
        alert("Hai raggiunto la lunghezza massima per il messaggio");   } else {
     countfield.value = maxlimit - field.value.length;   
}
}






