/* MEGA MENU */
$(document).ready(function() {
	function addMega(){
		$(this).addClass("hovering");
		$(this).find('.megamenu').fadeIn(200);
	}

	function removeMega(){
		$(this).removeClass("hovering");
		$(this).find('.megamenu').fadeOut(200);
	}

	var megaConfig = {
		 interval: 0,
		 sensitivity: 4,
		 over: addMega,
		 timeout: 400,
		 out: removeMega
	};

	$("li.mega").hoverIntent(megaConfig);
});

/* TABS */

$(document).ready(function() {

	$('.bloc').each(function()
	{
		$('.panel', this).hide();
		$('.panel:first', this).show();
	});

	$('.bloc').tabs(
	{
		tabs: '.tab',
		panels: '.panel',
		mevent: 'click',

		before: function(wrap){
			$('.panels .panel', wrap).hide();
		},
		after: function(wrap){
			$('.panels .active', wrap).show();
		}
	});

});

// c'aurait été plus correct, setHeight ^plante sur certaines pages

//--- EQUALHEIGHTS
/*
$.fn.equalHeights = function () {
	var heightMin = 0;
	$(this).each(function(){
		$(this).each(function(){
			$(this).css({'height' : 'auto'});
			if ($(this).height() > heightMin) { heightMin = $(this).height(); }
		});
	});
	$(this).each(function(){ 
		$(this).css({'height': heightMin});
	});
};

$(window).load(function(){
	$('#bloc-center, #column, #wrap, #white').equalHeights();
});
*/
function setHeight(){
	//$('#bloc-center, #column, #wrap, #white').equalHeights();

	if ($('#form').length <0){
		if($(document.getElementById('column')).length > 0){
			if($(document.getElementById('column')).height() < ($(document.getElementById('bloc-center')).height()+20)){
				$(document.getElementById('column')).css('height',$(document.getElementById('bloc-center')).height()+20);
				$(document.getElementById('wrap')).css('height',$(document.getElementById('bloc-center')).height()-20);
				$(document.getElementById('white')).css('height',$(document.getElementById('bloc-center')).height()-20);
			}
			else{
				$(document.getElementById('bloc-center')).css('height',$(document.getElementById('column')).height()-20);
				$(document.getElementById('wrap')).css('height',$(document.getElementById('column')).height()-40);
				$(document.getElementById('white')).css('height',$(document.getElementById('column')).height()-40);
			}
		}
	}
}

$(document).ready(function(){

	setHeight();

	$('#CATAACTIVITEniv1').change(function(){
		$(document.getElementById('bloc-center')).css('height','auto');
		$(document.getElementById('wrap')).css('height','auto');
		$(document.getElementById('white')).css('height','auto');
		setHeight();
	});
});

/* THICKBOX */
var fermer='{#CLOSE#}';
var prev='{#PREV#}';
var next='{#NEXT#}';
var echapk='{#ECHAP#}';
var of="{#OF#}";

/* ACTUS */
$(document).ready(function(){
	$('#actualites .panel').each(function(){
		var articles = $(this).find('.article');
		articles.css({
			width : (100/articles.length)+'%'
		})
	});
});

/* PARTENAIRES */

$(document).ready(function(){
	$(document.getElementById('box_content')).scrolling({speed:speed});
});

/* Gabarit Spécial */

$(document).ready(function(){
	if($('#aside .side').length > 0 && $(document.getElementById('carrepub')).length > 0){
		$(document.getElementById('carrepub')).css('margin-top','20px');
	}
});
