/* IE
-------------------------------------------------------------- */
if($.browser.msie && $.browser.version <= 6){
	$('.title + *').addClass('nextTitle');
}

/* Main nav (drop down menu)
-------------------------------------------------------------- */
$.fn.dropDown = function(){
	return this.each(function(){
		var $this = $(this);
		$('> li',$this).each(function(i){
			if( $('ul',this).length ){
				$(this).hover(
					function(){
						$(this).addClass('hover');
					},
					function(){
						$(this).removeClass('hover');
					}
				);
			}
		});
	});
};
/* => */ $('#main-nav').dropDown();

/* Sub nav (sidebar)
-------------------------------------------------------------- */
$.fn.subNav = function(){
	return this.each(function(){
		var $this = $(this);
		$('dt',$this)
			.next('dd').css({ display: 'none' })
			.end().append('<span class="alt" />').find('span').live('click',function(){	
				$(this).toggleClass('alt').closest('dt').next('dd').slideToggle('fast');
				/*$(this).closest('dt').siblings().find('span').addClass('alt').closest('dt').next('dd').slideUp('fast');*/
			})
			.end().each(function(){
				if($(this).hasClass('open')){
					$(this).find('span').removeClass('alt').end().next('dd').css({ display: 'block' });
				}
			})
		;
	});
};
/* => */ $('#sub-nav').subNav();

/* FAQ
-------------------------------------------------------------- */
$.fn.faq = function(){
	return this.each(function(){
		var $this = $(this);
		// Click 1st level DT
		$(' > dt',$this).click(function(){
			var hasOpen = $(this).hasClass('open');
			$('dt.open',$this).removeClass('open');
			$(' > dd:visible',$this).css({ display: 'none' }).find('dd').css({ display: 'none' });
			if( !hasOpen ){
				$(this).addClass('open');
				$(' + dd',this).css({ display: 'block' });
			}
		});
		
		// Click 2nd level DT
		$('dl dt',$this).click(function(){
			var hasOpen = $(this).hasClass('open');
			$('dl dt.open',$this).removeClass('open');
			$(this).siblings('dd:visible').css({ display: 'none' });
			if( !hasOpen ){
				$(this).addClass('open');
				$(' + dd',this).addClass('open').css({ display: 'block' });
			}
		});
		
		// Click out
		/*$(document).click(function(e){
			if(!$(e.target).parents().filter('#faq').length){
				$('#faq *').each(function(){
					$(this).removeClass('open').filter('[style]').removeAttr('style');
				});
			}
		});*/
	});
};
/* => */$('#faq').faq();

/* Patch */
if($('#classement-complet').length){
	$('#classement-complet tr:even').removeClass('alt');
}
if($('.comparator').length){
	$('.comparator th:not(:last)').addClass('br');
	$('.comparator tr').removeClass('alt');
	$('.comparator tbody tr:even').addClass('alt');
}
