/* init */
$(document).ready(function(){
	if (typeof(admin) == 'undefined') {
  	$(document).bind("contextmenu",function(e){
  		e.preventDefault();
  	});
	}
	$("form").attr("autocomplete", "off");
	$("a.external").attr("target","_blank");
	$(".delete").click(function(){ return confirm("Cancellare il record selezionato?") });
	$('#d').datepicker();
});

/* functions */
// seleziona/deseleziona tutti i checkbox
function checkAll() {
	var form = (arguments[0]) ? arguments[0] : "#form1";
	var trigger = (arguments[1]) ? arguments[1] : "#chkToggle";
	$(trigger).click(function(){
		$(form + " input[type='checkbox']").attr("checked", $(this).is(":checked"));
	});
}

// mostra/nasconde le righe
function toggleDisplay(){
	var checkbox = $(arguments[0]);
	var show = arguments[1];
	var hide = arguments[2];
	if (show){
		var shows = show.split(",");
		for(var i=0; i<shows.length; i++) {
			$('#'+shows[i]).hide();
			if (checkbox.is(":checked")) {
				$('#'+shows[i]).show();
			}
		}
	}
	if (hide){
		var hides = hide.split(",");
		for(var i=0; i<hides.length; i++) {
			$('#'+hides[i]).show();
			if (checkbox.is(":checked")) {
				$('#'+hides[i]).hide();
			}
		}
	}
}

