//array of ids to be shown
var showIDs=new Array();
//bool for if first click
firstClick=true; 

function showDiv(classToHide){
	$('.'+classToHide).show();
};
function hideDiv(classToHide){
	$('.'+classToHide).hide();
};
function initFilter(){	
	//uncheck all options initially (in case of refresh)
	$(".calendarFilter INPUT[ type='checkbox']").attr('checked', false);
	
	$(".calendarFilter INPUT[ type='checkbox']").click(function() {
		//if first click then hide all the divs
		if(firstClick) {
			hideDiv("event");
			firstClick=false;
		}
		//if the button was checked add id to showIDs array and show the div
		//else the button was unchecked remove the id from showIDs hide the divs with that id,
		//but must also show all divs that are still checked in case it hides a div that should
		//still be shown
		if($(this).is(':checked')) {
			if($.inArray($(this).attr('id'), showIDs)==-1) {
				showIDs.push($(this).attr('id'));
				showDiv($(this).attr('id'));
			}
		} else {
			if($.inArray($(this).attr('id'), showIDs)!=-1) {
				showIDs.splice($.inArray($(this).attr('id'), showIDs), 1);
				hideDiv($(this).attr('id'));
				for(var i=0;i<showIDs.length;i++) {
					showDiv(showIDs[i]);
				}
			}
		}
		//if showIDs is empty show all divs and set firstClick back to true
		if(showIDs.length<1) {
			showDiv("event");
			firstClick=true;
		}
	});
};
function initCatHider(){
	$("#cal-title").hover(function() {
		alert("hello");
		hideDiv($(this).attr('class'));
	});
};
$(document).ready(function() { 
	initFilter();
	initCatHider();
});