$(document).ready(function(){
	//menu 
	$('#nav01 a').click(function(){
		$this = $(this);
		li = $this.parent();
		if(li.find('ul').length){
			ul = $this.parent().parent();
			showedClass = 'selected';
			if(li.hasClass(showedClass)){
				li.removeClass(showedClass);	
			} else {
				ul.find('> .'+showedClass).removeClass(showedClass);
				li.addClass(showedClass);	
			}
			return false;
		}										
	});


	// Init Galleriffic Gallery
	$('#gallery-adv').galleriffic('#thumbs-adv');
	
	
	/* easy font size switcher */ 
	(function($) {
		function switchTextSize(size) {
			$('body').attr('id', size);
			$.cookie('textsize', size, {path:'/'});
			$('#contentPane').jScrollPane();
		}
		
		$.fn.easyfs = function() {
			var curtextsize = $.cookie('textsize');
			if (curtextsize) { $('body').attr('id', curtextsize); }

			return this.each(function(){
				$(this).bind('click', function(){
					switchTextSize(this.className);
					return false;
				});
			});
		}
	})(jQuery);
	$('#tools a[class^=sizer]').easyfs();
	
	
	// Init scrollbar
	$('#contentPane').jScrollPane({showArrows:true});
	
	$(".fancybox").fancybox();
	
	
	/* CONCOURS */
	$('#content .concours-medias a').hover(function(){
		$('.info', this).fadeIn();
	}, function(){
		$('.info', this).hide();
	});	
	
	$('#content .concours-medias label').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	}).click(function(){
		$(this).find('input').attr('checked', 'checked').trigger('change');	
	});
	
	$('#content .concours-medias input').change(function(){
		$(this).parents('ul').find('.selected').removeClass('selected');
		if(this.checked) $(this).parent().addClass('selected');
	}).filter(':checked').trigger('change');
	
	$('#formConcoursVotes').submit(function(){
		if(!$('input[name=print]').is(':checked')){
			alert('Veuillez voter pour la campagne "Print" avant de continuer.');
			return false;
		}
		if(!$('input[name=spot]').is(':checked')){
			alert('Veuillez voter pour la campagne "Spot radio" avant de continuer.');
			return false;
		}
		if(!$('input[name=video]').is(':checked')){
			alert('Veuillez voter pour la campagne "Clip vidéo" avant de continuer.');
			return false;
		}
	});
	
	$('#formConcoursSave').validate({
		rules: {
			email: {
				required:true,
				email:true
			}
		}														
	});
});

Shadowbox.init();