/* ************************************************** *

	@file			global.js
	@description:	Comportements globaux
	@author:		Erick Gagnon
	@date:			20 mai 2010
	vim: set noet ts=4 fdm=marker fenc=utf-8:

***************************************************** */

if ( !window.console ) {
	(function() {
		var f = function() {};
		window.console = { log: f, warn: f, error: f, trace: f, group: f, groupCollapsed: f, groupEnd: f, time: f, timeEnd: f, profile: f, profileEnd: f, count: f };
	})();
}

(function($) {

	$(function() {

/* @Infolettre {{{
***************************************************** */
		$('#inscription-infolettre').click(function() {
			$('#inscription-infolettre').css('display','none');
			if (!($.browser.msie && $.browser.version.substr(0,1) < 7)) { // pas d'animation pour Explorer 6
				$('#formulaire-infolettre').show();
			} else {
				$('#formulaire-infolettre').fadeIn('750');
			}
		});
	
		if ($('form div').hasClass('actif')) {
			$('#inscription-infolettre').css('display','none');
			$('#formulaire-infolettre').show();
		};
/*}}}*/

/* @Effet de FADE sur certains éléments HOVER {{{
***************************************************** */
		if (!($.browser.msie && $.browser.version.substr(0,1) < 7)) { // pas d'animation pour Explorer 6
			$('#enrobage').removeClass('sans-javascript'); 
			$('#menu li a, #sous-menu-top li a, a.bouton, a#joindre, a#haut-de-page, button.bouton')
				.css({backgroundPosition: '0% 100%'})
				.mouseover(function(){
					$(this).stop().animate(
						{backgroundPosition:'(0% 0%)'}, 
						{duration:400}
					);
				})
				.mouseout(function(){
					$(this).stop().animate( 
						{backgroundPosition:'(0% 100%)'},  
						{duration:250}
					);
				});
		};
/*}}}*/

/* @Rotation "présentement à l'affiche" à l'accueil {{{
***************************************************** */

		var $presentementALaffiche = $('#presentement-a-l-affiche').children();
		if ($presentementALaffiche.length > 1) {
			
			$presentementALaffiche.not(':first').css('opacity', 0);
			var currentBlock = 0;
			setInterval(function() {
				var newBlock;
				if (currentBlock >= $presentementALaffiche.length-1) {
					newBlock = 0;
				} else {
					newBlock = currentBlock + 1;
				}
				$presentementALaffiche.eq(currentBlock).animate({ opacity: 0 }, 'fast');
				$presentementALaffiche.eq(newBlock).animate({ opacity: 1 }, 'fast');
				currentBlock = newBlock;
			}, 3000);
		
		}

/*}}}*/
	
	})
})(jQuery);
