<!--
function verif_date(input)
{
var regex = new RegExp("[/-]");
var date = input.split(regex);
var nbJours = new Array('',31,28,31,30,31,30,31,31,30,31,30,31);
var result = true;

if ( date['2']%4 == 0 && date['2']%100 > 0 || date['2']%400 == 0 )
nbJours['2'] = 29;

if( isNaN(date['2']) )
result=false;

if ( isNaN(date['1']) || date['1'] > 12 || date['1'] < 1 )
result=false;

if ( isNaN(date['0']) || date['0'] > nbJours[Math.round(date['1'])] || date['0'] < 1 )
result=false;

return result;
}



function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
return 1;
else
return 0;
}


var re_emptyall = new RegExp("^[ ]*$");
var re_not_number = new RegExp("[^0-9]");
var errore = 0;


function show_denuncia_amministratore(value) {
if(value == true) {
document.getElementById('denuncia_amministratore_box').style.display = "block";
} else {
document.getElementById('denuncia_amministratore_box').style.display = "none";
}
}


function show_amministratore(value) {
if(value == true) {
document.getElementById('amministratore_box').style.display = "block";
if(document.getElementById('amministratore_hidden').value == 'si') {
document.getElementById('denuncia_amministratore_box').style.display = "block";
}
}
 else {
document.getElementById('amministratore_box').style.display = "none";
document.getElementById('denuncia_amministratore_box').style.display = "none";
}
}


function process_form(invia) {
var string_errore = "";
if ( (document.getElementById('data_incidente').value == "" ) || (re_emptyall.test(document.getElementById('data_incidente').value)) ) {
string_errore = string_errore + "<li>Devi inserire la data dell'evento</li>";
}

if(!verif_date(document.getElementById('data_incidente').value)) {
string_errore = string_errore + "<li>Il formato della data dell'evento non e' valido</li>";
}

if ( (document.getElementById('luogo_incidente').value == "" ) || (re_emptyall.test(document.getElementById('luogo_incidente').value)) ) {
string_errore = string_errore + "<li>Devi inserire il luogo dell'evento</li>";
}

if(document.getElementById('cognome_testi').value == "") {
string_errore = string_errore + "<li>Devi indicare il cognome del contraente</li>";
}

if(document.getElementById('nome_testi').value == "") {
string_errore = string_errore + "<li>Devi indicare il nome del contraente</li>";
}


if(document.getElementById('tipologia_danno_hidden').value == "") {
string_errore = string_errore + "<li>Devi indicare la tipologia del danno</li>";
}


if(document.getElementById('tipo_abitazione_hidden').value == "") {
string_errore = string_errore + "<li>Devi indicare il tipo di abitazione</li>";
}


if(string_errore != "") {
if(document.getElementById('errori')) {
document.getElementById('errori').innerHTML = "";
document.getElementById('errori').innerHTML = '<p>Hai commesso i seguenti errori:</p><ul>'+string_errore+'</ul>';
} else {
document.getElementById('errori_contenitore').innerHTML ='<div id="errori"><p>Hai commesso i seguenti errori:</p><ul>'+string_errore+'</ul></div>';
}

window.scrollTo(0,0);

if(invia == true) {
return false;
} else {
return;
}
}


if(invia == false) {
var input_fields = document.getElementsByTagName('input');
var textarea_fields = document.getElementsByTagName('textarea');
var radio = document.getElementById('modulo').getElementsByTagName('span');



reTrim=/\s+$|^\s+/g;

for(i = 0; i < input_fields.length; i++) {
if(input_fields[i].type == 'text') {
if((input_fields[i].value.replace(reTrim,"")) == "") {
input_fields[i].value = "n.d.";
}
}
}

for(i = 0; i < textarea_fields.length; i++) {
var titolo_elemento = textarea_fields[i].name + '_text';
if(document.getElementById(titolo_elemento)) {
var text_area = textarea_fields[i].value;
text_area = text_area.replace(/\n/g, '<br />');
document.getElementById(titolo_elemento).innerHTML = text_area;
}

textarea_fields[i].style.display = 'none';
}


for(i = 0; i < input_fields.length; i++) {
if(input_fields[i].type != 'radio') {
if(input_fields[i].className != 'result') {
input_fields[i].className += ' result';
}
input_fields[i].style.display = 'inline';
}
}

for(i = 0; i < radio.length; i++) {
if(radio[i].className == 'radio_buttons') {
radio[i].style.display = 'none';
}
}



if(document.getElementById('errori')) {
document.getElementById('errori').style.display = 'none';
}
document.getElementById('files_allegati').style.display = 'none';
document.getElementById('bottone').style.display = 'none';
document.getElementById('hidden_testo').style.display = 'block';
window.print(0,0);
}
window.location.href = 'fine.jhtml';
}


function aggiorna(value, campo) {
document.getElementById(campo).value = value;
}

function display(value, campo, campo_value) {
if(value == true) {
document.getElementById(campo).style.display = "block";
} else {
if(document.getElementById(campo_value).value) {
document.getElementById(campo_value).value = "";
}
document.getElementById(campo).style.display = "none";
}
}
-->

