//**********************************************************************************************************************
/**
* DOCUMENT: /core/plugins/events/front/projects.back.js
* DEVELOPED BY: Ryan Stemkoski
* COMPANY: Zipline Interactive
* EMAIL: ryan@gozipline.com
* PHONE: 509-321-2849
* DATE: 4/28/2010
* DESCRIPTION: This document has all of the javascript functions required for the events  plugin.
*/
//***********************************************************************************************************************

//***********************************************************************************************************************
//ON DOCUMENT READY FUNCTIONS
//***********************************************************************************************************************
$(function() {


 		//CREATES AN ACCORDION MENU
 		function create_accordion() {
 
			//ACCORDION BUTTON ACTION	
			$('div.accordionButton').click(function() {
				$('div.accordionContent').slideUp('normal');
				if($(this).next().is(':hidden') == true) {
					$(this).next().slideDown('normal');
				}
				
			});
		 
			//HIDE THE DIVS ON PAGE LOAD	
			$("div.accordionContent").hide();
		
		}
	
		//CREATES CLICKABLE BUTTONS
		function calendar_button() {
	
			//ON BUTTON CLICK ADJUST DATE
			$('.button').click(function() {
	
				var date_item = $(this).attr("id");
				var date_items = date_item.split("-");
				var month_post = date_items['0'];
				var year_post = date_items['1'];
			
				$.post("index.php", { action: "calendar_ajax", month: month_post, year: year_post },
	   				function(data){
	     			$('#wrapper_calendar').replaceWith(data).fadeIn("normal");
	     			calendar_button();
	     			create_accordion();
	   			});
				
			});
			
		}
		
		//ONLOAD CREATE CALENDAR BUTTONS
		calendar_button();
		create_accordion();


	
});

