// JavaScript Document



$(document).ready(function(){  

	$("#nav ul").css('z-index','1000');

	var largeur = Math.round((1000- $("#nav ul").width())/2);
	$("#nav").prepend("<div class='spacer' style='width:"+largeur+"px;height:1px;float:left'></div>");

	$("#nav ul li ul.subnav").css('display','none');
	
	$("#nav ul li.main").each(
		function() {
			if ($(this).hasClass("select")) {
				$(this).css('background-image','none');
				$(this).css('text-shadow','none');
			}
		}
	);
	
	interactiveNav();
	
	
	
	largeur = 0;
	$("#subNavCatalogue .item").each(function() {
		largeur+=$(this).outerWidth(true)+2;
		$(this).children(".checked").css('left',(($(this).outerWidth(true)-$(this).children(".checked").width())/2)+'px');
		$(this).children(".check").css('left',(($(this).outerWidth(true)-$(this).children(".check").width())/2)+'px');
		$(this).children(".indicateur").css('left',(($(this).outerWidth(true)-$(this).children(".indicateur").width())/2)+'px');
	});
	largeur = Math.round((1000- largeur)/2);
	$("#subNavCatalogue").prepend("<div style='width:"+largeur+"px;height:1px;float:left'></div>");
	
	$("#subNavCatalogue .item").click(function() {
		document.location.href = $(this).attr('href');
	});
	
	$("#subNavCatalogue .item").hover(
		function() {
			$(this).children(".inside").animate({
				'margin-top': 25
			}, 150, function() {
				// Animation complete.
			});
			$(this).children(".inside").children(".spacer").animate({
				'height': 15
			}, 150, function() {
				// Animation complete.
			});
		},
		function() {
			$(this).children(".inside").animate({
				'margin-top': 40
			}, 150, function() {
				// Animation complete.
			});
			$(this).children(".inside").children(".spacer").animate({
				'height': 0
			}, 150, function() {
				// Animation complete.
			});
		}
	);
	
	
	largeur = 0;
	$("#subSubNavCatalogue .item").each(function() {
		largeur+=$(this).outerWidth(true)+2;
	});
	largeur = Math.round((1000- largeur)/2);
	$("#subSubNavCatalogue").prepend("<div style='width:"+largeur+"px;height:1px;float:left'></div>");
	
	
	$(".bande").each(function() {
		largeur = 0;
		$(this).children(".article").each(function() {
			largeur+=$(this).outerWidth(true)+2;
		});
		largeur = Math.round((740 - largeur)/2);
		$(this).prepend("<div style='width:"+largeur+"px;height:1px;float:left'></div>");
	});
	
	
	
});

function interactiveNav() {
	$("#nav ul li.main").click(
		function() {
			$(this).find("ul.subnav").slideDown('fast').show();
			if (!$(this).hasClass("select")) {
				$(this).toggleClass("liOver");
				$(this).css('background-image','none');
				$(this).css('text-shadow','none');
			}
		}
	);
	
	$("#nav ul li.main").hover(
		function() {
			$(this).find("ul.subnav").slideDown('fast').show();
			if (!$(this).hasClass("select")) {
				$(this).toggleClass("liOver");
				$(this).css('background-image','none');
				$(this).css('text-shadow','none');
			}
		},
		function() {
			$(this).find("ul.subnav").slideUp('fast').show();
			if (!$(this).hasClass("select")) {
				$(this).toggleClass("liOver");
				$(this).css('background-image','url(images/breakNav.png)');
				$(this).css('text-shadow','1px 1px 1px #f0c48d');
			}
		}
	);
}
