<%@ include file="/project/include.jsp" %>
 		
<script type="text/javascript">
	<c:if test="${bui:isMode(null, 'record_created')}">
		registerOnDocumentLoad(mostraLookup);
		
		function mostraLookup(){
			var valData = document.getElementById("dataCollocazioneCLD").value;
			if (valData == '') {
				document.getElementById('idSpanLookup').style.display = 'none';
			} else {
				document.getElementById('idSpanLookup').style.display = 'inline';
			}			
		}
	</c:if>

	function getTipiAdozioni(comboTipoIstruttoria){
		var value_sel = comboTipoIstruttoria.options[comboTipoIstruttoria.selectedIndex].value;
		if (value_sel != '') {
			var params = 'idTipoIstruttoria=' + value_sel;				
			loadStandardSelectOptionsAndFill('tipoAdozione', 
				'it.cedaf.icare.affidiadozioni.control.binding.requestbean.valuesetproviders.TipiAdozioniValueSetProvider(idTipoIstruttoria)', params); 
		} else {
			clearCombo('tipoAdozione');
		}
	}
  	
  	function visualizzaNucleo() {
  		var idNucleo = '';
  		var	dataValidita = '';
  		var dataValiditaParam = '';
  		
  		if (bui_datamanagement.getMode().isView()) {
  			idNucleo = cpGetMasterColumnValueOfCurrentRow('idNucleoFamiliare');
  			dataValidita = cpGetMasterColumnValueOfCurrentRow('dataCollocazione');
  		} else {
  			idNucleo = document.getElementById('id_nucleo').value;
		   	dataValidita = document.getElementById("dataCollocazioneCLD").value;
  		}
		
		dataValidita = completeDateString(dataValidita);
		if (dataValidita != null) {
			dataValiditaParam = '&dataNucleo=' + dataValidita;
		}		
  		juiceOpenWindow('NucleoFamiliare','anagrafiche.viewNucleo?idNucleo=' + idNucleo + dataValiditaParam, getCenterWindowOptions(700, 500));
  	}
	
	<bui:out modes="update,create">	
		function onChangeDataCollocazione(){
			<c:if test="${bui:isMode(null, 'record_created')}">
				mostraLookup();
				var denomNucleo = document.getElementById("denominazione_nucleoLookup").value
				if (denomNucleo != '') {
					alert('Attenzione.\nCambiando la data primo colloquio � possibile che venga variata\nla composizione del nucleo scelto.')
				}
				getOperatoriRiferimento();
			</c:if>			
		}
		
		function changePartecipatoCorso(){
			/** */
			var inizio = document.getElementById('dataInizioCorsoCLD');
			var fine = document.getElementById('dataFineCorsoCLD');
			
			/** */
			if (document.forms['buiForm'].partecipatoCorso[0].checked){
				/** */
				inizio.disabled = false;
				fine.disabled = false;
			} else {
				inizio.disabled = true;
				inizio.value = '';
				fine.disabled = true;
				fine.value = '';				
			}
		}
	</bui:out>

</script>	
		
<table border="0" cellpadding="0" cellspacing="3" width="100%">
	<tr>
		<td valign="top" width="50%">	        	       	
			<shell:fieldset title="Informazioni richiesta">
				<table border="0" cellpadding="0" cellspacing="3">
					<tr>   
			      		<td class="form-label">
			    			<shell:label prop="icaroCode" />
			    		</td>
			    		<td class="form-values">
							<j:tile name="shell.plaintext" prop="icaroCode" />
						</td> 
				  	</tr>
			  		<tr>   
			      		<td class="form-label">
			    			<shell:label prop="dataCollocazione" />
			    		</td>
			    		<bui:out modes="view">   
					  		<td class="form-values">
								<j:tile name="shell.plaintext" prop="dataCollocazione" />
							</td>
						</bui:out>
						<bui:out modes="update,create">
						    <j:bind prop="dataCollocazione">						
								<td class="form-values">
									<j:text class="form-date" id="dataCollocazioneCLD" onchange="onChangeDataCollocazione();" />
									<shell:calendar inputId="dataCollocazioneCLD" />	
									<shell:error />
								</td>
							</j:bind>
					   	</bui:out> 
				  	</tr>
			        <tr>	
						<c:choose>
							<c:when test="${bui:isMode(null, 'record_created')}">
								<td class="form-label">
									<shell:label prop="idNucleoFamiliare" />
								</td>			 
								<td class="form-values">
									<j:bind prop="denominazioneNucleo">
										<j:text class="form-long-text" readonly="true" id="denominazione_nucleoLookup" />
										<shell:error />
									</j:bind>	
									<span id="idSpanLookup">
										<shell:lookup lookupId="nucleoLookup" identifier="anagrafiche.nucleoFamiliare" 
											init="it.cedaf.icare.anagrafiche.model.datamanagement.NucleoFamiliareFromAffidiAdozioniLookupInitializer" 
											formParams="dataCollocazioneCLD|dataNucleo" noCommitOnCreate="id=-1" />
									</span>				  	
									<j:bind prop="idNucleoFamiliare">
										<j:hidden id="id_nucleoLookup"/>
										<shell:error />
									</j:bind>
								</td>
							</c:when>
							<c:otherwise>
								<td class="form-label">
									<shell:label prop="denominazioneNucleo" />
								</td>			 
								<td class="form-values">
									<j:tile name="shell.plaintext" prop="denominazioneNucleo" />
									<a href="javascript:visualizzaNucleo();" onclick="coordinates(event);"> <img src="${j:getResourceUrlOfModule('anagrafiche','img/nucleo_small.gif')}" title="Visualizza nucleo" align="absmiddle" border="0"></a> 
									<bui:out modes="update,create">
										<j:bind prop="idNucleoFamiliare">
											<j:hidden id="id_nucleo"/>
											<shell:error />
										</j:bind>
									</bui:out>
								</td>
							</c:otherwise>
						</c:choose>						
					</tr>				  	
				  	<tr>   
				      	<td class="form-label">
			    			<shell:label prop="tipoIstruttoria" />
			    		</td>
			    		<bui:out modes="view">   
						  	<td class="form-values">
								<j:tile name="shell.plaintext" prop="tipoIstruttoria" />
							</td>
						</bui:out>
						<bui:out modes="update,create">
						    <j:bind prop="tipoIstruttoria">
								<td class="form-values">
									<j:select class="form-input" emptyOptionDescr=" " onchange="getTipiAdozioni(this);"/> 
								    <shell:error />
								</td>
							</j:bind>
					   	</bui:out> 
					</tr>
					<tr>   
				      	<td class="form-label">
			    			<shell:label prop="tipoAdozione" />
			    		</td>
			    		<bui:out modes="view">   
						  	<td class="form-values">
								<j:tile name="shell.plaintext" prop="tipoAdozione" />
							</td>
						</bui:out>
						<bui:out modes="update,create">
						    <j:bind prop="tipoAdozione">
								<td class="form-values">
									<j:select class="form-input" id="tipoAdozione" emptyOptionDescr=" "/> 
								    <shell:error />
								</td>
							</j:bind>
					   	</bui:out> 
					</tr>
					<tr>   
				      	<td class="form-label">
			    			<shell:label prop="tipoServizioIstruttoria" />
			    		</td>
			    		<bui:out modes="view">   
						  	<td class="form-values">
								<j:tile name="shell.plaintext" prop="tipoServizioIstruttoria" />
							</td>
						</bui:out>
						<bui:out modes="update,create">
						    <j:bind prop="tipoServizioIstruttoria">
								<td class="form-values">
									<j:select class="form-input" emptyOptionDescr=" "/> 
								    <shell:error />
								</td>
							</j:bind>
					   	</bui:out> 
					</tr>
					<tr>   
				      	<td class="form-label">
				    		<shell:label prop="nominativoServizio" />
				    	</td>
				    	<td class="form-values">
					    	<bui:out modes="view">   
								<j:tile name="shell.plaintext" prop="nominativoServizio" />
							</bui:out>					
							<bui:out modes="update,create">
							    <j:bind prop="nominativoServizio">
									<j:text class="form-normal-text"/>
									<shell:error />
								</j:bind>
						   	</bui:out> 
						</td>
					</tr>
				</table>
			</shell:fieldset>
		</td>
		<td valign="top" width="50%">
			<shell:fieldset title="Informazioni operatori">
				<table border="0" cellpadding="0" cellspacing="3">
					<j:tile name="commons.opRifNonStoricizzato"/>	
					<j:tile name="commons.opAbilitato" objectName="RichiestaAffidoAdozione" idField="id" sendToAbilitato="true"/>
				</table>
			</shell:fieldset>
		</td>
	</tr>
</table>	

<shell:fieldset title="Partecipazione ai corsi">							
	<table border="0" cellpadding="0" cellspacing="3">										
		<tr>   
	      	<td class="form-label">
	    		<shell:label prop="partecipatoCorso" />
	    	</td>
	    	<td class="form-values">
	    		<bui:out modes="view">   
			  		<j:tile name="shell.plaintext" prop="partecipatoCorso" />
				</bui:out>
				<bui:out modes="update,create">
			    	<j:bind prop="partecipatoCorso">											
				    	<j:radio id="partecipatoCorsoId_0" displayValue="si" onClick="changePartecipatoCorso();"/>${j:bundle('LBL_si')}
						<j:radio id="partecipatoCorsoId_1" displayValue="no" onClick="changePartecipatoCorso();"/>${j:bundle('LBL_no')}
						<shell:error />
					</j:bind>
		   		</bui:out>
		   	</td>
	  	</tr>		
		<tr>
			<td class="form-label">
				<shell:label prop="dataRichiestaCorso" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataRichiestaCorso" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataRichiestaCorso">
						<j:text class="form-date" id="dataRichiestaCorsoCLD"/>
						<shell:calendar inputId="dataRichiestaCorsoCLD" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>		  				
		<tr>
			<td class="form-label">
				<shell:label prop="dataInizioCorso" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataInizioCorso" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataInizioCorso">
						<j:text class="form-date" id="dataInizioCorsoCLD"/>
						<shell:calendar inputId="dataInizioCorsoCLD" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>	
		<tr>
			<td class="form-label">
				<shell:label prop="dataFineCorso" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataFineCorso" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataFineCorso">
						<j:text class="form-date" id="dataFineCorsoCLD"/>
						<shell:calendar inputId="dataFineCorsoCLD" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>
		<tr>
			<td class="form-label">
				<shell:label prop="dataRichiestaIndagine" />
			</td>
			<td class="form-values">
				<bui:out modes="view">
					<j:tile name="shell.plaintext" prop="dataRichiestaIndagine" />
				</bui:out>
				<bui:out modes="create, update">
					<j:bind prop="dataRichiestaIndagine">
						<j:text class="form-date" id="dataRichiestaIndagineCLD"/>
						<shell:calendar inputId="dataRichiestaIndagineCLD" />
						<shell:error />
					</j:bind>
				</bui:out>
			</td>						
		</tr>
	</table>		
</shell:fieldset>		
			
<shell:fieldset title="Informazioni aggiuntive">
	<table>
		<tr>   
	  		<td class="form-label">
				<shell:label prop="note" />
	    	</td>
		    <bui:out modes="view">   
			 	<td class="form-values">
					<j:tile name="shell.plaintext" prop="note" />
				</td>
			</bui:out>
			<bui:out modes="update,create">
			    <j:bind prop="note">
					<td class="form-values">
						<j:textarea class="form-long-textarea" />
						<shell:error />
					</td>
				</j:bind>
			</bui:out> 
		</tr>
	</table>
</shell:fieldset>