jQuery.noConflict();

jQuery(document).ready(function(){

	var newdate = new Date();

	var year = newdate.getFullYear();
	var month = newdate.getMonth();
	
	var previous_year;
	var previous_month
	
	var next_year;
	var next_month;
		
	jQuery("#next_month").click(function(){
		
		if(month == 12) {
			next_year = year+1;
			next_month = 1;
		} else {
			next_year = year;
			next_month = month+1;
		}
		
		month = next_month;
		year = next_year;
		
		//element_agenda
		jQuery.ajax({
		   type: "POST",
		   url: "/load_calendar.php",
		   data: "month="+next_month+"&year="+next_year,
		   success: function(html){
				
								
				jQuery("#element_agenda").html(html);

				sIFR.replaceElement("h2", named({sFlashSrc: "/includes/georgia.swf", sColor: "#1C437E", sWmode: "transparent"}));

				
		   }
		 });
		
		
	});

					
	
	jQuery("#previous_month").click(function(){
			
		if(month == 1) {
			previous_year = year-1;
			previous_month = 12;
		} else {
			previous_year = year;
			previous_month = month-1;
		}
			
		month = previous_month;
		year = previous_year;
		
		//element_agenda
		jQuery.ajax({
			type: "POST",
			url: "/load_calendar.php",
			data: "month="+previous_month+"&year="+previous_year,
			success: function(html){
				
				
				jQuery("#element_agenda").html(html);

				//replace the header
				sIFR.replaceElement("h2", named({sFlashSrc: "/includes/georgia.swf", sColor: "#1C437E", sWmode: "transparent"}));
			}
		 });
	});
		
});
