jQuery(
	function($) {
		// Veranstaltungskalender
		(
			function() {
				var
					$calendar = $('#show_calendar'),
					o;

				if ($calendar.length) {
					o = $calendar.metadata();
					$calendar
						.datepicker(
							{
								beforeShowDay:
									function(date) {
										var dateString = 'date_' + $.datepicker.formatDate('yy_mm_dd', date);

										return [!!o[dateString], '', (!!o[dateString] ? o[dateString].title : '')];
									},
								dateFormat: 'yy_mm_dd',
								inline: true,
								onSelect:
									function(dateText, inst) {
										var event = o['date_' + dateText];
										if (!!event) window.location.href = event.href;
									}
							}
						);
				}
			}
		)();

		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); },
			function() { $(this).removeClass('ui-state-hover'); }
		);
	}
);
