/**
* @author:Grzegorz Frydrychowicz
*/

(function() {
	jQuery.fn.shnTogglePanel = function(settings) {
		var cContainers = this;
		settings = jQuery.extend({	
		toggleBtn:'.toggleBtn',
		togglePanel:'.box2M',
		animationOpen:'slow',
		animationClose:'slow'
		}, settings);
		return cContainers.each(function(){
			var jDomElem = this;	
			var panel = $(jDomElem).find(settings.togglePanel);
			
			var btn = $(jDomElem).find(settings.toggleBtn);
			
			if($(btn).hasClass('closed')){
				$(panel).hide();
			}
			btn.click(function(){ 
				if($(panel).css('display') == 'none'){
					$(this).removeClass('closed');
					$(panel).show("slide", { direction: "up" }, settings.animationOpen);
				}else{
					$(this).addClass('closed');
					//$(panel).hide(settings.animationClose);
					$(panel).hide("slide", { direction: "up" }, settings.animationClose);

					
				}
    		});
		});
	};
})(jQuery);
