(function($){
	$.fn.extend({
		offerToggle : function(){
			
			// For each element declared in function 
			return this.each(function(){
				
				var jThis = $(this);
				var jOptions = jThis.find("ul.onglets");
				var jOffers = jThis.find(".offres").children("div");
				
				// For each option on ul.onglets
				jOptions.find("input:radio").each(function(){
					var jOption = $(this);
					var jOptionCt = jOption.parent();
					//Sets the related content (gets the option parent id and uses as jquery class selector
					var jRelContent = $("."+jOptionCt[0].id).hide();
					
					//Checks the "checked" attribute on each option on document load, then display the related content
					if ( jOption.is(":checked") ){
						if (jOffers.length){ 
							jRelContent.show();
							jOffers.not(jRelContent).hide();
							jOptions.addClass('active');
						}
						jOptionCt.addClass("active").siblings().removeClass("active");
					}
					
					//Displays the related Content (and hides the others) while radio input status changes:
					jOption.click(function(){
						if (jOffers.length){ 
							jOffers.not(jRelContent).hide();
							jRelContent.show();
							jOptions.addClass('active');
						}
						jOptionCt.addClass("active").siblings().removeClass("active");
					});
					
				});
				
			});
		}
	});//How to init ? $(function(){ $(elt).offerToggle(); });

	if (!window.bt) {
		window.bt = { fn: {} };
	}
		
	bt.fn.initBTCard = function(){
		var jMobileList = $('#mobile_list'),
			jMobileListItem = jMobileList.find('li'),
			jSubmit = $('#choice-1 div.add_basket');
		jMobileListItem.each(function(){
			var jItem = $(this),
				jRadio = jItem.find('input[type=radio]');
			if (jRadio.is(':checked')){
				jMobileListItem.removeClass('active');
				jItem.addClass('active');
				jSubmit
					.addClass('active')
					.find('input[type=submit]')
					.removeAttr('disabled','disabled');
			} 
			jRadio.click(function(){
				if (jRadio.is(':checked')){
					jMobileListItem.removeClass('active');
					jItem.add(jSubmit).addClass('active');
					jSubmit.find('input[type=submit]').removeAttr('disabled');
				} 
			});
			
		});
	};
	
})(jQuery);