// JavaScript Document
function componente_onsubmit()
{
	var frm = getElement('frm');
	
	if(empty(frm.comp_cognome.value))
	{
		alert('Cognome obbligatorio!');
		return false;
	}
	if(empty(frm.comp_nome.value))
	{
		alert('Nome obbligatorio!');
		return false;
	}
	if(empty(frm.comp_datanas.value))
	{
		alert('Data nascita obbligatoria!');
		return false;
	}
	if(empty(frm.comp_luogonas.value))
	{
		alert('Luogo di nascita obbligatoria!');
		return false;
	}
	if(empty(frm.comp_indirizzo.value))
	{
		alert('Indirizzo obbligatorio!');
		return false;
	}
	return true;
}

function componente_delete_onClick(index)
{
	var frm = getElement('frm');
	if(!confirm('Eliminare il componente selezionato???')) return false;
	frm.idcomponente.value = index;
	frm.act.value = 'deletecomponente';
	frm.submit();
}

function prosegui_onclick()
{
	
	var frm = getElement('frm');		
	
	if(empty(frm.cgcognome.value))
	{
		alert('Cognome capogruppo obbligatorio!');
		return false;
	}
	if(empty(frm.cgnome.value))
	{
		alert('Nome capogruppo obbligatorio!');
		return false;
	}
	if(empty(frm.cittanas.value))
	{
		alert('Citta nascita capogruppo obbligatoria!');
		return false;
	}
	if(empty(frm.provnas.value))
	{
		alert('Prov nascita capogruppo obbligatoria!');
		return false;
	}
	if(empty(frm.datanas.value))
	{
		alert('Data nascita capogruppo obbligatoria!');
		return false;
	}
	if(empty(frm.indirizzo.value))
	{
		alert('Indirizzo capogruppo obbligatorio!');
		return false;
	}
	if(empty(frm.cap.value))
	{
		alert('Cap capogruppo obbligatoria!');
		return false;
	}
	if(empty(frm.citta.value))
	{
		alert('Citta residenza capogruppo obbligatoria!');
		return false;
	}
	if(empty(frm.tel.value) || empty(frm.cell.value))
	{
		alert('Necessario almeno un recapito telefonico!');
		return false;
	}
	if(empty(frm.email.value))
	{		
		alert('Inserire indirizzo E-mail di contatto!');
		return false;		
	}
	else
	{
		if(!checkMail(frm.email.value)) 
		{			
			return false;		
		}
	}
	/*if(empty(frm.professione.value))
	{
		alert('Professione capogruppo obbligatoria!');
		return false;		
	}*/
	if(empty(frm.doctipo.value) || empty(frm.docnr.value) ||
	   empty(frm.rilasciatoil.value) || empty(frm.rilasciatoda.value))
	{
		alert('Info documento obbligatorie!');
		return false;
	}
	/*if(empty(frm.tipoauto.value))
	{
		alert('Tipo auto obbligatoria!');
		return false;		
	}*/
	if(!almenouno('frm','trattamento'))
	{
		alert('Selezionare tipo trattamento desiderato!');
		return false;		
	}
	if(!almenouno('frm','alloggio'))
	{
		alert('Selezionare tipo alloggio desiderato!');
		return false;		
	}
	if(empty(frm.dal.value))
	{
		alert('Inserire data Check IN!');
		return false;		
	}
	if(empty(frm.al.value))
	{
		alert('Inserire data Check OUT!');
		return false;		
	}
	
	if(empty(frm.caparra.value))
	{
		alert('Inserire la caparra che si intende pagare!');
		return false;		
	}
	
	
	if(empty(frm.unita.value))
	{
		alert('Inserire numero unità abitative richieste!');
		return false;		
	}
	frm.action = 'riepilogo.php';
	frm.submit();
}

function trovati_onclick(el,txt)
{
	var eltxt = getElement(txt);
	var eltxt2;
	
	if(txt == 'altro') eltxt2 = getElement('fiera');
	else eltxt2 = getElement('altro');
	
	if(el.checked)
	{
		eltxt.disabled = false; 
		eltxt.focus()
		eltxt2.value = '';
		eltxt2.disabled = true;
	}
	else 
	{
		eltxt.disabled = true; 
		eltxt.value='';		
	}
	
}
