max = 2000; 

function contatore(form,field)
{	
	if (field.value.length > max) {
		field.value = field.value.substring(0,max);
		rest = 0;
	} 
	else {
		rest = max - field.value.length;
		}
	form.num.value = rest;
}

function LunghezzaMax(campo) 
{ 
	if (campo.value.length>max) 
	{ 
		alert("Inserire al massimo "+max+" caratteri nella textarea."); 
		campo.value=campo.value.substring(0, max); 
	} 
} 

function confirmMsg(msg)
{
    if(confirm(msg))
    {
        return (true);
    }else return(false);
}

function Form_Validator_Cat(theForm,fields)
{
    for(var i=0;i<fields.length;i++)
    {
        if(eval("theForm."+fields[i]+".value") == '')
        {
            alert("Compilare tutti i campi obbligatori");
            return (false);
        }
    }
    return (true);
}
