
function okdati() {
var den, com, cf, nome, p_ccia, codfis, nm_reg;
 
	if (document.f.modulo.value == 'modulo1') {
		// controllo primo form 
		den = WordCount(document.f.m1_Denominazione,'');		
		if ((document.f.m1_ChkVisFab.checked == false) && (document.f.m1_ChkVisTer.checked == false)) {
			alert('Sezione 1:\nSelezionare il Tipo di Ricerca');
			return false;
		}
		if ((document.f.m1_Denominazione.value == '') && (document.f.m1_Iva.value == '')) {
			alert("Sezione 1:\nInserire il campo 'Ragione sociale'");
			return false;
		}	
		if (document.f.m1_Iva.value != '') {
			if (!check_piva(document.f.m1_Iva,"pc")) {  	
				return false;
			}
		}
	}
		
	if (document.f.modulo.value == 'modulo2') {
		// controllo secondo form	
		if ((document.f.m2_ChkVisFab.checked == false) && (document.f.m2_ChkVisTer.checked == false)) {
			alert('Sezione 1:\nSelezionare il Tipo di Ricerca');
			return false;
		}		
		if ((document.f.m2_Cognome.value == '') && (document.f.m2_Cf.value == '')) {
			alert("Sezione 1:\nInserire il campo 'Cognome'");
			return false;
		}		
		if ((document.f.m2_Nome.value == '') && (document.f.m2_Cf.value == '')) {
			alert("Sezione 1:\nInserire il campo 'Nome'");
			return false;
		}	
		if (((document.f.m2_Gg.value == '') && (document.f.m2_Mm.value == '') && (document.f.m2_Aaaa.value == '')) && (document.f.m2_Cf.value == '')) {
			alert('Sezione 1:\nInserire il Codice Fiscale o la Data di Nascita');
			return false;
		}		
		if ((document.f.m2_Gg.value != '') || (document.f.m2_Mm.value != '') || (document.f.m2_Aaaa.value != '')) {
			if (check_data(document.f.m2_Gg, document.f.m2_Mm, document.f.m2_Aaaa)==false) {
				return false;
			}
		}		
		if (document.f.m2_Cf.value != '') {
			if (!check_piva(document.f.m2_Cf,"cf")) {  	
				return false;
			}
		}
	}		
	return true;
}

function PivaCheckCat() {
	Campo = document.f.m1_Iva;
	var tmp;
	tmp = trim(Campo.value);
	if (!(check_num(Campo.value))) {
		alert("Sezione 1\nPer la ricerca su impresa inserire soltanto caratteri numerici nel campo Codice Fiscale.");
		Campo.value = '';
		return false;
	}
}
