$(document).ready(function() {
   // Create Date Object
   var jsDateObject = new Date();

   // Create Calendar Object ( Holds all your variables, etc )
   var jsCalendar = {};
       jsCalendar.currentMonth = jsDateObject.getMonth();
		jsCalendar.currentMonth++
		
   // Controls the NEXT button
   $("#jsCalendarNext").click(function() {
      // Update Active Month
      jsCalendar.currentMonth++;
         if(jsCalendar.currentMonth>12) { jsCalendar.currentMonth=1; }
		
      // Get New Calendar
      ajaxUpdateCalendar();
	  return false;
   });

   // Controls the PREV button
   $("#jsCalendarPrev").click(function() {
      // Update Active Month
      jsCalendar.currentMonth--;
         if(jsCalendar.currentMonth<1) { jsCalendar.currentMonth=12; }

      // Get New Calendar
      ajaxUpdateCalendar();
	  return false;
   });

	ajaxUpdateCalendar();

   // Use AJAX to update the Calendar
   function ajaxUpdateCalendar() {
	   

      $.post(
         "page-contents/classes.inc.php",
         { calendarMonth: jsCalendar.currentMonth },
         function(data) {
            $("#jsCalendarContainer").fadeOut("fast", function(){$("#jsCalendarContainer").html(data);});
			$("#jsCalendarContainer").fadeIn("fast");
			
         }
      );

   }

});
