      var percorso="";
	function cambioPasso1(){
	//alert("in");
       
			var nome =document.getElementById('nome').value;
			var cognome=document.getElementById('cognome').value; 
			var password=document.getElementById('password').value;
                        var confpassword=document.getElementById('confpassword').value;
                        var luogonascita=document.getElementById('luogonascita').value;
                        var regione=document.getElementById('regione').value;
			if(document.getElementById('citta')){
				var citta=document.getElementById('citta').value;
			}
			var ddnascita =document.getElementById('ddnascita').value;
			var mmnascita=document.getElementById('mmnascita').value;
			var aanascita= document.getElementById('aanascita').value;
		//	var residenza=document.getElementById('residenza').value;
			var domicilio=document.getElementById('domicilio').value;
			var codicefiscale=document.getElementById('codicefiscale').value;
			var telefono=document.getElementById('telefono').value;
			var email=document.getElementById('email').value;
			var msn=document.getElementById('msn').value;;
			var facebook=document.getElementById('facebook').value;
                        var sesso=document.getElementById('sesso').value;
			var sito=document.getElementById('sito').value;


                        //alert(sesso);
                        //var compenso=document.getElementById('compenso').value;
	//alert("s");
	var datanascita = aanascita+"-"+mmnascita+"-"+ddnascita; 
	
		if(nome==""){
			alert('Campo nome obbligatorio');
			return false;
		}else
		
		if(cognome==""){
			alert('Campo cognome obbligatorio');
			return false;
		}else
		
		if(password=="" || password.length <=5 ){
			alert('Il campo password e vuoto o deve contenere almeno 6 caratteri ');
			return false;
		}else

                if(confpassword==""){
			alert('Il campo conferma password e vuoto');
			return false;
		}else

                if(password != confpassword){
			alert('I campi password non corrispondono ');
			return false;
		}else

                if(sesso=="nop"){
			alert('Devi scegliere il sesso!');
			return false;
		}else

		if(regione=="nop"){
			alert('Devi scegliere una regione!');
			return false;
		}else
		
		if(citta==""){
			alert('Campo citta obbligatorio');
			return false;
		}else
		
		/*if(residenza==""){
			alert('Campo residenza obbligatorio');
			return false;
		}else*/
		
		if(domicilio==""){
			alert('Campo domicilio obbligatorio');
			return false;
		}else
		if(codicefiscale==""){
			alert('Campo codice fiscale obbligatorio');
			return false;
		}else
		if(telefono=="" || isNaN(telefono)){
			alert('Il campo telefono e vuoto oppure non e un numero');
			return false;
		}else
		if(email==""){
			alert('Campo email obbligatorio');
			return false;
		}else{
		
		
		
	
	$.post("form/ajax/ajaxStep2Form.php",  {
		nome:nome,
		cognome:cognome,
		password:password,
                luogo_nascita:luogonascita,
		regione:regione,
		citta:citta,
                sesso:sesso,
		data_nascita:datanascita,
		indirizzo_domicilio:domicilio,
		codice_fiscale:codicefiscale,
		telefono:telefono,
		email:email,
		msn:msn,
		facebook:facebook,
		www:sito
		
	}, function(data){
	//alert(data)
	document.getElementById('step2').innerHTML = data
	document.getElementById('step1').style.display='none'
	document.getElementById('step2').style.display= 'block'
	});
			}
	}

	function cambioPasso2(){
	//alert("in");
			var altezza =document.getElementById('altezza').value;
			var tagliapantaloni=document.getElementById('tagliapantaloni').value; 
			var tagliamaglietta=document.getElementById('tagliamaglietta').value;
			var tagliareggiseno=document.getElementById('tagliareggiseno').value;
			var numeroscarpe =document.getElementById('numeroscarpe').value;
			var misure=document.getElementById('misure').value;
			var coloreocchi= document.getElementById('coloreocchi').value;
			var colorecapelli=document.getElementById('colorecapelli').value;
			var tipocapelli=document.getElementById('tipocapelli').value;
			var segniparticolari=document.getElementById('segniparticolari').value;
		//	alert('here');
		
	if(altezza==""){
			alert('Campo altezza obbligatorio');
			return false;
		}else
		
		if(tagliapantaloni==""){
			alert('Campo taglia pantaloni obbligatorio');
			return false;
		}else
		
		if(tagliamaglietta==""){
			alert('Campo taglia maglietta obbligatorio');
			return false;
		}else
		
		if(numeroscarpe==""){
			alert('Campo numero scarpe obbligatorio');
			return false;
		}else
		
		//if(misure==""){
		//	alert('Campo misure obbligatorio');
		//	return false;
		//}else
		if(coloreocchi==""){
			alert('Campo colore occhi obbligatorio');
			return false;
		}else
		if(colorecapelli==""){
			alert('Campo colore capelli obbligatorio');
			return false;
		}else
		if(tipocapelli==""){
			alert('Campo tipo capelli obbligatorio');
			return false;
		}else{
	
		
		
	
	$.post("form/ajax/ajaxStep3Form.php",  {
		altezza:altezza,
		tagliapantaloni:tagliapantaloni,
		tagliamaglietta:tagliamaglietta,
		tagliareggiseno:tagliareggiseno,
		numeroscarpe:numeroscarpe,
		misure:misure,
		coloreocchi:coloreocchi,
		colorecapelli:colorecapelli,
		tipocapelli:tipocapelli,
		segniparticolari:segniparticolari
	}, function(data){
	//alert(data)
	document.getElementById('step3').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step3').style.display= 'block'
	});
		}
	}
	
	function cambioPasso3(){
	//alert("in");
	var titolostudio = document.getElementById('titolostudio').value;
	var studioattuale=document.getElementById('studioattuale').value;
	var formazionecomplementare=document.getElementById('formazionecomplementare').value;
	var lavoro=document.getElementById('lavoro').value;
	var conoscenzeinformatiche=document.getElementById('conoscenzeinformatiche').value;
	var lavorisvolti ="";//=document.getElementById('lavorisvolti').value;
	var altro=document.getElementById('altro').value;
	var hobby=document.getElementById('hobby').value;
	var rimborsotrasporto =""; 
	var rimborsotrasferta="";
	var disponibiletrasferte=""; 
	var note=document.getElementById('note').value;
	var automunito=document.getElementById('automunito').value;
	
	
	
	
	/*if(titolostudio==""){
			alert('Campo titolo studio obbligatorio');
			return false;
		}else
		
		if(studioattuale==""){
			alert('Campo studio attuale obbligatorio');
			return false;
		}else
		
		if(formazionecomplementare==""){
			alert('Campo formazione complementare obbligatorio');
			return false;
		}else
		
		if(lavoro==""){
			alert('Campo lavoro obbligatorio');
			return false;
		}else
		
		{
	*/
		
	
	
	
	for(i=0; i<document.step3form.lavorisvolti.length; i++){
		if(document.step3form.lavorisvolti[i].selected){
		//alert(document.step3form.lavorisvolti[i].value);
			lavorisvolti += document.step3form.lavorisvolti[i].value+"|";	
		}
	}
	/*
	for(i=0; i<document.step3form.rimborsotrasporto.length; i++){
		if(document.step3form.rimborsotrasporto[i].checked){
			rimborsotrasporto += document.step3form.rimborsotrasporto[i].value+"|";	
		}
	}
	
	for(i=0; i<document.step3form.rimborsotrasferta.length; i++){
		if(document.step3form.rimborsotrasferta[i].checked){
		rimborsotrasferta += document.step3form.rimborsotrasferta[i].value+"|";	
		}
	}
	*/
	for(i=0; i<document.step3form.disponibiletrasferte.length; i++){
		if(document.step3form.disponibiletrasferte[i].checked){
		disponibiletrasferte += document.step3form.disponibiletrasferte[i].value+"|";	
		}
	}
	//alert(rimborsotrasporto);
	
	
	$.post("form/ajax/ajaxStep4Form.php",  {
		titolostudio:titolostudio,
		studioattuale:studioattuale,
		formazionecomplementare:formazionecomplementare,
		lavoro:lavoro,
		conoscenzeinformatiche:conoscenzeinformatiche,
		lavorisvolti:lavorisvolti,
		altro:altro,
		hobby:hobby,
		automunito:automunito,
		disponibiletrasferte:disponibiletrasferte,
		note:note
		
	}, function(data){
//	alert(data)
	document.getElementById('step4').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step3').style.display='none'
	document.getElementById('step4').style.display= 'block'
	});
		//}
	}
	
	
	function cambioPasso4(){
//	alert("in");
	var mans = new Array();
	var cittapp = new Array();
	var mansione="";
	var cittappoggio="";
	
	
	
	
	var status = false;
	var statusApp = false;
	
	
	for(i=0; i<document.formans.mansioni.length; i++){
		if(document.formans.mansioni[i].selected){
	//	alert("nko");
		mans += document.formans.mansioni[i].value+",";	
		status=true;
		}
	}
	count= mans.length;
	//alert(status);
	if(status !=true){
		alert("Devi selezionare almeno una mansione");
	}
	//alert(count);
	mans = mans.substring(0,count-1);
	
	
	
	
	for(i=0; i<document.formans.cittappoggio.length; i++){
		if(document.formans.cittappoggio[i].selected){
		//alert("nko");
		cittapp += document.formans.cittappoggio[i].value+"|";
		status=true;
		}
	}
	count= cittapp.length;
	//alert(status);
	/*if(status !=true){
		alert("Devi selezionare almeno una mansione");
	}*/
	//alert(count);
	//cittapp = cittapp.substring(0,count-1);
	
	
	//alert(mans);
	$.post("form/ajax/ajaxStep5Form.php",  {
		mansione:mans,
		cittappoggio:cittapp
	}, function(data){
	//alert(data)
	document.getElementById('step5').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step4').style.display='none'
	document.getElementById('step3').style.display='none'
	document.getElementById('step5').style.display= 'block'
	});
		
	}
	/*
	function cambioPasso3(){
	//alert("in");
	var titolostudio = document.getElementById('titolostudio').value;
	var studioattuale=document.getElementById('studioattuale').value;
	var formazionecomplementare=document.getElementById('formazionecomplementare').value;
	var lavoro=document.getElementById('lavoro').value;
	var conoscenzeinformatiche=document.getElementById('conoscenzeinformatiche').value;
	var lavorisvolti ="";//=document.getElementById('lavorisvolti').value;
	var altro=document.getElementById('altro').value;
	var hobby=document.getElementById('hobby').value;
	var rimborsotrasporto =""; 
	var rimborsotrasferta="";
	var disponibiletrasferte=""; 
	var note=document.getElementById('note').value;
	var automunito=document.getElementById('automunito').value;
	
	for(i=0; i<document.step3form.lavorisvolti.length; i++){
		if(document.step3form.lavorisvolti[i].selected){
		alert(document.step3form.lavorisvolti[i].value);
			lavorisvolti += document.step3form.lavorisvolti[i].value+"|";	
		}
	}
	
	for(i=0; i<document.step3form.rimborsotrasporto.length; i++){
		if(document.step3form.rimborsotrasporto[i].checked){
			rimborsotrasporto += document.step3form.rimborsotrasporto[i].value+"|";	
		}
	}
	
	for(i=0; i<document.step3form.rimborsotrasferta.length; i++){
		if(document.step3form.rimborsotrasferta[i].checked){
		rimborsotrasferta += document.step3form.rimborsotrasferta[i].value+"|";	
		}
	}
	
	for(i=0; i<document.step3form.disponibiletrasferte.length; i++){
		if(document.step3form.disponibiletrasferte[i].checked){
		disponibiletrasferte += document.step3form.disponibiletrasferte[i].value+"|";	
		}
	}
	//alert(rimborsotrasporto);
	
	
	$.post("form/ajax/ajaxStep4Form.php",  {
		titolostudio:titolostudio,
		studioattuale:studioattuale,
		formazionecomplementare:formazionecomplementare,
		lavoro:lavoro,
		conoscenzeinformatiche:conoscenzeinformatiche,
		lavorisvolti:lavorisvolti,
		altro:altro,
		hobby:hobby,
		automunito:automunito,
		rimborsotrasporto:rimborsotrasporto,
		rimborsotrasferta:rimborsotrasferta,
		disponibiletrasferte:disponibiletrasferte,
		note:note
		
	}, function(data){
//	alert(data)
	document.getElementById('step4').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step3').style.display='none'
	document.getElementById('step4').style.display= 'block'
	});
		
	}
	*/
	/*
	function cambioPasso4(){
//	alert("in");
	var mans = new Array();
	
	
	for(i=0; i<document.formans.mansioni.length; i++){
		if(document.formans.mansioni[i].selected){
	//	alert(document.formans.mansioni[i].value);
		mans += document.formans.mansioni[i].value+",";	
		}
	}
	count= mans.length;
	alert(count);
	mans = mans.substring(0,count-1);
	
	
	
	alert(mans);
	$.post("form/ajax/ajaxStep5Form.php",  {
		mansione:mans
		
	}, function(data){
	//alert(data)
	document.getElementById('step5').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step4').style.display='none'
	document.getElementById('step3').style.display='none'
	document.getElementById('step5').style.display= 'block'
	});
		
	}
	*/
	
	function returnResult(path){
        percorso=path;
		var mansione = document.getElementById('mansione').value;
		var regione = document.getElementById('regione').value;
		var citta = document.getElementById('citta').value;

        if (regione !="" && citta !=""){
            alert("Puoi selezionare o una CITTA o una REGIONE!" );
            return false;
        }


	$.post(path+"/result.php",  {
		mansione:mansione,
		regione:regione,
		citta:citta
	}, function(data){
	//alert(data)
	document.getElementById('retResu').innerHTML = data
	document.getElementById('retResu').style.display= 'block'
	document.getElementById('result').style.display= 'none'
	});
		
	}
	
	
	
	function cambioPasso5(){
//	alert("in");

	//var pagamento = document.getElementById('pagamento').value;
	var nomebanca = document.getElementById('nomebanca').value;
	var intestatario = document.getElementById('intestatario').value;
	//var numerocarta = document.getElementById('numerocarta').value;
	var iban = document.getElementById('iban').value;
	
	$.post("form/ajax/ajaxStep6Form.php",  {
		
		nomebanca:nomebanca,
		intestatario:intestatario,
		iban:iban
	}, function(data){
	//alert(data)
	document.getElementById('step6').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step4').style.display='none'
	document.getElementById('step3').style.display='none'
	document.getElementById('step5').style.display='none'
	document.getElementById('step6').style.display= 'block'
	});
		
	}
	
	
	function cambioPasso6(){
//	alert("in");

	
	
	$.post("form/ajax/ajaxStep7Form.php",  {
		
		
		
		
	}, function(data){
	//alert(data)
	document.getElementById('step7').innerHTML = data
	document.getElementById('step2').style.display='none'
	document.getElementById('step1').style.display='none'
	document.getElementById('step4').style.display='none'
	document.getElementById('step6').style.display='none'
	document.getElementById('step3').style.display='none'
	document.getElementById('step5').style.display='none'
	document.getElementById('step7').style.display= 'block'
	});
		
	}
	
	
	
	function invia(){
	
	var step1 = document.getElementById('step1').value;
	var step2 = document.getElementById('step2').value;
	var step3 = document.getElementById('step3').value;
	var step4 = document.getElementById('step4').value;
	var step5 = document.getElementById('step5').value;
	
	//var cinese =document.formlang.cinese.value;
	var inglese =document.formlang.Inglese.value;
	var tedesco =document.formlang.tedesco.value;
	var francese =document.formlang.Francese.value;
	var russo =document.formlang.russo.value;
        var cinese =document.formlang.cinese.value;
        
        

        var status = false;
		if(cinese!="nop"){
		status=true;
		}else
		if(russo!="nop"){
		status=true;
		}else
		if(francese!="nop"){
		status=true;
		}else
		if(tedesco!="nop"){
		status=true;
		}else
		if(inglese!="nop"){
		status=true;
		}
		
	//	alert(arraLang);
                   
        if ( status==false){
            alert("selezionare almeno una lingua");
        }   else{
            
	$.post("form/ajax/ajaxInsertData.php",  {
		step1:step1,
		step2:step2,
		step3:step3,
		step4:step4,
		step5:step5,
		inglese:inglese,
                cinese:cinese,
                russo:russo,
                francese:francese,
                tedesco:tedesco
               

	});
	alert("Dati inseriti correttamente!")
	window.location.href = "./index.php";

	}}
	
	function giveProv(reg,path){
	//alert(reg);
     //   alert(path);
	var region = document.getElementById('regione').value;
	//alert(region);
	$.post(path+"/form/ajax/ajaxProv.php",  {
		region:region
	}, function(data){
	//alert(data);
	document.getElementById('city').innerHTML = data;
	document.getElementById('city').style.display= 'block';
	});


        
	
        }


        function logout_sess(path){
          
            $.post(path+"/ajax/ajaxSession.php");
              alert('Disconnessione');
            location.href=path+"/index.php";
             window.location.reload();
         }

	 function logout(path){
            location.href=path+"/index.php";
         }

    function login(path){
  
        var user= document.getElementById('username').value;
        var passwd= document.getElementById('password').value;


$.post(path+"/login.php",  {username:user,	password: passwd }, function(data){
	
        if(data=="1"){
        location.href=path+"/admin/index.php";
        }else{
	document.getElementById('resuLog').innerHTML = data;
	document.getElementById('log').style.display='none';
	document.getElementById('resuLog').style.display= 'block';
       dx=data.substring(0,6);
      
        if(dx == '111111'){
            return false;
        }else{
       window.location.reload();
        }
        }
    });
    }

    function getResultFromAjax(page,mans,citta){
	//alert(mans+" "+citta)
        $.post(percorso+"/result.php",  {page:page,mansione:mans,citta:citta}, function(data){
       // alert(data)
         document.getElementById('retResu').innerHTML ="";
        document.getElementById('retResu').innerHTML = data;
	document.getElementById('retResu').style.display= 'block';
	//document.getElementById('result').style.display= 'none';

        });

	}
	
	function modificaInfo(path){
    

var id= document.getElementById('id').value;

$.post(path+"/ajax/ajaxModInfoViewStaff.php",  { modulo:'info', id:id  }, function(data){
	//alert(data)
	document.getElementById('info').innerHTML = data;
	document.getElementById('box').style.display='none';
	document.getElementById('info').style.display= 'block';
	});

}

function modificaFisico(path){
var id= document.getElementById('id').value;
$.post(path+"/ajax/ajaxModInfoViewStaff.php",  { modulo:'fisico', id:id,path:path  }, function(data){
	//alert(data)
	document.getElementById('fisico').innerHTML = data;
	document.getElementById('fisicoview').style.display='none';
	document.getElementById('fisico').style.display= 'block';
	});

}

function modificaMans(path){
var id= document.getElementById('id').value;

$.post(path+"/ajax/ajaxModInfoViewStaff.php",  { modulo:'mansione', id:id  }, function(data){
	//alert(data)
	document.getElementById('mansione').innerHTML = data;
	document.getElementById('mansioneview').style.display='none';
	document.getElementById('mansione').style.display= 'block';
	});

}

function del(path,id,item){
   
//alert(id)
$.post(path+"/ajax/ajaxDelPhotoP.php",  { id:id, item:item  });
alert("Foto eliminata con successo!");
   window.location.reload();
}

function modificaFormazione(path){

var id= document.getElementById('id').value;
$.post(path+"/ajax/ajaxModInfoViewStaff.php",  { modulo:'formazione', id:id  }, function(data){
	//alert(data)
	document.getElementById('forma').innerHTML = data;
	document.getElementById('formaview').style.display='none';
	document.getElementById('forma').style.display= 'block';
	});

}

function updateInfo(k,v,path){
  //alert(k+v)

var id= document.getElementById('id').value;
$.post(path+"/ajax/ajaxUpdateinfoViewStaff.php",  { key:k, id:id, value:v  });

}

function updateForm(k,v,path){
  if(k=='automunito' && v=='SI' ){
    v=1;
}else if(k=='automunito' && v=='NO'){
    v=0;
}
var id= document.getElementById('id').value;
$.post(path+"/ajax/ajaxUpdateFisViewStaff.php",  { key:k, id:id, value:v});
}


function updateFis(k,v,path){
 // alert(k+v)
//alert(k+" "+v);
var id= document.getElementById('id').value;
$.post(path+"/ajax/ajaxUpdateFisViewStaff.php",  { key:k, id:id, value:v  });

}

function updateMans(k,v,t,path){
 
if (t==true){
    $.post(path+"/ajax/ajaxUpdatemansViewStaff.php",  { key:k,  value:v, model:"add"  });
}else{
    $.post(path+"/ajax/ajaxUpdatemansViewStaff.php",  { key:k,  value:v, model:"rem" });
}

}

function checkemail(){

var email = document.getElementById('email').value;
   $.post("ajax/ajaxCheckEmail.php",  {email:email}, function(data){
    if(data=='1'){
        
       alert("Questa email e gia stata usata per l'iscrizione");
       document.getElementById('sucpas').disabled=true;
       
       return false;
    }else{
        document.getElementById('sucpas').disabled=false;
    }

   });



}


function firstpic(path,id,file){

   $.post(path+"/ajax/ajaxChangePhotoProfile.php",  {id:id, file:file}, function(data){
   alert('La foto del profilo e\' stata modificata!!');
   window.location.reload();
   });

}



function checkcode(path){
   var code= document.getElementById('code').value;
   $.post(path+"/securimage/securimageCheck.php",  {code:code}, function(data){
   if(data=='1'){
       document.getElementById('sucpas').disabled=false;
       document.getElementById('butcode').disabled=true;

   }else{
        document.getElementById('sucpas').disabled=true;
        alert("CODICE DI SICUREZZA VUOTO O ERRATO!!!");
   }

   });
   
}


function getEvent(path){
   
   var eventid= document.getElementById('eventPart').value;
   if (eventid==""){

   }else{
   $.post(path+"/ajax/eventPart.php",  {eventid:eventid}, function(data){
   document.getElementById('partevent').innerHTML = data;
   document.getElementById('partevent').style.display= 'block';

   });
   }
}
