/**
 * myAccordion ( http://supercanard.phpnet.org/jquery-test/myAccordion/ )
 * plugin jQuery pour afficher des bôites d'onglet.
 * 
 * Version 1.0
 *
 * Auteur : Jonathan Coulet ( j.coulet@gmail.com )
 * 
 **/
(function($){
	$.fn.myAccordion = function(option){
		// Param plugin
		var param = jQuery.extend({
			speed: "medium", // @param : low, medium, fast
			defautContent: 0 // @param : number
		}, option);
		$(this).each(function() {
			// var
			var $this = this;
			var $thisId = this.id;
			// Attribut un id à chaque déclencheur
			$("#"+$thisId+" .discover-toggler").attr("id", function(arr){
				return $thisId+"-elem"+arr;
			})
			// Masque tous les content
			$("#"+$thisId+" .discover-toggler").next(".discover-content").hide();
			// Ouvre le content par défaut
			$("#"+$thisId+" #discover-elem"+option.defautContent).next(".discover-content").show();
			$("#"+$thisId+" #discover-elem"+option.defautContent).addClass("discover-toggler-actif");
			$("#"+$thisId+" #discover-elem"+option.defautContent).next(".discover-content").addClass("discover-content-actif");
			// Action sur déclencheur
			$("#"+$thisId+" .discover-toggler").click(function(){
				$("#"+$thisId+" .discover-content-actif").hide(option.speed);
				$("#"+$thisId+" .discover-content-actif").removeClass("discover-content-actif");
				$("#"+$thisId+" .discover-toggler-actif").removeClass("discover-toggler-actif");
				var contentCourant = $(this).attr("id");
				$("#"+$thisId+" #"+contentCourant).next(".discover-content").show(option.speed);
				$("#"+$thisId+" #"+contentCourant).addClass("discover-toggler-actif");
				$("#"+$thisId+" #"+contentCourant).next(".discover-content").addClass("discover-content-actif");
			});
		});
	}
})(jQuery);
