$(document).ready(function(){

	$("#invia_modulo").validate({
		rules : {
			nominativo : "required",
			email: {
	      required: true,
	      email: true
	    },
			auth : "required"
		},
		messages : {
			nominativo : " *",
			email : " *",
			auth : " *"
		}
	});

});

function limitChars(textid, limit, infodiv) {
	
 var text = $('#'+textid).val(); 
 var textlength = text.length;

 if(textlength > limit) {

  $('#' + infodiv).html('Non puoi scrivere un messaggio con pi&ugrave; di '+limit+' caratteri!');
  $('#'+textid).val(text.substr(0,limit));
  	return false;
  	
 } else {

	$('#' + infodiv).html(''+ (limit - textlength) +' caratteri rimanenti.');	
		return true;
		
 }

}
<!--
function PopupGoogleTalk()
{
  var w = 750;
  var h = 500;
  var l = Math.floor((screen.width-w)/2);
  var t = Math.floor((screen.height-h)/2);
   
  window.open("/chat.php","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}
//-->

$(function(){
	$('#messaggio').keyup(function(){
		limitChars('messaggio', 255, 'charleft');
	})
});
