// remove the "$" namespace from jQuery, avoids conflicts with other libraries
jQuery.noConflict();

// closure, mapping jQuery to $, window, document and undefined - useful for minifing tools
(function($, window, document, undefined){

// document ready method
$(function(){


	if ($.fn.accordion)
	{
		$('.accordion').accordion();
	}

});

// plugins

// accordion - jQuery plugin - creates an accordion - by Valentin Ceaprazaru http://valentin.ceapraza.ru
$.fn.accordion = function(args)
{
	if (!this.length) return false;
	var opts = $.extend({
		triggers: '.accordion-button',
		containers: '.accordion-content',
		allowOpened: true // true or false. If set to TRUE, a trigger can be set with ACTIVE class to be open on load
	}, args || {});

	return this.each(function(){
		var parent = $(this), triggers = parent.find(opts.triggers), containers = parent.find(opts.containers);
		
		triggers.click(function(){
			var trigger = $(this), container = trigger.next();

			containers.slideUp('normal');
			triggers.removeClass('active');

			if (container.is(':hidden') == true)
			{
				$(this).next().slideDown('normal');
				trigger.addClass('active');
			}
			return false;
		});
		containers.hide();

		if (opts.allowOpened)
		{	
			var active = (triggers.filter('.active').length) ? triggers.filter('.active') : triggers.eq(0);
			active.click();
		}
	});
}


})(jQuery, window, document);


