/*
 *
 *	@titre: home.
 *	@description: javascript homepage - Moniteur Archizz.
 *	@auteur: neov - http://www.neov.net.
 *	@creation: 200900806.
 *	@modification: -.
 *	@requires: jquery 1.3.2
 *
 */

var imgTimer = 3000;
var imgLength = 0;
var imgStart = 1;
var int = null;

$(
	function()
	{
		// nbr image.
		imgLength = $('.photo > div').length;
		
		// animation.
		function animation(id)
		{
			$('.photo > div').hide();
			$('.photo > div').eq(id).show();
		}
		
		// commencer l'animation.
		function start()
		{
			int = setInterval(
				function()
				{
					if(imgStart<imgLength) {
						animation(imgStart);
						imgStart++;
					} else {
						animation(0);
						imgStart=1;
					}
				},
				imgTimer
			);
		}
		
		// arreter l'animation.
		function end()
		{
			clearInterval(int);
		}
		
		// rollover sur la grande image.
		$('.photo > div > .img > a').hover(
			function()
			{
				end();
			},
			function()
			{
				start();
			}
		);
		
		// rollover sur le carousel.
		$('.hcar1 li a').each(
			function(index)
			{
				$(this).hover(
					function()
					{
						end();
						animation(index);
						imgStart = index + 1;
					},
					function()
					{
						start();
					}
				);
			}
		);
		
		// popup liste des maitres d'oeuvre
		$('.listmoe').showPopListeMoe('#list-moe');
		
		start();
		
	}
);