$(document).ready(function() {

	var admin = $('#calendar').hasClass('admin');

	$('#calendar').fullCalendar({
		header: {
			left: 'prev,next today',
			center: 'title',
			right: 'month,agendaWeek,agendaDay'
		},

		// US Holidays
		events: $.fullCalendar.gcalFeed('http://www.google.com/calendar/feeds/listings%40renterval.com/public/basic'),

		eventMouseover: function(event) {
			var title = event.fullTitle;
			if (admin) title += ' - Click to remove unavailability';
			$(this).attr('title', title);
		},

		eventClick: function(event) {
			if (admin && confirm('Are you sure you want to remove this unavailalibility?')) {
				var slotId = event.description.split('-')[1];
				window.location = '/listings/remove_unavailability/'+listingId+'/' + slotId;
			}
			return false;
		},

		loading: function(bool) {
			if (bool) {
				$('#loading').show();
			}else{
				$('#loading').hide();
			}
		}

	});

});

