<?php
include("../sessionreserved.php");
include("../../db.php");

//estraggo i dettagli della visita
$result = mysql_query("
	SELECT *, 
	DATE_FORMAT(datavisita,'%d/%m/%Y') AS datavisitaOK,
	DATE_FORMAT(data_inizlav,'%d/%m/%Y') AS data_inizlavOK,
	DATE_FORMAT(data_finelav,'%d/%m/%Y') AS data_finelavOK,
	DATE_FORMAT(data_prossvisita,'%d/%m/%Y') AS data_prossvisitaOK
	
	FROM visite 
	LEFT JOIN visite_imp ON visite.idvisita = visite_imp.idvisita 
	LEFT JOIN users ON visite.userid = users.userid
	WHERE visite.idvisita = '".$_GET['id']."'
	AND dir = '".$_SESSION['dir']."'
	");
	
if(mysql_num_rows($result) > 0){
$rlstAnagr = mysql_result($result,0,'anagrafica');
$idvisita = mysql_result($result,0,'idvisita');
$codice = mysql_result($result,0,'codice');
$userid = mysql_result($result,0,'userid'); 
$datavisita = mysql_result($result,0,'datavisitaOK');
$percontodi = mysql_result($result,0,'percontodi');
$tipovisita = mysql_result($result,0,'tipovisita'); 
$tipovisita == 'aziendale' ? $aziendale = ' checked="checked"' : $aziendale = '';
$tipovisita == 'richiesta' ? $richiesta = ' checked="checked"' : $richiesta = '';
$tipovisita == 'pos' ? $pos = ' checked="checked"' : $pos = '';
$tipovisita == 'altro' ? $altro = ' checked="checked"' : $altro = '';

$tipoaltro = mysql_result($result,0,'tipoaltro'); 
$nvisita = mysql_result($result,0,'nvisita');

mysql_result($result,0,'congiunta') == 1 ? $congiunta = ' checked="checked"' : $congiunta = '';
$congiuntadesc = mysql_result($result,0,'congiuntadesc');

$id_comune = mysql_result($result,0,'id_comune');
$id_strada = mysql_result($result,0,'id_strada');
$id_numero = mysql_result($result,0,'id_numero');

$cant_comune = mysql_result($result,0,'cant_comune');
$cant_strada = mysql_result($result,0,'cant_strada');

$custom_comune = mysql_result($result,0,'custom_comune');
$custom_strada = mysql_result($result,0,'custom_strada');
$custom_numero = mysql_result($result,0,'custom_numero');

if($custom_comune <> ''){
	$customCheck = ' checked="checked"';
	$showcustom = 'block';
	$showexact = 'none';
}else{
	$showexact = 'block';
	$showcustom = 'none';
}

mysql_result($result,0,'lavpubblico') == 1 ? $lavpubblico1 = ' checked="checked"' : $lavpubblico2 = ' checked="checked"';

$commit_anagra = mysql_result($result,0,'commit_anagra'); 
$commit_piva = mysql_result($result,0,'commit_piva'); 
$commit_codfis = mysql_result($result,0,'commit_codfis'); 
$commit_via = mysql_result($result,0,'commit_via'); 
$commit_n = mysql_result($result,0,'commit_n'); 
$commit_comune = mysql_result($result,0,'commit_comune'); 
$commit_prov = mysql_result($result,0,'commit_prov'); 
$commit_tel = mysql_result($result,0,'commit_tel'); 
$codnat = mysql_result($result,0,'codnat'); 
$codtiponat = mysql_result($result,0,'codtiponat'); 
$partecip1 = mysql_result($result,0,'partecip1'); 
$partecip2 = mysql_result($result,0,'partecip2'); 
$partecip3 = mysql_result($result,0,'partecip3'); 
$partecip4 = mysql_result($result,0,'partecip4'); 
$partecip1_funz = mysql_result($result,0,'partecip1_funz'); 
$partecip2_funz = mysql_result($result,0,'partecip2_funz');
$partecip3_funz = mysql_result($result,0,'partecip3_funz'); 
$partecip4_funz = mysql_result($result,0,'partecip4_funz'); 
$note = mysql_result($result,0,'note'); 

mysql_result($result,0,'psc_vis') == 1 ? $psc_vis = ' checked="checked"' : NULL;
mysql_result($result,0,'psc_vis') == 2 ? $psc_vis2 = ' checked="checked"' : NULL;
mysql_result($result,0,'psc_ido') == 1 ? $psc_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'psc_ido') == 2 ? $psc_ido2 = ' checked="checked"' : NULL;
mysql_result($result,0,'pos_vis') == 1 ? $pos_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'pos_vis') == 2 ? $pos_vis2 = ' checked="checked"' : NULL;
mysql_result($result,0,'pos_ido') == 1 ? $pos_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'pos_ido') == 2 ? $pos_ido2 = ' checked="checked"' : NULL;
mysql_result($result,0,'pss_vis') == 1 ? $pss_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'pss_vis') == 2 ? $pss_vis2 = ' checked="checked"' : NULL;
mysql_result($result,0,'pss_ido') == 1 ? $pss_ido = ' checked="checked"' : NULL;
mysql_result($result,0,'pss_ido') == 2 ? $pss_ido2 = ' checked="checked"' : NULL;

mysql_result($result,0,'docinfo_vis') == 1 ? $docinfo_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'docinfo_vis') == 2 ? $docinfo_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'docinfo_ido') == 1 ? $docinfo_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'docinfo_ido') == 2 ? $docinfo_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'libretti_vis') == 1 ? $libretti_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'libretti_vis') == 2 ? $libretti_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'libretti_ido') == 1 ? $libretti_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'libretti_ido') == 2 ? $libretti_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'reginf_vis') == 1 ? $reginf_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'reginf_vis') == 2 ? $reginf_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'reginf_ido') == 1 ? $reginf_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'reginf_ido') == 2 ? $reginf_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'duvri_vis') == 1 ? $duvri_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'duvri_vis') == 2 ? $duvri_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'duvri_ido') == 1 ? $duvri_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'duvri_ido') == 2 ? $duvri_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi1_dist') == 1 ? $dpi1_dist = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi1_dist') == 2 ? $dpi1_dist2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi1_form') == 1 ? $dpi1_form = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi1_form') == 2 ? $dpi1_form2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi2_dist') == 1 ? $dpi2_dist = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi2_dist') == 2 ? $dpi2_dist2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi2_form') == 1 ? $dpi2_form = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi2_form') == 2 ? $dpi2_form2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi3_dist') == 1 ? $dpi3_dist = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi3_dist') == 2 ? $dpi3_dist2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi3_form') == 1 ? $dpi3_form = ' checked="checked"' : NULL; 
mysql_result($result,0,'dpi3_form') == 2 ? $dpi3_form2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'rchimico_vis') == 1 ? $rchimico_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'rchimico_vis') == 2 ? $rchimico_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'rchimico_ido') == 1 ? $rchimico_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'rchimico_ido') == 2 ? $rchimico_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'rvibraz_vis') == 1 ? $rvibraz_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'rvibraz_vis') == 2 ? $rvibraz_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'rvibraz_ido') == 1 ? $rvibraz_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'rvibraz_ido') == 2 ? $rvibraz_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'rrumore_vis') == 1 ? $rrumore_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'rrumore_vis') == 2 ? $rrumore_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'rrumore_ido') == 1 ? $rrumore_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'rrumore_ido') == 2 ? $rrumore_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'pimus_vis') == 1 ? $pimus_vis = ' checked="checked"' : NULL; 
mysql_result($result,0,'pimus_vis') == 2 ? $pimus_vis2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'pimus_ido') == 1 ? $pimus_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'pimus_ido') == 2 ? $pimus_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'orario_vis') == 1 ? $orario_vis = ' checked="checked"' : NULL;
mysql_result($result,0,'orario_vis') == 2 ? $orario_vis2 = ' checked="checked"' : NULL;
mysql_result($result,0,'orario_ido') == 1 ? $orario_ido = ' checked="checked"' : NULL; 
mysql_result($result,0,'orario_ido') == 2 ? $orario_ido2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'servizi_pres') == 1 ? $servizi_pres = ' checked="checked"' : NULL; 
mysql_result($result,0,'servizi_pres') == 2 ? $servizi_pres2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'servizi_norma') == 1 ? $servizi_norma = ' checked="checked"' : NULL; 
mysql_result($result,0,'servizi_norma') == 2 ? $servizi_norma2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'spogliat_pres') == 1 ? $spogliat_pres = ' checked="checked"' : NULL; 
mysql_result($result,0,'spogliat_pres') == 2 ? $spogliat_pres2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'spogliat_norma') == 1 ? $spogliat_norma = ' checked="checked"' : NULL; 
mysql_result($result,0,'spogliat_norma') == 2 ? $spogliat_norma2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'mensa_pres') == 1 ? $mensa_pres = ' checked="checked"' : NULL; 
mysql_result($result,0,'mensa_pres') == 2 ? $mensa_pres2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'mensa_norma') == 1 ? $mensa_norma = ' checked="checked"' : NULL; 
mysql_result($result,0,'mensa_norma') == 2 ? $mensa_norma2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'cassetta_pres') == 1 ? $cassetta_pres = ' checked="checked"' : NULL;
mysql_result($result,0,'cassetta_pres') == 2 ? $cassetta_pres2 = ' checked="checked"' : NULL;
mysql_result($result,0,'cassetta_norma') == 1 ? $cassetta_norma = ' checked="checked"' : NULL; 
mysql_result($result,0,'cassetta_norma') == 2 ? $cassetta_norma2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'numeri_pres') == 1 ? $numeri_pres = ' checked="checked"' : NULL; 
mysql_result($result,0,'numeri_pres') == 2 ? $numeri_pres2 = ' checked="checked"' : NULL; 
mysql_result($result,0,'numeri_norma') == 1 ? $numeri_norma = ' checked="checked"' : NULL;
mysql_result($result,0,'numeri_norma') == 2 ? $numeri_norma2 = ' checked="checked"' : NULL;

$data_prossvisita = mysql_result($result,0,'data_prossvisitaOK'); 
$ora_prossvisita = substr(mysql_result($result,0,'ora_prossvisita'),0,5); 
mysql_result($result,0,'chiuso') == 1 ? $chiuso = ' checked="checked"' : $chiuso = '';
mysql_result($result,0,'completata') == 1 ? $completata = ' checked="checked"' : $completata = '';
$coord_x = mysql_result($result,0,'coord_x'); 
$coord_y = mysql_result($result,0,'coord_y'); 
$dataora = mysql_result($result,0,'dataora'); 

if($coord_x == 0)
	$mapHide = ' display:none';
	
//impresa
$idvisitaimp = intval(mysql_result($result,0,'idvisitaimp')); 
$idvisitaimp > 0 ? $impHide = ' style="display:block"' : $impHide = '';
$idvisita = mysql_result($result,0,'idvisita'); 
$imp_anagrafica = mysql_result($result,0,'imp_anagrafica'); 
$imp_comune = mysql_result($result,0,'imp_comune'); 
$imp_prov = mysql_result($result,0,'imp_prov'); 
$imp_indirizzo = mysql_result($result,0,'imp_indirizzo'); 
$imp_numero = mysql_result($result,0,'imp_numero'); 
$imp_piva = mysql_result($result,0,'imp_piva'); 
$imp_codfisc = mysql_result($result,0,'imp_codfisc'); 

$imp_esterna = mysql_result($result,0,'imp_esterna');
$imp_esterna == 1 ? $EXT = ' checked="checked"' : $EXT = '';
$imp_esterna == 2 ? $INT = ' checked="checked"' : $INT = '';

$imp_assoc = mysql_result($result,0,'imp_assoc');
$imp_assoc == 'COL' ? $COL = ' checked="checked"' : $COL = '';
$imp_assoc == 'CNA' ? $CNA = ' checked="checked"' : $CNA = '';
$imp_assoc == 'CON' ? $CON = ' checked="checked"' : $CON = '';

$imp_tel = mysql_result($result,0,'imp_tel'); 
$imp_fax = mysql_result($result,0,'imp_fax'); 
$imp_email = mysql_result($result,0,'imp_email');  
$imp_attivita = mysql_result($result,0,'imp_attivita'); 
$ccnl = mysql_result($result,0,'ccnl'); 
$ccnl == 'ind' ? $ccnlind = ' checked="checked"' : $ccnlind = '';
$ccnl == 'art' ? $ccnlart = ' checked="checked"' : $ccnlart = '';
$ccnl == 'altro' ? $ccnlaltro= ' checked="checked"' : $ccnlaltro = '';
$ccnl_altro = mysql_result($result,0,'ccnl_altro'); 
$tipologiacod = mysql_result($result,0,'tipologiacod');  
$lavorazionecod = mysql_result($result,0,'lavorazionecod'); 
$attivitacod = mysql_result($result,0,'attivitacod'); 
$rls = mysql_result($result,0,'rls'); 
$n_addetti = mysql_result($result,0,'n_addetti'); 
$n_operai = mysql_result($result,0,'n_operai'); 
$n_impiegati = mysql_result($result,0,'n_impiegati'); 
$n_apprendisti = mysql_result($result,0,'n_apprendisti'); 
$n_interinali = mysql_result($result,0,'n_interinali'); 
$n_parttime = mysql_result($result,0,'n_parttime'); 
$n_autonomi = mysql_result($result,0,'n_autonomi'); 
$n_addettipres = mysql_result($result,0,'n_addettipres'); 
$data_inizlav = mysql_result($result,0,'data_inizlavOK'); 
$data_finelav = mysql_result($result,0,'data_finelavOK');
if($data_inizlav == '00/00/0000')
	$data_inizlav = '';
if($data_finelav == '00/00/0000')
	$data_finelav = '';
if($data_prossvisita == '00/00/0000')
	$data_prossvisita = '';
}
$gravita = mysql_result($result,0,'gravita');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Osservatorio Edile Biella - C.P.T. | Modifica visita</title>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAvnzqYxi83_Kgi00fv8YJyRSQ2BMzX7Vse3YRADHpruIA_5wdfBTuS_-_g9D8QDYRKpiBXG69dEO1Vw"></script>
<script language="javascript" src="../js/script.js"></script>
<script language="javascript" src="js/rlst.js"></script>
<script language="javascript" src="js/maps.js"></script>
<script language="javascript" src="../maps/js/maps.js"></script>

<script language="javascript">
function initializeEmbed() {
	var tmpx = document.getElementById('COORD_X').value * 1;
	var tmpy = document.getElementById('COORD_Y').value * 1;
	if(tmpx > 0){
		if (GBrowserIsCompatible()) {
			var mapEmbed = new GMap2(document.getElementById("mapEmbed"));
			mapEmbed.enableScrollWheelZoom();
			mapEmbed.setCenter(new GLatLng(tmpx, tmpy), 15);
			
			var point = new GLatLng(tmpx, tmpy);
			mapEmbed.addOverlay(new GMarker(point));
		}
	}
}
</script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>

<body onload="initializeEmbed()">

<div id="header"></div>
<div id="container">
	<div id="mainHeader" class="clearfix"><?php include("mainHeader.php");?></div>
	<?php include("mainMenu.php");?>
    <div id="mainContainer">
        <span class="mainContentTitle">Apportare le modifiche necessarie alla visita visualizzata. <span style="float:right">COD. <?php echo $codice;?></span></span>
        <div id="mainContent" class="clearfix">
            <form name="newCant" method="post" action="visita_editsave.php" onsubmit="return ver_cant()">
            <div class="form clearfix">
            	<div class="row">
                	Il Geometra <strong><?php echo $rlstAnagr;?></strong> 
                    in qualit&agrave; di tecnico C.P.T. ha effettuato 
                    in Data <input name="datavisita" type="text" id="datavisita" size="10" maxlength="10" value="<?php echo $datavisita;?>" />
            		per conto di
                    <select name="percontodi" id="percontodi">
                    <option selected="selected" value="0"></option>
                    <?php
					$result = mysql_query("SELECT * FROM users WHERE zona <> '' AND dir = '".$_SESSION['dir']."' ORDER BY anagrafica");
						while($row = mysql_fetch_array($result)){
							$row['userid'] == $percontodi ? $selPerC = ' selected="selected"' : $selPerC = '';
							echo '<option value="'.$row['userid'].'"'.$selPerC.'>'.utf8_encode($row['anagrafica']).'</option>';
						}
					?>
                    </select>
                </div>
                <div class="row">
                    <input<?php echo $aziendale;?> class="check" type="radio" name="tipovisita" value="aziendale" /> Visita aziendale &nbsp;&nbsp;
                    <input<?php echo $richiesta;?> class="check" type="radio" name="tipovisita" value="richiesta" /> Visita richiesta &nbsp;&nbsp;
                    <input<?php echo $pos;?> class="check" type="radio" name="tipovisita" value="pos" /> Visione P.O.S. &nbsp;&nbsp;
                    <input<?php echo $altro;?> class="check" type="radio" name="tipovisita" value="altro" /> 
                    altro <input type="text" name="tipoaltro" value="<?php echo $tipoaltro;?>" maxlength="50" />
                </div>
            	<div class="row">
                	Visita n. <?php echo $nvisita;?> &nbsp;&nbsp; 
                    <input type="hidden" name="nvisita" value="<?php echo $nvisita;?>" /> &nbsp;&nbsp;
                    <input<?php echo $congiunta;?> name="congiunta" type="checkbox" class="check" value="1" /> Visita congiunta 
                    <input value="<?php echo $congiuntadesc;?>" type="text" name="congiuntadesc" maxlength="100" size="40" onkeyup="checkcontrol('newCant','congiunta',this.value)" />
                </div>
            	<div class="sep"></div>
            	<div class="row" id="exactindirizzo" style="display:<?php echo $showexact;?>">
                    Cantiere: Comune 
                   	<select id="ID_COMUNE" name="ID_COMUNE" onChange="stradario('via',this.value,'strad_via')">
                    <option value="0"></option>
                    <?php
					$result = mysql_query("SELECT * FROM civici_provbi GROUP BY Nome_Comun ORDER BY Nome_Comun");
						while($row = mysql_fetch_array($result)){
							if($row['Codice_Com'] == $id_comune){
								$sel = ' selected="selected"';
								$COORD_X_comune = $row['Coord_X'];
								$COORD_Y_comune = $row['Coord_Y'];
							}else{
								$sel = '';
							}
							echo '<option'.$sel.' value="'.$row['Codice_Com'].'">'.utf8_encode($row['Nome_Comun']).'</option>';
						}
					?>
                    </select>
                    <span id="strad_via">
					<?php
                    if(!empty($id_comune)){
                        $result = mysql_query("SELECT * FROM civici_provbi WHERE Codice_Com = '".$id_comune."' GROUP BY ID_STRADA ORDER BY Via");
                        if(mysql_num_rows($result) > 0){
                            echo 'Via <select id="ID_STRADA" name="ID_STRADA" onChange="stradario(\'civico\',this.value,\'strad_civico\')">';
                            echo '<option value="0"></option>';
                            while($row = mysql_fetch_array($result)){
								if($row['ID_STRADA'] == $id_strada){
									$sel = ' selected="selected"';
									$COORD_X_via = $row['Coord_X'];
									$COORD_Y_via = $row['Coord_Y'];
								}else{
									$sel = '';
								}
                                echo '<option'.$sel.' value="'.$row['ID_STRADA'].'">'.utf8_encode($row['Via']).'</option>';
							}
                            echo '</select>';		
                            
                            //scrivo le coordinate della via
                            echo '<input type="hidden" name="COORD_X_comune" id="COORD_X_comune" value="'.$COORD_X_comune.'" />';
                            echo '<input type="hidden" name="COORD_Y_comune" id="COORD_Y_comune" value="'.$COORD_Y_comune.'" />';
                            echo '<input type="hidden" name="cant_comune" id="cant_comune" value="'.$cant_comune.'" />';
                            
                        }
                    }
                    ?>               
                    </span>
                    <span id="strad_civico">
                    <?php
					//elenco civici
					if(!empty($id_strada)){
						$result = mysql_query("SELECT * FROM civici_provbi WHERE ID_STRADA = '".$id_strada."' GROUP BY NUMERO ORDER BY NUMERO*1");
						if(mysql_num_rows($result) > 0){
							echo 'n. <select name="ID_NUMERO" id="ID_NUMERO" onChange="stradario(\'coord\',this.value,\'strad_coord\')">';
							echo '<option value="0"></option>';
							while($row = mysql_fetch_array($result)){
								if($row['NUMERO'] == $id_numero && $id_numero <> ''){
									$sel = ' selected="selected"';
									$coord_x = $row['Coord_X'];
									$coord_y = $row['Coord_Y'];
								}else{
									$sel = '';
								}
								echo '<option'.$sel.' value="'.$row['NUMERO'].'">'.utf8_encode($row['NUMERO']).'</option>';
							}
							echo '</select>';
						
							//scrivo le coordinate della via
							echo '<input type="hidden" name="COORD_X_via" id="COORD_X_via" value="'.COORD_X_via.'" />';
							echo '<input type="hidden" name="COORD_Y_via" id="COORD_Y_via" value="'.COORD_Y_via.'" />';
							echo '<input type="hidden" name="cant_strada" id="cant_strada" value="'.$cant_strada.'" />';
						}else{
							echo 'Elenco civici non disponibile';
						}
					}
					
					?>
                    </span>
                    <span id="strad_coord">
						<input type="hidden" name="COORD_X" id="COORD_X" value="<?php echo $coord_x;?>" />
						<input type="hidden" name="COORD_Y" id="COORD_Y" value="<?php echo $coord_y;?>" />
                    </span>
                 </div>
				 <div class="row">
                    <input class="check" type="checkbox" onclick="customInd(this.checked)"<?php echo $customCheck;?> /> Fuori provincia <br />
                </div>
                <div class="row" id="customindirizzo"  style="display:<?php echo $showcustom;?>">
                    Comune <input type="text" size="30" id="custom_comune" name="custom_comune" maxlength="60" value="<?php echo $custom_comune;?>" /> 
                    indirizzo <input type="text" id="custom_strada" name="custom_strada" size="50" maxlength="255" value="<?php echo $custom_strada;?>" /> 
                    n. <input type="text" id="custom_numero" name="custom_numero" size="4" maxlength="20" value="<?php echo $custom_numero;?>" /> 
                </div>                 
            	<div class="row">
                    <center>
					<div id="mapEmbed" style="width:875px; height:180px;<?php echo $mapHide;?>"></div>
                    </center>
                </div>
            	<div class="row">
                    Lavoro: &nbsp;&nbsp;
                    <input<?php echo $lavpubblico1;?> class="check" type="radio" name="lavpubblico" value="1" /> pubblico
                    <input<?php echo $lavpubblico2;?> class="check" type="radio" name="lavpubblico" value="0" /> privato
                </div>
            	<div class="row">
                    Committente <input value="<?php echo $commit_anagra;?>" type="text" name="commit_anagra" maxlength="255" /> 
                    P.iva <input value="<?php echo $commit_piva;?>" type="text" name="commit_piva" maxlength="11" /> 
                    C.f. <input value="<?php echo $commit_codfis;?>" type="text" name="commit_codfis" maxlength="16" />
                </div>
            	<div class="row">
                    via <input value="<?php echo $commit_via;?>" type="text" name="commit_via" maxlength="100" /> 
                    n <input value="<?php echo $commit_n;?>" type="text" size="4" name="commit_n" maxlength="16" /> 
                    Comune <input value="<?php echo $commit_comune;?>" type="text" name="commit_comune" maxlength="100" />
                    prov <input value="<?php echo $commit_prov;?>" type="text" size="2" name="commit_prov" maxlength="2" /> 
                    tel <input value="<?php echo $commit_tel;?>" type="text" name="commit_tel" maxlength="50" /> 
                </div>
            	<div class="row">
                    Natura dell'opera:
					<select name="codnat" onChange="natopera(this.value)">
                    <option></option>
					<?php
					$result = mysql_query("SELECT * FROM natopera GROUP BY codnat ORDER BY nat");
						while($row = mysql_fetch_array($result)){
							$row['codnat'] == $codnat ? $sel = ' selected="selected"' : $sel = '';
							echo '<option'.$sel.' value="'.$row['codnat'].'">'.utf8_encode($row['nat']).'</option>';
						}
					?>
					</select>
                	<span id="natopera02">
                    <?php
					//elenco vie
					$result = mysql_query("SELECT * FROM natopera WHERE codnat = '".$codnat."' AND codtiponat > 0 GROUP BY codtiponat ORDER BY tiponat");
					if(mysql_num_rows($result) > 0){
						echo 'Dettaglio: <select id="codtiponat" name="codtiponat">';
						echo '<option></option>';
						while($row = mysql_fetch_array($result)){
							$row['codtiponat'] == $codtiponat ? $sel = ' selected="selected"' : $sel = '';
							echo '<option'.$sel.' value="'.$row['codtiponat'].'">'.utf8_encode($row['tiponat']).'</option>';
						}
						echo '</select>';	
					}
                    ?>
                    </span>
                </div>
            	
                <div class="sep"></div>
            	
                <!-- impresa -->
                
                <div class="row rowTitle">
                	<button type="button" onclick="lightShow('on','../imprese.php')">Seleziona impresa</button>
                	<a name="impresa" id="impresa"></a>
                </div>
                
               <div id="impHide"<?php echo $impHide;?>>
               
               <div class="row">
                    Ragione Sociale Impresa <input value="<?php echo $imp_anagrafica;?>" name="imp_anagrafica" type="text" size="50" maxlength="255" /> 
                    Comune sede legale <input value="<?php echo $imp_comune;?>" name="imp_comune" type="text" maxlength="100" />
                    Provincia <input value="<?php echo $imp_prov;?>" size="3" name="imp_prov" type="text" maxlength="2" />
                </div>
                <div class="row">
                    via <input value="<?php echo $imp_indirizzo;?>" name="imp_indirizzo" type="text" size="35" maxlength="100" /> 
                    n. <input value="<?php echo $imp_imp_numero;?>" name="imp_numero" type="text" size="4" maxlength="16" /> 
                    P.iva <input value="<?php echo $imp_piva;?>" name="imp_piva" type="text" maxlength="11" /> 
                    C.f. <input value="<?php echo $imp_codfisc;?>" name="imp_codfisc" type="text" maxlength="16" />
                </div>
            	<div class="row">
                	Ditta: &nbsp;&nbsp;<input<?php echo $EXT;?> class="check" type="radio" name="imp_esterna" value="1" /> esterna &nbsp;&nbsp;
                    <input<?php echo $INT;?> class="check" type="radio" name="imp_esterna" value="2" /> iscritta a Cassa Edile &nbsp;&nbsp;&nbsp;&nbsp;
                    associata: <input<?php echo $COL;?> class="check" type="radio" name="imp_assoc" value="COL" /> Collegio costruttori &nbsp;&nbsp;
                    <input<?php echo $CNA;?> class="check" type="radio" name="imp_assoc" value="CNA" /> Cna &nbsp;&nbsp;
                    <input<?php echo $CON;?> class="check" type="radio" name="imp_assoc" value="CON" /> Confartigianato
                </div>
            	<div class="row">
					Tel <input value="<?php echo $imp_tel;?>" name="imp_telefono" type="text" maxlength="50" /> 
                    Fax <input value="<?php echo $imp_fax;?>" name="imp_fax" type="text" maxlength="50" /> 
                    E-Mail <input value="<?php echo $imp_email;?>" name="imp_email" maxlength="255" size="45" type="text" />
				</div>
                <div class="row">
                	Attivit&agrave; svolta <input value="<?php echo $imp_attivita;?>" name="imp_attivita" type="text" size="50" maxlength="255" /> 
                    CCNL edilizia: &nbsp;&nbsp;
                    <input class="check" type="radio" name="ccnl" value="ind"<?php echo $ccnlind;?> /> ind &nbsp;&nbsp;
                    <input class="check" type="radio" name="ccnl" value="art"<?php echo $ccnlart;?> /> art &nbsp;&nbsp;
                    <input class="check" type="radio" name="ccnl" value="altro"<?php echo $ccnlaltro;?> /> altro 
                    <input value="<?php echo $ccnl_altro;?>" type="text" name="ccnl_altro" maxlength="50" />
                </div>
                <div class="row attspec">
                   	<strong>Specifica attivit&agrave; svolta in cantiere:</strong><br /><br />
                    <span id="tipologiacod">
                    1) Tipologia: <select name="tipologiacod" onChange="attspec(this,'lavorazionecod')">
                    <option selected="selected"></option>
                    <?php
					$result = mysql_query("SELECT * FROM attivitaspec GROUP BY tipologiacod");
						while($row = mysql_fetch_array($result)){
							$row['tipologiacod'] == $tipologiacod ? $sel = ' selected="selected"' : $sel = '';
							echo '<option'.$sel.' value="'.$row['tipologiacod'].'">'.utf8_encode($row['tipologia']).'</option>';
						}
					?>
                    </select>
                    </span>
                    <span id="lavorazionecod">
                    <?php
					if(!empty($lavorazionecod)){
						$result = mysql_query("SELECT * FROM attivitaspec WHERE lavorazionecod = '".$lavorazionecod."' AND lavorazione <> '' GROUP BY lavorazionecod");
						if(mysql_num_rows($result) > 0){
							echo '2) Lavorazione: <select name="lavorazionecod" onChange="attspec(this,\'attivitacod\')">';
							echo '<option></option>';
							while($row = mysql_fetch_array($result)){
								$row['lavorazionecod'] == $lavorazionecod ? $sel = ' selected="selected"' : $sel = '';
								echo '<option'.$sel.' value="'.$row['lavorazionecod'].'">'.utf8_encode($row['lavorazione']).'</option>';
							}
							echo '</select>';		
						}
						
					}
					?>
                    </span>
                    <span id="attivitacod">
                    <?php
					if(!empty($attivitacod)){						
						$result = mysql_query("SELECT * FROM attivitaspec WHERE lavorazionecod = '".$lavorazionecod."' AND attivita <> '' GROUP BY attivitacod");
						if(mysql_num_rows($result) > 0){
							echo '3) Attivit&agrave;: <select name="attivitacod">';
							echo '<option></option>';
							while($row = mysql_fetch_array($result)){
								$row['attivitacod'] == $attivitacod ? $sel = ' selected="selected"' : $sel = '';
								echo '<option'.$sel.' value="'.$row['attivitacod'].'">'.utf8_encode($row['attivita']).'</option>';
							}
							echo '</select>';		
						}
						
					}
					?>
                    </span>
                 </div>
                <div class="row">
                    RLS int. Sign <input value="<?php echo $rls;?>" type="text" size="35" name="rls" maxlength="100" />
                </div>
                <div class="row">
                	<table class="standard" cellspacing="0" cellpadding="0">
                      <tr>
                        <td>&nbsp;</td>
                        <td width="13%">n. addetti</td>
                        <td width="13%">operai</td>
                        <td width="13%">impiegati</td>
                        <td width="13%">apprendisti</td>
                        <td width="13%">interinali</td>
                        <td width="13%">part time</td>
                        <td width="13%">lav. autonomi</td>
                      </tr>
                      <tr>
                        <td>Totali</td>
                        <td><input value="<?php echo $n_addetti;?>" type="text" size="3" name="n_addetti" maxlength="4" /></td>
                        <td><input value="<?php echo $n_operai;?>" type="text" size="3" name="n_operai" maxlength="4" /></td>
                        <td><input value="<?php echo $n_impiegati;?>" type="text" size="3" name="n_impiegati" maxlength="4" /></td>
                        <td><input value="<?php echo $n_apprendisti;?>" type="text" size="3" name="n_apprendisti" maxlength="4" /></td>
                        <td><input value="<?php echo $n_interinali;?>" type="text" size="3" name="n_interinali" maxlength="4" /></td>
                        <td><input value="<?php echo $n_parttime;?>" type="text" size="3" name="n_parttime" maxlength="4" /></td>
                        <td><input value="<?php echo $n_autonomi;?>" type="text" size="3" name="n_autonomi" maxlength="4" /></td>
                      </tr>
                    </table>
                </div>
                <div class="row">
                	n. addetti presenti <input value="<?php echo $n_addettipres;?>" type="text" size="3" name="n_addettipres" maxlength="4" /> 
                    Data inizio lavori <input value="<?php echo $data_inizlav;?>" type="text" size="10" name="data_inizlav" maxlength="10" /> 
                    Data fine lavori <input value="<?php echo $data_finelav;?>" type="text" size="10" name="data_finelav" maxlength="10" />
                </div>
                </div>
                
                <!-- fine selezione impresa -->
                
                
                <div class="row">
                    <table class="standard" width="100%" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="34%">Partecipanti</td>
                        <td width="34%">Funzione</td>
                        <td width="32%">Firma</td>
                      </tr>
                      <tr>
                        <td><input value="<?php echo $partecip1;?>" type="text" size="40" name="partecip1" maxlength="100" /></td>
                        <td><input value="<?php echo $partecip1_funz;?>" type="text" size="40" name="partecip1_funz" maxlength="100" /></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td><input value="<?php echo $partecip2;?>" type="text" size="40" name="partecip2" maxlength="100" /></td>
                        <td><input value="<?php echo $partecip2_funz;?>" type="text" size="40" name="partecip2_funz" maxlength="100" /></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td><input value="<?php echo $partecip3;?>" type="text" size="40" name="partecip3" maxlength="100" /></td>
                        <td><input value="<?php echo $partecip3_funz;?>" type="text" size="40" name="partecip3_funz" maxlength="100" /></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td><input value="<?php echo $partecip4;?>" type="text" size="40" name="partecip4" maxlength="100" /></td>
                        <td><input value="<?php echo $partecip4_funz;?>" type="text" size="40" name="partecip4_funz" maxlength="100" /></td>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                </div>
                
                <div class="row">
                	<center><strong>Documenti Visionati</strong></center>
                </div>
                <div class="row">
                	<table align="left" class="docVisionati" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="20%">visionato</td>
                        <td>&nbsp;</td>
                        <td width="20%">idoneo</td>
                      </tr>
                      <tr>
                        <td><input name="psc_vis" type="radio" class="check" value="1"<?php echo $psc_vis;?> /> si <input name="psc_vis" type="radio" class="check" value="2"<?php echo $psc_vis2;?> /> no</td>
                        <td>Piano di Sicurezza Cantiere</td>
                        <td><input name="psc_ido" type="radio" class="check" value="1"<?php echo $psc_ido;?> /> si <input name="psc_ido" type="radio" class="check" value="2"<?php echo $psc_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="pos_vis" type="radio" class="check" value="1"<?php echo $pos_vis;?> /> si <input name="pos_vis" type="radio" class="check" value="2"<?php echo $pos_vis2;?> /> no</td>
                        <td>Piano Operativo Sicurezza</td>
                        <td><input name="pos_ido" type="radio" class="check" value="1"<?php echo $pos_ido;?> /> si <input name="pos_ido" type="radio" class="check" value="2"<?php echo $pos_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="pss_vis" type="radio" class="check" value="1"<?php echo $pss_vis;?> /> si <input name="pss_vis" type="radio" class="check" value="2"<?php echo $pss_vis2;?> /> no</td>
                        <td>Piano Sost. Sicurezza</td>
                        <td><input name="pss_ido" type="radio" class="check" value="1"<?php echo $pss_ido;?> /> si <input name="pss_ido" type="radio" class="check" value="2"<?php echo $pss_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="docinfo_vis" type="radio" class="check" value="1"<?php echo $docinfo_vis;?> /> si <input name="docinfo_vis" type="radio" class="check" value="2"<?php echo $docinfo_vis2;?> /> no</td>
                        <td>Documenti di info/formazione</td>
                        <td><input name="docinfo_ido" type="radio" class="check" value="1"<?php echo $pdocinfo_ido;?> /> si <input name="docinfo_ido" type="radio" class="check" value="2"<?php echo $docinfo_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="libretti_vis" type="radio" class="check" value="1"<?php echo $libretti_vis;?> /> si <input name="libretti_vis" type="radio" class="check" value="2"<?php echo $libretti_vis2;?> /> no</td>
                        <td>Libretti/manuali</td>
                        <td><input name="libretti_ido" type="radio" class="check" value="1"<?php echo $libretti_ido;?> /> si <input name="libretti_ido" type="radio" class="check" value="2"<?php echo $libretti_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="reginf_vis" type="radio" class="check" value="1"<?php echo $reginf_vis;?> /> si <input name="reginf_vis" type="radio" class="check" value="2"<?php echo $reginf_vis2;?> /> no</td>
                        <td>Registro infortuni</td>
                        <td><input name="reginf_ido" type="radio" class="check" value="1"<?php echo $reginf_ido;?> /> si <input name="reginf_ido" type="radio" class="check" value="2"<?php echo $reginf_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="duvri_vis" type="radio" class="check" value="1"<?php echo $duvri_vis;?> /> si <input name="duvri_vis" type="radio" class="check" value="2"<?php echo $duvri_vis2;?> /> no</td>
                        <td>D.u.v.r.</td>
                        <td><input name="duvri_ido" type="radio" class="check" value="1"<?php echo $duvri_ido;?> /> si <input name="duvri_ido" type="radio" class="check" value="2"<?php echo $duvri_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td class="newline">distribuiti</td>
                        <td class="newline">&nbsp;</td>
                        <td class="newline">formazione</td>
                      </tr>
                      <tr>
                        <td><input name="dpi1_dist" type="radio" class="check" value="1"<?php echo $dpi1_dist;?> /> si <input name="dpi1_dist" type="radio" class="check" value="2"<?php echo $dpi1_dist2;?> /> no</td>
                        <td>D.P.I. tipo 1</td>
                        <td><input name="dpi1_form" type="radio" class="check" value="1"<?php echo $dpi1_form;?> /> si <input name="dpi1_form" type="radio" class="check" value="2"<?php echo $dpi1_form2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="dpi2_dist" type="radio" class="check" value="1"<?php echo $dpi2_dist;?> /> si <input name="dpi2_dist" type="radio" class="check" value="2"<?php echo $dpi2_dist2;?> /> no</td>
                        <td>D.P.I. tipo 2</td>
                        <td><input name="dpi2_form" type="radio" class="check" value="1"<?php echo $dpi2_form;?> /> si <input name="dpi2_form" type="radio" class="check" value="2"<?php echo $dpi2_form2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="dpi3_dist" type="radio" class="check" value="1"<?php echo $dpi3_dist;?> /> si <input name="dpi3_dist" type="radio" class="check" value="2"<?php echo $dpi3_dist2;?> /> no</td>
                        <td>D.P.I. tipo 3</td>
                        <td><input name="dpi3_form" type="radio" class="check" value="1"<?php echo $dpi3_form;?> /> si <input name="dpi3_form" type="radio" class="check" value="2"<?php echo $dpi3_form2;?> /> no</td>
                      </tr>
                    </table>
                	
                    <table align="right" class="docVisionati" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="20%">visionato</td>
                        <td>&nbsp;</td>
                        <td width="20%">idoneo</td>
                      </tr>
                      <tr>
                        <td><input name="rchimico_vis" type="radio" class="check" value="1"<?php echo $rchimico_vis;?> /> si <input name="rchimico_vis" type="radio" class="check" value="2"<?php echo $rchimico_vis2;?> /> no</td>
                        <td>Rischio chimico</td>
                        <td><input name="rchimico_ido" type="radio" class="check" value="1"<?php echo $rchimico_ido;?> /> si <input name="rchimico_ido" type="radio" class="check" value="2"<?php echo $rchimico_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="rvibraz_vis" type="radio" class="check" value="1"<?php echo $rvibraz_vis;?> /> si <input name="rvibraz_vis" type="radio" class="check" value="2"<?php echo $rvibraz_vis2;?> /> no</td>
                        <td>Rischio vibrazioni</td>
                        <td><input name="rvibraz_ido" type="radio" class="check" value="1"<?php echo $rvibraz_ido;?> /> si <input name="rvibraz_ido" type="radio" class="check" value="2"<?php echo $rvibraz_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="rrumore_vis" type="radio" class="check" value="1"<?php echo $rrumore_vis;?> /> si <input name="rrumore_vis" type="radio" class="check" value="2"<?php echo $rrumore_vis2;?> /> no</td>
                        <td>Rischio rumore</td>
                        <td><input name="rrumore_ido" type="radio" class="check" value="1"<?php echo $rrumore_ido;?> /> si <input name="rrumore_ido" type="radio" class="check" value="2"<?php echo $rrumore_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="pimus_vis" type="radio" class="check" value="1"<?php echo $pimus_vis;?> /> si <input name="pimus_vis" type="radio" class="check" value="2"<?php echo $pimus_vis2;?> /> no</td>
                        <td>Pimus</td>
                        <td><input name="pimus_ido" type="radio" class="check" value="1"<?php echo $pimus_ido;?> /> si <input name="pimus_ido" type="radio" class="check" value="2"<?php echo $pimus_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="orario_vis" type="radio" class="check" value="1"<?php echo $orario_vis;?> /> si <input name="orario_vis" type="radio" class="check" value="2"<?php echo $orario_vis2;?> /> no</td>
                        <td>Orario lavoro</td>
                        <td><input name="orario_ido" type="radio" class="check" value="1"<?php echo $orario_ido;?> /> si <input name="orario_ido" type="radio" class="check" value="2"<?php echo $orario_ido2;?> /> no</td>
                      </tr>
                      <tr>
                        <td class="newline">presenti</td>
                        <td class="newline">&nbsp;</td>
                        <td class="newline">a norma</td>
                      </tr>
                      <tr>
                        <td><input name="servizi_pres" type="radio" class="check" value="1"<?php echo $servizi_pres;?> /> si <input name="servizi_pres" type="radio" class="check" value="2"<?php echo $servizi_pres2;?> /> no</td>
                        <td>Servizi igienici</td>
                        <td><input name="servizi_norma" type="radio" class="check" value="1"<?php echo $servizi_norma;?> /> si <input name="servizi_norma" type="radio" class="check" value="2"<?php echo $servizi_norma2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="spogliat_pres" type="radio" class="check" value="1"<?php echo $spogliat_pres;?> /> si <input name="spogliat_pres" type="radio" class="check" value="2"<?php echo $spogliat_pres2;?> /> no</td>
                        <td>Spogliatoio/ricovero</td>
                        <td><input name="spogliat_norma" type="radio" class="check" value="1"<?php echo $spogliat_norma;?> /> si <input name="spogliat_norma" type="radio" class="check" value="2"<?php echo $spogliat_norma2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="mensa_pres" type="radio" class="check" value="1"<?php echo $mensa_pres;?> /> si <input name="mensa_pres" type="radio" class="check" value="2"<?php echo $mensa_pres2;?> /> no</td>
                        <td>Mensa</td>
                        <td><input name="mensa_norma" type="radio" class="check" value="1"<?php echo $mensa_norma;?> /> si <input name="mensa_norma" type="radio" class="check" value="2"<?php echo $mensa_norma2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="cassetta_pres" type="radio" class="check" value="1"<?php echo $cassetta_pres;?> /> si <input name="cassetta_pres" type="radio" class="check" value="2"<?php echo $cassetta_pres2;?> /> no</td>
                        <td>Cassetta pronto soccorso</td>
                        <td><input name="cassetta_norma" type="radio" class="check" value="1"<?php echo $cassetta_norma;?> /> si <input name="cassetta_norma" type="radio" class="check" value="2"<?php echo $cassetta_norma2;?> /> no</td>
                      </tr>
                      <tr>
                        <td><input name="numeri_pres" type="radio" class="check" value="1"<?php echo $numeri_pres;?> /> si <input name="numeri_pres" type="radio" class="check" value="2"<?php echo $numeri_pres2;?> /> no</td>
                        <td>Numeri utili</td>
                        <td><input name="numeri_norma" type="radio" class="check" value="1"<?php echo $numeri_norma;?> /> si <input name="numeri_norma" type="radio" class="check" value="2"<?php echo $numeri_norma2;?> /> no</td>
                      </tr>
                    </table>
                </div>
                <div class="row">
                	<center><strong>Note</strong></center>
                </div>
                <div class="row">
                	<textarea name="note" class="note"><?php echo $note;?></textarea>
                </div>
                <div class="row">
                	Gravit&agrave; 
                    <select name="gravita">
                        <option value="0"></option>
                        <?php
                        for($i=1;$i<=10;$i++){
							$i==$gravita ? $sel = ' selected="selected"' : $sel = '';
                            echo '<option value="'.$i.'"'.$sel.'>'.$i.'</option>';
						}
                        ?>
                    </select>
                </div>
                <div class="row">
                	Prossima visita per verifica: Giorno <input value="<?php echo $data_prossvisita;?>" name="data_prossvisita" type="text" id="data_prossvisita" size="10" maxlength="10" /> Ora <input value="<?php echo $ora_prossvisita;?>" name="ora_prossvisita" type="text" id="ora_prossvisita" size="5" maxlength="5" />
                </div>
                <div class="row">
                	<input<?php echo $chiuso;?> name="chiuso" type="checkbox" class="check" value="1" /> Cantiere Chiuso 
                </div>
                <div class="row">
                	<input<?php echo $completata;?> name="completata" type="checkbox" class="check" value="1" /> Visita completata 
                </div>
                <div class="row buttons">
                	<center>
                    	<button id="btn_form_save" type="submit">Salva modifiche</button> 
                        <button type="button" onclick="delVisita(<?php echo $idvisita;?>,'<?php echo base64_encode($_SERVER['HTTP_REFERER']); ?>')">Elimina questa visita</button>
                    	<button type="button" onclick="window.location='visita_print.php?id=<?php echo $_GET['id'];?>'">Stampa</button> 
                    </center>
                </div>
            </div>
        	<input type="hidden" name="idvisita" value="<?php echo $idvisita;?>" />
        	<input type="hidden" name="idvisitaimp" value="<?php echo $idvisitaimp;?>" />
        	<input type="hidden" name="codice" value="<?php echo $codice;?>" />
        </form>
        </div>
    </div>
    
</div>

<div id="footer"></div>
</body>
</html>