function checkFormField(b){var a="";if(b.name=="brand"){if(b.value==""){b.value="N/D";a+="Marca non definita, valore impostato a 'N/D'\n"}}else{if(b.name=="model"){if(b.value==""){b.value="N/D";a+="Modello non definito, valore impostato a 'N/D'\n"}}else{if(b.name=="color"){if(b.value==""){b.value="N/D";a+="Colore non definito, valore impostato a 'N/D'\n"}}else{if(b.name=="year"){if(b.value==""){b.value=curr_year;a+="Anno vuoto, valore impostato all'anno corrente\n"}else{if(isNaN(b.value)){b.value=curr_year;a+="Anno numero non valido, valore impostato all'anno corrente\n"}else{if(parseInt(b.value)<1950||parseInt(b.value)>curr_year+1){b.value=curr_year;a+="Anno fuori da un intervallo ragionevole (1950-"+(curr_year+1)+"), valore impostato all'anno corrente\n"}}}}else{if(b.name=="price"){if(b.value==""){b.value=0;a+="Prezzo vuoto, valore impostato a 0\n"}else{if(isNaN(b.value)){b.value=0;a+="Prezzo numero non valido, valore impostato a 0\n"}else{if(parseInt(b.value)<0){b.value=0;a+="Prezzo negativo, valore impostato a 0\n"}}}}else{if(b.name=="news"){if(b.value==""){b.value="N/D";a+="News non inserita, valore impostato a 'N/D'\n"}}}}}}}return a}function checkForm(c){var d="";for(var b=0;b<c.elements.length;b++){var a=checkFormField(c.elements[b]);if(a!=""){d+=a}}return d}function doCheck(a){msg=checkForm(a);if(msg==""){return true}else{window.alert(msg);return false}}function resetFileField(b){if(b.type=="file"){var a=document.createElement("input");a.name=b.name;a.type=b.type;a.value="";b.parentNode.replaceChild(a,b)}}function resetFileFieldsInForm(b){if(b!=null){for(var a=0;a<b.elements.length;a++){if(b.elements[a].type=="file"){resetFileField(b.elements[a])}}}}function resetForm(b){if(b!=null){for(var a=0;a<b.elements.length;a++){if(b.elements[a].type=="text"){b.elements[a].value=""}else{if(b.elements[a].type=="file"){resetFileField(b.elements[a])}else{if(b.elements[a].type=="checkbox"){b.elements[a].checked=false}}}}}}function findChecked(a){for(var b=0;b<a.options.length;b++){if(a.options[b].selected){return a.options[b].value}}return false}function handleError(a){window.location=errurl+"?"+a;return true};
