function cambiaSistemazioni() {
	$('.nascosto:not(:first)').css('display', 'none');
	$('#sistemazione').change(function() {
		var iddiv = $(this).find('option[selected]').val();
		$('.nascosto').hide('slow');
		$('#' + iddiv).show('slow');
	});
}

function validaForm() {
	var fields = $('.req');
	var valid = true;
	fields.each(function() {
		if($(this).val() == "") valid = false;
		if($(this).is(':checkbox') && !this.checked) valid = false;
	});
	return valid;
}

function OpenPage(lar, alt) {
	window.open('','zoom','toolbar=no,directories=no,menubar=no,scrollbars=yes,width=' + lar + ',height=' + alt + ',top=100,left=50');
}

function bookmarksite(title, url){
	if (document.all) {
		window.external.AddFavorite(url, title);
	} else if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	}
}

var dateNotes = {
	n2011_12: " ",
	n2012_1: " ",
	n2012_2: " ",
	n2012_3: " ",
	n2012_4: " ",
	n2012_5: " ",
	n2012_6: " ",
	n2012_7: " ",
	n2012_8: " ",
	n2012_9: " ",
	n2012_10: " ",
	n2012_11: " ",
	n2012_12: " "
};

function setDefaultDateNote() {
	var currentDate = new Date();
	if(dateNotes['n'+currentDate.getFullYear()+'_'+(currentDate.getMonth()+1)]) {
		$('#ui-datepicker-notes-container').html(dateNotes['n'+currentDate.getFullYear()+'_'+(currentDate.getMonth()+1)]);
	} else {
		$('#ui-datepicker-notes-container').empty();
	}
}

function enableCalendars() {
		$('.date').datepicker({
		beforeShow: function(input, inst) {
			if(input.value == '') {
				setDefaultDateNote();
			}
		},
  	onChangeMonthYear: function(year, month, inst) {
			if(dateNotes['n'+year+'_'+month]) {
				$('#ui-datepicker-notes-container').html(dateNotes['n'+year+'_'+month]);
			} else {
				$('#ui-datepicker-notes-container').empty();
			}
		},
		onClose: function(dateText, inst) {
			if(dateText == '') {
				setDefaultDateNote();
			}
		}
	});
}
