function showFiglio (codice,imgName) {
			
	altro_el = document.getElementById(codice).style; 
	//spanName = document.getElementById(imgName).style;
	
	if(altro_el.display == "") {
		altro_el.display = "none" ;
		//spanName.backgroundImage = "url(img/pallino.gif)" ;
		//spanName.backgroundRepeat = "no-repeat" ;
	}else {
		altro_el.display = "" ;
		//spanName.backgroundImage = "url(img/pallino.gif)" ;
		//spanName.backgroundRepeat = "no-repeat" ;
	}
}

function showFiglioManager (codice,imgName) {
			
	altro_el = document.getElementById(codice).style; 
	//spanName = document.getElementById(imgName).style;
	
	if(altro_el.display == "") {
		altro_el.display = "none" ;
		spanName.backgroundImage = "url(../img/bot_down.gif)" ;
		spanName.backgroundRepeat = "no-repeat" ;
	}else {
		altro_el.display = "" ;
		spanName.backgroundImage = "url(../img/bot_up.gif)" ;
		spanName.backgroundRepeat = "no-repeat" ;
	}
}

function toggleDisplayChiudiAltri(fO) {

  
	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	var num = document.getElementsByTagName('div');
 
 
 		// chiudi tutti e vafancul
		for (var i=0;i<num.length;i++) { 
			idx = num[i].id ;
					 
			arr = idx.split("_") ;
			 		 
			if (idx != fO) { 		 
				if (arr[0] == "bib") {   	 
	 				if(ie5 || ns6){ 
	 					document.getElementById(idx).style.display="none";
	 				}
	 				if(ie4){
	 					document.all[idx].style.display="none";
	 				} 
				} 		
			}
		}
		

 
 		
 		// apro quello selezioanto
 		toggleDisplay (fO) ;
		/*if(ie5 || ns6){
			document.getElementById(fO).style.display="inline";
		}
 		if(ie4){
 			document.all[fO].style.display="inline";
 		}*/
  
	
 	 
}

function toggleDisplayMenu(fO){

	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	

	
	
	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {
		document.getElementById(fO).style.display="inline";
		}else{
		document.getElementById(fO).style.display="none";
		}
	}
	
	if(ie4){
		if (document.all[fO].style.display=="none") {
		document.all[fO].style.display="inline";
		}else{
		document.all[fO].style.display="none";
		}
	}	
}

function toggleDisplay(fO){

	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	
	
	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {
		document.getElementById(fO).style.display="inline";
		}else{
		document.getElementById(fO).style.display="none";
		}
	}
	
	if(ie4){
		if (document.all[fO].style.display=="none") {
		document.all[fO].style.display="inline";
		}else{
		document.all[fO].style.display="none";
		}
	}	
}

function popup(url_pagina,w,h,sw_scroll) {

	
	  /*w = 500;
	  h = 400;*/
	  l = (screen.width - w) / 2;
	  t = (screen.height - h) / 2;
	
	  wnd = window.open(url_pagina,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+sw_scroll+", resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
	  wnd.focus();		

}

function riportaservizio(){
	var servizio = "" ;
	var id_servizio = 0 ;
	var descr_servizio = "" ;
	var id_descr_servizio = 0 ;
	
	id_servizio = document.form.id_servizio.options[form.id_servizio.selectedIndex].value;
	id_descr_servizio = document.form.id_descr_servizio.options[form.id_descr_servizio.selectedIndex].value ;
	
	servizio = document.form.id_servizio.options[form.id_servizio.selectedIndex].text ;
	descr_servizio = document.form.id_descr_servizio.options[form.id_descr_servizio.selectedIndex].text ;

	window.opener.document.form.id_servizio.value=id_servizio;
	window.opener.document.form.id_descr_servizio.value=id_descr_servizio;

	window.opener.document.form.servizio.value=servizio;
	window.opener.document.form.descr_servizio.value=descr_servizio;
self.close();	
}

function riportacommessa() {
		
	var commessa = "" ;
	var id_commessa_head = 0 ;
	var lavoro = "" ;
	var id_commessa_dett = 0 ;
	
	id_commessa_head = document.form.id_commessa_head.options[form.id_commessa_head.selectedIndex].value;
	id_commessa_dett = document.form.id_commessa_dett.options[form.id_commessa_dett.selectedIndex].value ;
	
	commessa = document.form.id_commessa_head.options[form.id_commessa_head.selectedIndex].text ;
	lavoro = document.form.id_commessa_dett.options[form.id_commessa_dett.selectedIndex].text ;
	
	window.opener.document.form.id_commessa_head.value=id_commessa_head;
	window.opener.document.form.id_commessa_dett.value=id_commessa_dett;

	window.opener.document.form.commessa.value=commessa;
	window.opener.document.form.lavoro.value=lavoro;
self.close();			
		} 

function riportalocalita(id_regione,id_provincia,id_comune,regione,provincia,comune) {

	window.opener.document.form.id_regione.value=id_regione;
	window.opener.document.form.id_provincia.value=id_provincia;
	window.opener.document.form.id_comune.value=id_comune;
	window.opener.document.form.regione.value=regione;
	window.opener.document.form.provincia.value=provincia;
	window.opener.document.form.comune.value=comune;

self.close();
}

function riportalocalita2(id_regione,id_provincia,id_comune,regione,provincia,comune) {
	
	window.opener.document.form.id_regione_2.value=id_regione;
	window.opener.document.form.id_provincia_2.value=id_provincia;
	window.opener.document.form.id_comune_2.value=id_comune;
	window.opener.document.form.regione_2.value=regione;
	window.opener.document.form.provincia_2.value=provincia;
	window.opener.document.form.comune_2.value=comune;

self.close();
}

function riporta_ctg(cod_ctg,categoria) {
	
	window.opener.document.form.cod_ctg.value=cod_ctg;
	window.opener.document.form.categoria.value=categoria;

self.close();
} 

function riporta_data(data,campo){
 
 Arr = data.split("-")
 
 datavisYYYY  = Arr[0] ; 
 datavisMM  = Arr[1] ; 
 datavisGG  = Arr[2] ; 
 
 if(datavisMM.length == 1) datavisMM = "0" + datavisMM ;
 if(datavisGG.length == 1) datavisGG = "0" + datavisGG ;

 datavis = datavisGG + "-" + datavisMM + "-" + datavisYYYY ;
 data = datavisYYYY + datavisMM + datavisGG ;


 if(campo == "data_in") {
	window.opener.document.form.data_in.value=data ;
	window.opener.document.form.data_in_vis.value=datavis ;
}
 if(campo == "data_out") {
	window.opener.document.form.data_out.value=data ;
	window.opener.document.form.data_out_vis.value=datavis ;
}
 if(campo == "data_fattura") {
	window.opener.document.form.data_fattura.value=data ;
	window.opener.document.form.data_fattura_vis.value=datavis ;
}
 if(campo == "data") { 
	window.opener.document.form.data.value=data ;
	window.opener.document.form.data_vis.value=datavis ;
}
 if(campo == "data_ch") { 
	window.opener.document.form.data_ch.value=data ;
	window.opener.document.form.data_ch_vis.value=datavis ;
}
 if(campo == "data_in_src") { 
	window.opener.document.form_src.data_in_src.value=data ;
	window.opener.document.form_src.data_in_src_vis.value=datavis ;
}
 if(campo == "data_out_src") { 
	window.opener.document.form_src.data_out_src.value=data ;
	window.opener.document.form_src.data_out_src_vis.value=datavis ;
}
 if(campo == "data_ddt") {
	window.opener.document.form.data_ddt.value=data ;
	window.opener.document.form.data_ddt_vis.value=datavis ;
}
 if(campo == "data_scadenza") {
	window.opener.document.form.data_scadenza.value=data ;
	window.opener.document.form.data_scadenza_vis.value=datavis ;
}
self.close();	
}

function riportalavoro(id_commessa_head,id_commessa_dett,commessa,lavoro) {
	window.opener.document.form.id_commessa_head.value=id_commessa_head ;
	window.opener.document.form.id_commessa_dett.value=id_commessa_dett ;
	window.opener.document.form.commessa.value=commessa ;
	window.opener.document.form.lavoro.value=lavoro ;
self.close();
}


function checkFormJob() { 	
		var swKO = 0 ;
		var msg = "" ;
 
		// sezione valida email
		var x = document.formjob.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		msg += "Indirizzo email inesatto.\n" ;
		swKO = 1 ;	
		} 

		
		
		 
		// sezione campi obbligatori
		if (document.formjob.nome.value == "" ) {
		msg += "Manca il nome.\n" ;
		swKO = 1 ;
		}
		if (document.formjob.cognome.value == "" ) {
		msg += "Manca il cognome.\n" ;
		swKO = 1 ;
		}	

		if (document.formjob.indirizzo.value == "" ) {
		msg += "Manca l\'indirizzo.\n" ;
		swKO = 1 ;
		}		

		if (document.formjob.cap.value == "" ) {
		msg += "Manca il CAP.\n" ;
		swKO = 1 ;
		}
			
		if (document.formjob.luogo_nascita.value == "" ) {
		msg += "Manca il luogo di nascita.\n" ;
		swKO = 1 ;
		}

		var provincia_nascita = document.forms['formjob'].provincia_nascita.options[0].selected ;
		var provincia_residenza = document.forms['formjob'].provincia_residenza.options[0].selected ;

		if(provincia_nascita == true) {
				msg += 'Devi specificare la provincia di nascita.\n';
				swKO = 1 ;	
		}
		if(provincia_residenza == true) {
				msg += 'Devi specificare la provincia di residenza.\n';
				swKO = 1 ;	
		}
		
		 
		if (document.formjob.nazionalita.value == "" ) {
		msg += "Manca la nazionalita.\n" ;
		swKO = 1 ;
		}
		if (document.formjob.email.value == "" ) {
		msg += "Manca la email.\n" ;
		swKO = 1 ;
		}		
		 
		var the_box1 = document.formjob.acconsento1[1].checked;
		var the_box2 = document.formjob.acconsento2[1].checked;
		 
		if (the_box1 == true) {
		msg += "Devi accettare la clausola 1.\n" ;
		swKO = 1 ;
		}
 		if (the_box2 == true) {
		msg += "Devi accettare la clausola 2.\n" ;
		swKO = 1 ;
		} 
		 
		 
				
		if (swKO == 1) {
		alert(msg);
		return false ;
			
		}  

}

function checkFormJobUk() { 	
		var swKO = 0 ;
		var msg = "" ;
 
		// sezione valida email
		var x = document.formjob.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		msg += "Bad email address.\n" ;
		swKO = 1 ;	
		} 

		// sezione campi obbligatori
		if (document.formjob.nome.value == "" ) {
		msg += "Name required.\n" ;
		swKO = 1 ;
		}
		if (document.formjob.cognome.value == "" ) {
		msg += "Surname required.\n" ;
		swKO = 1 ;
		}	

		if (document.formjob.indirizzo.value == "" ) {
		msg += "Address required.\n" ;
		swKO = 1 ;
		}		

		if (document.formjob.cap.value == "" ) {
		msg += "ZIP required.\n" ;
		swKO = 1 ;
		}
			
		if (document.formjob.luogo_nascita.value == "" ) {
		msg += "Place of birth required.\n" ;
		swKO = 1 ;
		}

		if (document.formjob.provincia_nascita.value == "" ) {
		msg += "Region/state of birth required.\n" ;
		swKO = 1 ;
		}
		
		if (document.formjob.provincia_residenza.value == "" ) {
		msg += "Region/state required.\n" ;
		swKO = 1 ;
		}

		if (document.formjob.nazionalita.value == "" ) {
		msg += "Nationality required.\n" ;
		swKO = 1 ;
		}
		if (document.formjob.email.value == "" ) {
		msg += "email required.\n" ;
		swKO = 1 ;
		}		
		 
		var the_box1 = document.formjob.acconsento1[1].checked;
		 
		if (the_box1 == true) {
		msg += "accept the privacy policy.\n" ;
		swKO = 1 ;
		} 
				
		if (swKO == 1) {
		alert(msg);
		return false ;
			
		}  

}

function checkFormRegistrati() { 	
		var swKO = 0 ;
		
 
		// sezione valida email
		var x = document.form.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		alert('Indirizzo email inesatto.');
		swKO = 1 ;	
		} 

		// sezione campi obbligatori
		if (document.form.nome.value == "" ) {
		alert('Manca il nome.');
		swKO = 1 ;
		}
		if (document.form.cognome.value == "" ) {
		alert('Manca il cognome.');
		swKO = 1 ;
		}	
		if (document.form.email.value == "" ) {
		alert('Manca l\' email.');
		swKO = 1 ;
		} 
 		if (document.form.login.value == "" ) {
		alert('Manca il login.');
		swKO = 1 ;
		}
		if (document.form.passwd.value == "" ) {
		alert('Manca la password.');
		swKO = 1 ;
		}
		
					
		if (swKO == 1) {
			 
		return false ;	
		}  

}

function checkFormContatto() { 	
		var swKO = 0 ;
		 
 
		// sezione valida email
		var x = document.contatto.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		alert('Indirizzo email inesatto.');
		swKO = 1 ;	
		} 

		// sezione campi obbligatori
		if (document.contatto.nome.value == "" ) {
		alert('Manca il nome.');
		swKO = 1 ;
		}
		if (document.contatto.azienda.value == "" ) {
		alert('Manca l\'azienda.');
		swKO = 1 ;
		}	
		if (document.contatto.email.value == "" ) {
		alert('Manca l\'email.');
		swKO = 1 ;
		} 
 		if (document.contatto.ruolo.value == "" ) {
		alert('Manca il ruolo.');
		swKO = 1 ;
		}
		if (document.contatto.tel.value == "" ) {
		alert('Manca il telefono.');
		swKO = 1 ;
		}
		if (document.contatto.cell.value == "" ) {
		alert('Manca il cellulare.');
		swKO = 1 ;
		}		
		var the_box1 = document.contatto.acconsento1[1].checked;
		
		 
		if (the_box1 == true) {
		alert('Devi accettare la clausola .');
		swKO = 1 ;
		}
 		 
					
		if (swKO == 1) {
			 
		return false ;	
		}  
}

function checkFormUtenteAdmin() { 	 
		var swKO = 0 ;

		// sezione campi obbligatori
		if (document.form.cognome.value == "" ) {
		alert('Manca il cognome.');
		swKO = 1 ;
		}

		if (document.form.nome.value == "" ) {
		alert('Manca il nome.');
		swKO = 1 ;
		}
		if (document.form.rag_soc.value == "" ) {
		alert('Manca la ragione sociale.');
		swKO = 1 ;
		}	
		if (document.form.login.value == "" ) {
		alert('Manca la login.');
		swKO = 1 ;
		} 
 		if (document.form.passwd.value == "" ) {
		alert('Manca la password.');
		swKO = 1 ;
		}
		if (document.form.id_tipo_utente.value == "" ) {
		alert('Manca il tipo utente.');
		swKO = 1 ;
		}
				
		if (swKO == 1) {	 
		return false ;	
		}   

}

function checkFormCommessaAdmin() {
		var swKO = 0 ;

		// sezione campi obbligatori
		if (document.form.numero.value == "" ) {
		alert('Manca il numero.');
		swKO = 1 ;
		}

		if (document.form.data_in.value == "" ) {
		alert('Manca la data di inizio.');
		swKO = 1 ;
		}
		if (document.form.id_cliente.value == "" ) {
		alert('Manca il cliente.');
		swKO = 1 ;
		}	
		if (document.form.commessa.value == "" ) {
		alert('Manca il nome della commessa.');
		swKO = 1 ;
		} 
 		if (document.form.lavoro.value == "" ) {
		alert('Manca il lavoro.');
		swKO = 1 ;
		}
		if (document.form.id_servizio.value == "" ) {
		alert('Manca il servizio.');
		swKO = 1 ;
		}
		if (document.form.id_descr_servizio.value == "" ) {
		alert('Manca la descrizione del servizio.');
		swKO = 1 ;
		}				
		if (swKO == 1) {	 
		return false ;	
		}   	
}


	function showDett(id) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxDettaglio");
 
		l = (screen.width - 590) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l  ;
		e.style.top =  t -20 ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxDettaglio").style.display=="none") {
				document.getElementById("boxDettaglio").style.display="inline";
				sw=1 ;
			}
		}
		
		if(ie4){
			if (document.all["boxDettaglio"].style.display=="none") {
				document.all["boxDettaglio"].style.display="inline";
				sw=1 ;
			}	
		}
		
		
		 
		if (sw){
			makeRequestIdSpan('php/AJ.php?action=commessa&id_commessa_head='+id,'boxDettaglio') ;
		}

	}
	
	function showLavoroDett(id_commessa_dett,id_commessa_head) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxLavoroDettaglio");
 
		
		l = (screen.width - 590) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l +20 ;
		e.style.top =  t  ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxLavoroDettaglio").style.display=="none") {
				document.getElementById("boxLavoroDettaglio").style.display="inline";
				sw=1 ;
			}
		}
		
		if(ie4){
			if (document.all["boxLavoroDettaglio"].style.display=="none") {
				document.all["boxLavoroDettaglio"].style.display="inline";
				sw=1 ;
			}	
		}
		
		
		 
		if (sw){
			makeRequestIdSpan('php/AJ.php?action=lavoro&id_commessa_dett='+id_commessa_dett+'&id_commessa_head='+id_commessa_head,'boxLavoroDettaglio') ;
		}

	}	
 
	function showFaseDett(id_fase,id_commessa_dett,id_commessa_head) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxFaseDettaglio");
 
		
		l = (screen.width - 590) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l +40 ;
		e.style.top =  t +20 ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxFaseDettaglio").style.display=="none") {
				document.getElementById("boxFaseDettaglio").style.display="inline";
				sw=1 ;
			}
		}
		
		if(ie4){
			if (document.all["boxFaseDettaglio"].style.display=="none") {
				document.all["boxFaseDettaglio"].style.display="inline";
				sw=1 ;
			}	
		}
		
		
		 
		if (sw){
			makeRequestIdSpan('php/AJ.php?action=fase&id_fase='+id_fase+'&id_commessa_dett='+id_commessa_dett+'&id_commessa_head='+id_commessa_head,'boxFaseDettaglio') ;
		}

	}	 

function showBriefingDett(id_briefing) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxDettaglio");
 
		l = (screen.width - 650) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l  ;
		e.style.top =  t  ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxDettaglio").style.display=="none") {
				document.getElementById("boxDettaglio").style.display="inline";
				sw=1 ;
			}
		}
		
		if(ie4){
			if (document.all["boxDettaglio"].style.display=="none") {
				document.all["boxDettaglio"].style.display="inline";
				sw=1 ;
			}	
		}
		
		
		 
		if (sw){
			makeRequestIdSpan('php/AJ.php?action=edit&center=briefing&AJPopup=1&id_briefing='+id_briefing,'boxDettaglio') ;
		}	
}

function showCommessaWPDett (id_commessa_head) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxDettaglio");
 
		l = (screen.width - 590) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l  ;
		e.style.top =  t -20 ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxDettaglio").style.display=="none") {
				document.getElementById("boxDettaglio").style.display="inline";
				sw=1 ;
			}
		}
		
		if(ie4){
			if (document.all["boxDettaglio"].style.display=="none") {
				document.all["boxDettaglio"].style.display="inline";
				sw=1 ;
			}	
		}
		
		
		 
		if (sw){
			makeRequestIdSpan('php/AJ.php?action=dettaglioCmsByUtente&center=commessa&id_commessa_head='+id_commessa_head,'boxDettaglio') ;
		}	
}

function resetJob(tipo) {
	
	if (tipo == "lavoro") {
		for (i = 0; i < formjob.US_Durata_Collaborazione.length; i++) {
			formjob.US_Durata_Collaborazione[i].checked = false ;
		}
	}
	
	if (tipo == "lingue") {
		for (i = 0; i < formjob.inglese_lingua.length; i++) {
			formjob.inglese_lingua[i].checked = false ;
		}
		for (i = 0; i < formjob.francese_lingua.length; i++) {
			formjob.francese_lingua[i].checked = false ;
		}
		for (i = 0; i < formjob.tedesco_lingua.length; i++) {
			formjob.tedesco_lingua[i].checked = false ;
		}
		for (i = 0; i < formjob.spagnolo_lingua.length; i++) {
			formjob.spagnolo_lingua[i].checked = false ;
		}
	}
	
	if (tipo == "altrelingue") {
		for (i = 0; i < formjob.altre_uno_lingua.length; i++) {
			formjob.altre_uno_lingua[i].checked = false ;
		}
		for (i = 0; i < formjob.altre_due_lingua.length; i++) {
			formjob.altre_due_lingua[i].checked = false ;
		}		
	}
} 

	function showOreuomoDett(id_commessa_head) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxOreuomoDettaglio");
 
		
		l = (screen.width - 590) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l +40 ;
		e.style.top =  t +20 ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxOreuomoDettaglio").style.display=="none") {
				document.getElementById("boxOreuomoDettaglio").style.display="inline";
				sw=1 ;
			}
		}
		
		if(ie4){
			if (document.all["boxOreuomoDettaglio"].style.display=="none") {
				document.all["boxOreuomoDettaglio"].style.display="inline";
				sw=1 ;
			}	
		}
		
		
		 
		if (sw){
			makeRequestIdSpan('php/AJ.php?action=oreuomo&id_commessa_head='+id_commessa_head,'boxOreuomoDettaglio') ;
		}

	}		
/*
	------------------------------------------------------------------
	HTTP_REQUEST
*/	
 
	function makeRequestIdSpan(url,idSpan) {
		
		this.idSpan = idSpan ;
		http_request = checkHttpRequest() ;

	  http_request.onreadystatechange = alertContentsProdLista ;
		http_request.open('GET', url, true);
		http_request.send(true);
			
	}	
	
	function alertContentsProdLista() {
		
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				changeHtml () ;
			} else {
				alert('There was a problem with the request.');
			}
		} else {
			loading () ;	
		}
   }
    
	function loading () {
		var text =  "" ;
		text = "<img src=\"../img/spinner.gif\"><span class=\"text\">Loading ...</span>" ; 
		eval('document.getElementById(\''+this.idSpan+'\').innerHTML = text ;') ; 	
	}

	
	function changeHtml() {
		this.rispostaHtml = http_request.responseText ;
		eval('document.getElementById(\''+this.idSpan+'\').innerHTML = http_request.responseText;') ;
		
		
		// per LOGIN
		if(this.rispostaHtml == 'LOGIN OK'){ 
			location.href = "manager/" ;
		}
	}
    	
    	
    function checkHttpRequest() {
		http_request = false;
		
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/xml');
				
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		
		if (!http_request) {
		alert('Browser obsoleto.\n\nScarica un nuovo browser\nsiamo nel 2006 !!!!  ');
		return false;
		}
		
		return http_request ;
	}
/*
		fine HTTP_REQUEST
		------------------------------------------------------------------
*/



 

 


function toggleNLetterSrc(fO) {
	
	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	
	
	// a prescindere stuto l'altro
	if(ie5 || ns6){
		if(fO == "src_email"){
			document.getElementById('src_gruppo').style.display="none";
		} else {
			document.getElementById('src_email').style.display="none";
		}
	}
	if(ie4){
		if(fO == "src_email"){
			document.all['src_gruppo'].style.display="none";
		} else {
			document.all['src_email'].style.display="none";
		}
	}	
	
	toggleDisplay(fO);
	
}
 
function checkBriefing() { 	
		var swKO = 0 ;
		var msg = "" ;

		// sezione campi obbligatori
		if (document.form.titolo.value == "" ) {
		msg += "Manca il titolo.\n" ;
		swKO = 1 ;
		}
		if (document.form.briefing.value == "" ) {
		msg += "Manca il messaggio.\n" ;
		swKO = 1 ;
		}	
		if (document.form.data.value == "" ) {
		msg += "Manca la data.\n" ;
		swKO = 1 ;
		}
		 
				
		if (swKO == 1) {
		alert(msg);
		return false ;
			
		}  

}



function showDbDett(id_utente,subaction) {
		var sw = 0 ;
		var ns4 = (document.layers);
		var ie4 = (document.all && !document.getElementById);
		var ie5 = (document.all && document.getElementById);
		var ns6 = (!document.all && document.getElementById);

		e=document.getElementById("boxDettaglio");
 
		l = (screen.width - 650) / 2;
		t = (screen.height - 500) / 2;
		
		e.style.left =  l  ;
		e.style.top =  t  ; 
		
		
		if(ie5 || ns6){
			 
			
			if (document.getElementById("boxDettaglio").style.display=="none") {
				document.getElementById("boxDettaglio").style.display="inline";
				
			}
		}
		
		if(ie4){
			if (document.all["boxDettaglio"].style.display=="none") {
				document.all["boxDettaglio"].style.display="inline";
				
			}	
		}
		
		var ajaxObj = new ClassAJAX();
		ajaxObj.setExecute(true) ;
		ajaxObj.setElement("boxDettaglio") ;
		ajaxObj.runAJAX('./php/AJ.php?&center=wpdb&action=dbdati&id_utente='+id_utente+'&subaction='+subaction) ;	
		

}


/* FATTURE */


function scriviCommessaFattura(id_cliente) { 

	//var id_cliente = document.form.id_cliente.options[document.form.id_cliente.selectedIndex].value ;
	var url = "./php/AJ.php?action=fatturaShowCommessa" ;
	url += "&id_cliente="+id_cliente ;
	
	
	
	
	var ajaxObj = new ClassAJAX() ;
	ajaxObj.setExecute(true) ;	
	ajaxObj.setElement('contenitoreCommessa') ;
	
	
	ajaxObj.runAJAX (url) ;
	
	try {
		document.getElementById('tdSalvaBozza').style.display="none";
		document.getElementById('contenitoreCliente').style.display="none"; 
	}catch(e){}
	
	
	
}

function checkTestaFattura() {
	var swKO = 0 ;
	var msg = "" ;
	
	
	if (document.form.data_fattura.value == "" ) {
		msg += "Manca la data.\n" ;
		swKO = 1 ;
	}
	
	 
	if (swKO == 1) {
		alert(msg);
		return false ;		
	} else {
		return true ;	
	}
}

function riportaInFattura(id_commessa_dett,id_cliente,tdLavoro) {

	//var id_cliente = document.form.id_cliente.options[document.form.id_cliente.selectedIndex].value ;
	var num_fattura = document.form.num_fattura.value ;
	var data_fattura = document.form.data_fattura.value ;
	var data_scadenza = document.form.data_scadenza.value ;
	var mod_pagamento = document.form.mod_pagamento.value ;
	var rif_ddt = document.form.rif_ddt.value ;
	var data_ddt = document.form.data_ddt.value ;

	var url = "./php/AJ.php?action=fatturaLavoroInsert" ;
	url += "&id_cliente="+id_cliente ;
	url += "&num_fattura="+num_fattura ;
	url += "&data_fattura="+data_fattura ;
	url += "&id_commessa_dett="+id_commessa_dett ;
	url += "&data_scadenza="+data_scadenza ;
	url += "&mod_pagamento="+mod_pagamento ;
	url += "&rif_ddt="+rif_ddt ;
	url += "&data_ddt="+data_ddt ;


	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX (url) ;			
	
	var html = "" ;
	var htmlOld = "" ;
	
	myInterval = window.setInterval(
	function() { 
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
			
			if (htmlOld == html) { 
			
				window.clearInterval(myInterval);
				
				
				
				eval ("document.getElementById('"+tdLavoro+"').className='tdListOFF'") ;
				fatturaReload();
				
				/*var elem = document.getElementById('debug') ;	
				elem.style.display = "" ;
				elem.innerHTML = html ;*/
			}
		} 
	} 
	,1) ;

}

 

function deleteLavoroFattura(id_fattura_dett,id_commessa_dett) {
	
	var url = "./php/AJ.php?action=fatturaLavorodelete" ;
	url += "&id_fattura_dett="+id_fattura_dett ;
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX (url) ;			
	
	var html = "" ;
	var htmlOld = "" ;
	
	myInterval = window.setInterval(
	function() { 
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
			
			if (htmlOld == html) { 
			
				window.clearInterval(myInterval);
				
				
				eval ("document.getElementById('tdLavoro_"+id_commessa_dett+"').className='tdList'") ;
				fatturaReload();
				
				/*var elem = document.getElementById('debug') ;	
				elem.style.display = "" ;
				elem.innerHTML = html ;*/
			}
		} 
	} 
	,1) ;
	
	
}

function fatturaReload() {
	
	num_fattura_head = document.form.num_fattura_head.value ;
	var url = "./php/AJ.php?action=fatturaDettaglio" ;
	url += "&num_fattura_head="+num_fattura_head ;
	
	var ajaxObj = new ClassAJAX() ;
	ajaxObj.setExecute(true) ;	
	ajaxObj.setElement('contenitoreLavoro') ;

	ajaxObj.runAJAX (url) ;
}

function commassaDettShow() {
	var id_commessa_head = document.form.id_commessa_head_select.options[document.form.id_commessa_head_select.selectedIndex].value ;
	var url = "../manager/php/AJ.php?action=briefingCommessaDettaglio" ;
	url += "&id_commessa_head="+id_commessa_head ;
	
	 
	
	var ajaxObj = new ClassAJAX() ;
	ajaxObj.setExecute(true) ;	
	ajaxObj.setElement('commessaDettTD') ;

	ajaxObj.runAJAX (url) ;
	
	//document.getElementById('commessaDettTR').style.display="inline";
	
}


function salvaBozzaFattura(id_cliente) { 

	var check = checkTestaFattura() ;
	
	if (check) {
	
	var returnConfirm = confirm('Stai salvando una fattura in bozza\nAssegni il numero fattura ad un cliente\nil corpo fattura lo aggiornerai dopo\n\nSicuro ?');

		if (returnConfirm) {
			var num_fattura = document.form.num_fattura.value ;
			var data_fattura = document.form.data_fattura.value ;
			var data_scadenza = document.form.data_scadenza.value ;
			var mod_pagamento = document.form.mod_pagamento.value ;
			var rif_ddt = document.form.rif_ddt.value ;
			var data_ddt = document.form.data_ddt.value ;  
			
			
			var url = "./php/AJ.php?action=fatturaBozzaSave" ;
			url += "&num_fattura="+num_fattura ;
			url += "&data_fattura="+data_fattura ;
			url += "&data_scadenza="+data_scadenza ;
			url += "&data_ddt="+data_ddt ;
			url += "&mod_pagamento="+mod_pagamento ;
			url += "&rif_ddt="+rif_ddt ;
			url += "&id_cliente="+id_cliente ;
			
			
			// salvo la fattura
			 
			var ajaxObj = new ClassAJAX();
			ajaxObj.setExecute(false) ;
			ajaxObj.setReturn(true) ;
			ajaxObj.runAJAX (url) ;			
			
			var html = "" ;
			var htmlOld = "" ;
			
			myInterval = window.setInterval(
			function() { 
				htmlOld = html ;
				html = ajaxObj.getHtml() ;
				if (html != false) {
					
					if (htmlOld == html) { 
					
						window.clearInterval(myInterval);
 
						fatturaSalvataShow(html) ;
						
						var elem = document.getElementById('debug') ;	
						elem.style.display = "" ;
						elem.innerHTML = html ;
					}
				} 
			} 
			,1) ;
		} 		
	
		 
	} else {
		return false ;	
	}
			
}		 


function salvaFattura() { 

	var check = checkTestaFattura() ;
	
	if (check) {
		
		

		var returnConfirm = confirm('Sicuro di salvare questa fattura?');

		if (returnConfirm) {
			
			var num_fattura = document.form.num_fattura.value ;
			var data_fattura = document.form.data_fattura.value ;
			var data_scadenza = document.form.data_scadenza.value ;
			var mod_pagamento = document.form.mod_pagamento.value ;
			var rif_ddt = document.form.rif_ddt.value ;
			var id_cliente = document.form.id_cliente.value ;
			var data_ddt = document.form.data_ddt.value ;  
			 
			try {
			var editBozza = document.form.editBozza.value ;  
			}catch(e){editBozza = "";}
			
			var url = "./php/AJ.php?action=fatturaSave" ;
			url += "&num_fattura="+num_fattura ;
			url += "&data_fattura="+data_fattura ;
			url += "&data_scadenza="+data_scadenza ;
			url += "&data_ddt="+data_ddt ;
			url += "&mod_pagamento="+mod_pagamento ;
			url += "&rif_ddt="+rif_ddt ;
			url += "&id_cliente="+id_cliente ;
			url += "&editBozza="+editBozza ;
		
			
			
			

			// salvo la fattura
			
			var ajaxObj = new ClassAJAX();
			ajaxObj.setExecute(false) ;
			ajaxObj.setReturn(true) ;
			ajaxObj.runAJAX (url) ;			
			
			var html = "" ;
			var htmlOld = "" ;
			
			myInterval = window.setInterval(
			function() { 
				htmlOld = html ;
				html = ajaxObj.getHtml() ;
				if (html != false) {
					
					if (htmlOld == html) { 
					
						window.clearInterval(myInterval);

						fatturaSalvataShow(html) ;
						
						var elem = document.getElementById('debug') ;	
						elem.style.display = "" ;
						elem.innerHTML = html ;
					}
				} 
			} 
			,1) ;
					
	
		}
	} else {
		return false ;	
	}
}

function fatturaSalvataShow(num_fattura) {
	var url = "./php/AJ.php?action=fatturaSalavataShow" ;
	url += "&num_fattura="+num_fattura ;
	
	 
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(true) ;
	ajaxObj.setElement('contenitoreTotale') ;

	ajaxObj.runAJAX (url) ;
}

function anteprimaFattura(session_id) {
	var num_fattura = document.form.num_fattura.value ;
	var data_fattura = document.form.data_fattura.value ;
	var data_scadenza = document.form.data_scadenza.value ;
	var mod_pagamento = document.form.mod_pagamento.value ;
	var rif_ddt = document.form.rif_ddt.value ;
	var data_ddt = document.form.data_ddt.value ;
	
	var url = "popupfattura.php?sw_anteprima=1&" ;
	url += "num_fattura_temp="+session_id ;
	url += "&data_fattura="+data_fattura ;
	url += "&data_scadenza="+data_scadenza ;
	url += "&mod_pagamento="+mod_pagamento ;
	url += "&rif_ddt="+rif_ddt ;
	url += "&data_ddt="+data_ddt ;
	url += "&num_fattura="+num_fattura ;
	
	
	popup(url) ;	
}


function fatturaClienteSrc(){
	
	var rag_soc_src = document.form.rag_soc_src.value ;
	var url = "./php/AJ.php?action=fatturaClienteSrc" ;
	
	url += "&rag_soc_src="+rag_soc_src ;
	
	
	var ajaxObj = new ClassAJAX() ;
	ajaxObj.setExecute(true) ;	
	ajaxObj.setElement('contenitoreCliente') ;
	
	
	ajaxObj.runAJAX (url) ;
	 
	
}