function toggleForm(id, fpref, lb1,lb2) {
	$('#'+id).toggle('fast');
	$('#'+id).toggleClass("opened");
	if($('#'+id).hasClass("opened")) {
		$('#lab_'+id).text(lb2);
		$('#hid_'+id)[0].value=0;
		$('input,textarea,selct',$('#datiutente')).each(function() {
			$('#'+fpref+$(this).attr('id')).val($(this).val());
		});
	} else {
		$('#lab_'+id).text(lb1);
		$('#hid_'+id)[0].value=1;
	}
}

function limitChars(textid, limit, infodiv,copydiv) {
	var text = $('#'+textid).val(); 
	var textlength = text.length;
	if(textlength > limit) {
		$('#' + infodiv).html('Non puoi scrivere pi&ugrave; di '+limit+' caratteri');
		$('#'+textid).val(text.substr(0,limit));
		$('#'+copydiv).val(text.substr(0,limit));
		return false;
	} else {
		$('#' + infodiv).html('Ti rimangono '+ (limit - textlength) +' caratteri disponibili');
		$('#'+copydiv).val(text);
		return true;
	}
}

$(document).ready(
	function() {
		$("#Fatturare").change(
				function() {
					if($(this).attr("checked")) {
						$("#fatt_hs").show();
					} else $("#fatt_hs").hide();
				}
		);
		if ($.browser.msie) {
	        $('input:checkbox').click(function () {
	            this.blur();
	            this.focus();
	        });
	    }
	});