/* This is a plugin for the year month slide up, down and toggle effects Created by Raj Kandu (05/05/2009).
** The parameter for this plugin are:
** The wrapper class name which is the top most element: eg articleArchive;
** The toggleClassName which is the drop down picture(Optional): eg downIcon;
** The slideUpSpeed, which is the speed at which it slides Up an element(Optional): eg{slow","normal",or"fast(Default)"}
** The slideDownSpeed, which is the speed at which it slides Down an element(Optional): eg{slow","normal(Default)",or"fast"}
** The slideToggleSpeed, which is the speed at which it toggles between slideUp and slideDown(Optional): eg{"slow(Default)","normal",or"fast"}
** This is how you can use it anywhere in your script tag
   $().ready(function() {
	   $('.articleArchive').slideAccordionYearMonth({
		slideUpSpeed:"fast",
                                slideDownSpeed: "normal",
                                slideToggleSpeed: "slow",
		toggleClassName:"downIcon"
		});
	});
*/


(function($){  
     $.fn.slideAccordionYearMonth = function(options){
     
     var defaults = {  
       
       slideUpSpeed:"fast",
       slideDownSpeed: "normal",
       slideToggleSpeed: "slow",
	   toggleClassName: "toggleClassDownIcon"	
       };
      
		var options = $.extend(defaults, options);  
		
		return this.each(function() {  
		
			var obj = $(this);
			
			
			//looks for the ul within the provided class name at month level and slides it up
			$("ul ul ul",obj).slideUp(options.slideUpSpeed);
			
			//looks for the ul within the provided class at year level and slides it up
			$("ul ul",obj).slideUp(options.slideUpSpeed);
			
			//looks for the ul within the provided class at year level and slides it down 
			$("ul:first ul:first",obj).slideDown(options.slideDownSpeed);
			
			//looks for the class name which needs to be toggled with at the current year
			$("ul:first div:first",obj).toggleClass(options.toggleClassName);
			
			//looks for the ul within the provided class at year level and slides the first month down
			$("ul ul ul:first",obj).slideDown(options.slideDownSpeed);
			
			//looks for the class name which needs to be toggled with at the current month
			$("ul ul:first div:first", obj).toggleClass(options.toggleClassName);
			
			
			//attaches the click event on the class which needs to be clicked in order to toggle slide
			$("ul li div", obj).click(function() {  
					   $(this).toggleClass(options.toggleClassName);
					   $(this).next().slideToggle(options.slideToggleSpeed); 
					});
	           
		 
               });
	
		};
             
      
             
     })(jQuery);


