//Full Calendar
function closeEventDetails(){
	$("#eventwindow").fadeOut();	
}
function changeMonth(year, month, e){
	$("#monthNav li").removeClass('active');
	$("#monthNav #li-"+month).addClass('active');
	$("#calendar").fullCalendar('gotoDate',year,month);
}
$(document).ready(function() {

	$('#calendar').fullCalendar({
		header: false,
		editable: false,
		events: "https://www.christmasbureau.ca/js/cal-events.php",
		columnFormat:{
			month: 'dddd'    // Monday
		},
		contentHeight: 800,
		weekMode: 'variable',
	    eventClick: function(calEvent, jsEvent, view) {
			//offset
			leftOffset = 84;
			topOffset = 0;

			var left = $(this).css('left');
			left = left.replace('px','');
			left = parseInt(left)+leftOffset+'px';
			
			var top = $(this).css('top');
			top = top.replace('px','');
			top = parseInt(top)+topOffset+'px';
			
			$("#eventwindow").fadeOut(500,function(){
				$("#eventwindow").html($("#eventinfo-"+calEvent.id).html());
				$("#eventwindow").css('left', left);
				$("#eventwindow").css('top', top);
				$("#eventwindow").fadeIn(500);

	
    		});
		}
	});
	$('.fc-widget-content').hover(
	  function () {
		$(this).addClass('fc-widget-hoverstate');
	  },
	  function () {
		$(this).removeClass('fc-widget-hoverstate');
	  }
	);
});
$(document).ready(function(){
	$('#calendar').fullCalendar('render');
});


//jQuery Cycle
$(document).ready(function() {
    $('#sponsors .cycle').cycle({
		fx: 'fade',
		speed:    1000, 
    	timeout:  6000 
	});
});

//jQuery Tabs
$(document).ready(function() {
	$('#eventsNav').tabs({ fx: { opacity: 'toggle' } });
});

//Expandables
$(document).ready(function() {
	$(function(){
		$("#accordion").accordion({ 
			header: ".label", 
			autoHeight: false, 
			collapsible: true, 
			active: false, 
			change: function(event, ui) {
				$("#accordion .ui-state-default a").html("click here for more info");
				$("#accordion .ui-state-active a").html("click here to close panel");
			} 
		});
		$("#accordion1").accordion({ 
			header: ".clickable", 
			autoHeight: false, 
			collapsible: true, 
			active: false
		});
		$("#accordion2").accordion({ 
			header: ".clickable", 
			autoHeight: false, 
			collapsible: true, 
			active: false
		});
		$("#accordion3").accordion({ 
			header: ".clickable", 
			autoHeight: false, 
			collapsible: true, 
			active: false
		});
		$("#accordion4").accordion({ 
			header: ".clickable", 
			autoHeight: false, 
			collapsible: true, 
			active: false
		});
	});
});

