Event.observe(window, 'load', startFunction, false);
function startFunction(){
	manageMenu('lev2','activeMenu');
	blurAnchors();
	manageBlockInfo();
	manageGalery();
	manageVariants();
	manageNutriInfo();
}

function manageNutriInfo() {
	if (! document.getElementById('infos')) return;
	displayNutriInfo();
}

function getFlashMovieObject(movieName) {
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet") == -1) {
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName];
	} else {
		return document.getElementById(movieName);
	}
}

function setFlashVariable (flashId, variableName, value) {
	document.getElementById(flashId).SetVariable (variableName, value);
}

function setImages (flashId, standardImageUrl, zoomImageUrl) {
	setFlashVariable (flashId, "standardImageUrl", standardImageUrl);
	setFlashVariable (flashId, "zoomImageUrl", zoomImageUrl);
}

function manageVariants(){
	if (! document.getElementById('listVariants')) return;
	var listeLesNodes = document.getElementById('listVariants').getElementsByTagName('li');
	$A(listeLesNodes).each(function(node) {

		Event.observe(node.getElementsByTagName('a')[0], 'click', function(){
			$A(listeLesNodes).each(function(node2) {
				node2.className = "";
			})
			node.className = "listVariantOn";
		})
	})
}

function manageGalery(){
	if (! document.getElementById('affiches')) return;
	var listeLesNodes = document.getElementsByClassName('downLoad');
	$A(listeLesNodes).each(function(node) {
		var ulDownload = "";
		if (node.parentNode.parentNode.getElementsByTagName('ul')[1]) Element.toggle(node.parentNode.parentNode.getElementsByTagName('ul')[1]);
		Event.observe(node.getElementsByTagName('a')[0], 'click', function(){
			Element.toggle(node.parentNode.parentNode.getElementsByTagName('ul')[1]);
		})
	})
}

function manageBlockInfo(){
	if (! document.getElementById('productInfoBlock')) return;
	
	document.getElementById('productInfoBlock').style.display = 'none';
}
function toggleProductInfos() {
	if (! document.getElementById('productInfoBlock')) return;
	var elem = document.getElementById('productInfoBlock');
	if(elem.style.display == 'none') elem.style.display = 'block';
	else elem.style.display = 'none';
}

function blurAnchors()
{
	if(document.getElementsByTagName)
	{
		// on r&eacute;cup&egrave;re le tableau contenant tous les "A" de la page
		var a = document.getElementsByTagName("A");
		//collecter tous les A en faisant une boucle sur le tableau

		for(var i = 0; i < a.length; i++)
		{
			// ajouter le onfocus &agrave; chaque ocurrence
			a[i].onfocus = function(){this.blur();};
		}
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

///// MENU ////////////////////////////////////
// THE GOAL OF THIS FUNCTION IS TO MAKE A HTML MENU WITHOUT ANY JAVASCRIPT IN HIS CODE
// IT WORKS WITH PROTOTYPE.JS
// YOU'LL HAVE TO CALL IT WITH THIS COMMAND :
// manageMenu('myMenuId','ulClassOn'); -> for exemple : manageMenu('lev2','activeMenu');
// 'myMenuId' is the id of the block which contain the menu
// 'ulClassOn' is the name of the id taken by the visible level

// common variables
var hideUl = "";

// menu initialization
function manageMenu(mydiv,ulClassOn) {
	if (! document.getElementById(mydiv)) return;
	//hideElements(mydiv,'display');
	/*hideUl = document.getElementById(mydiv).getElementsByTagName('ul')[0].getElementsByTagName('ul');
	var listeLesNodes = document.getElementById(mydiv).getElementsByTagName('ul')[0].getElementsByTagName('a');
	$A(listeLesNodes).each(function(node) {
		var ul = node.parentNode.childNodes[2];
		if (ul) {
			Event.observe(node, 'click', function(){
				var ulClassOnExist = "";
				$A(hideUl).each(function(display) {
					if(display.parentNode.childNodes[2].getAttribute("id") == ulClassOn) {
						ulClassOnExist = "true";
					}
				});
				if (ulClassOnExist == "true") hideElement(ulClassOn);
				if(ul.getAttribute("id") != ulClassOn) {
					hideElements(ul,'css');
					ul.setAttribute("id", ulClassOn);
					showElement(ulClassOn);
				}
				else {
					ul.setAttribute("id", "");
				}
			});
			Event.observe(node, 'keypress', function(event){ if (event.keyCode == Event.KEY_TAB) ul.show() + ul.focus() });
		}
	});
	$A(hideUl).each(function(display) {
		if(display.parentNode.childNodes[2].getAttribute("id") == ulClassOn) {
			display.className = ulClassOn;
			display.setAttribute("id", ulClassOn);
			Effect.BlindDown(ulClassOn, {duration:1});
		}
	});*/
	jQuery('#'+mydiv+' > ul > li > ul').hide();
	jQuery('#'+mydiv+' > ul > li > a').click(function(){
		toDisplay = jQuery(this).parent().find('ul');
		if(toDisplay.attr('class') != ulClassOn) {
			toDisplay.attr('class', ulClassOn);
			toDisplay.show('slow');
		}
		else {
			toDisplay.attr('class', '');
			toDisplay.hide('slow');
		}
	});
}

// function use for hiding elements
function hideElements(mydiv,elmt) {
	$A(hideUl).each(function(display) {
		if (elmt == "display") display.parentNode.childNodes[2].style.display = "none";
		else if (elmt == "css") display.parentNode.getElementsByTagName('ul')[0].setAttribute("id", "");
	});
}

// function used to show elements (work with scrip aculous)
function showElement(mydiv) { Effect.BlindDown(mydiv, {duration:1}); }

// function used to hide elements (work with scrip aculous)
function hideElement(mydiv) { Effect.BlindUp(mydiv, {duration:1}); }

// function used for galery
function timedOutGalleryDisplay (galleryFile, mediaIndex) {
	setFlashVariable ("galerie", "galleryFile", galleryFile);
	setFlashVariable ("galerie", "mediaIndex", mediaIndex);
}

function setGalleryDisplay (galleryFile, mediaIndex) {
	document.getElementById("flashGallery").style.display="block";
	// Timeout to fix Firefox bug on SetVariable call.
	setTimeout("timedOutGalleryDisplay('"+ galleryFile +"','" + mediaIndex +"')", 100);
}

function setGalleryDisplayLarge (galleryFile, mediaIndex) {
	document.getElementById("flashGalleryLarge").style.display="block";
	// Timeout to fix Firefox bug on SetVariable call.
	setTimeout("timedOutGalleryDisplay('"+ galleryFile +"','" + mediaIndex +"')", 100);
}

// function used for send to a friend in galery
function sendToAFriend(mediaIndex) {
}

// Function called by Flash, which sets container div width and height.
function resizeFlash(containerDiv, width, height) {

	document.getElementById(containerDiv).style.visible = true;
	if (width != undefined && width != null) {
		document.getElementById(containerDiv).style.width = width;
	}
	if (height != undefined && height != null) {
		document.getElementById(containerDiv).style.height = height;
	}
}

function closeFlashGallerylarge () {
	document.getElementById("flashGalleryLarge").style.display="none";
}

function closeFlashGallery () {
	document.getElementById("flashGallery").style.display="none";
}

function altError()
{
	if (document.formReglement.chkReglement.checked == false)
	{
		document.getElementById('altError').style.visibility = "visible";
		return;
	}
	else
	{
		document.getElementById('altError').style.visibility = "hidden";
		document.formReglement.submit();
	}
}

function opaceIt(layer, opacity){
	document.getElementById(layer).style.visibility = "visible";
	if (opacity == 1) {
		document.getElementById(layer).setOpacity(0);
		return new Effect.Opacity(layer, 0, opacity);
	} else {
		document.getElementById(layer).setOpacity(1);
		return new Effect.Opacity(layer, 1, opacity);
	}
}