// Fonction lancée au démarrage
function initPage() {

}

// Joue sur le visibility d'un ?ment
function affiche(div, etat) {
	document.getElementById(div).style.visibility = (etat==1)?"visible":"hidden";
}

// Joue sur le display d'un élément
function montre(div, etat) {
	document.getElementById(div).style.display = (etat==1)?"block":"none";
}

// Récupère la valeur d'un élément
function getVal(div) {
	return document.getElementById(div).value;
}

// Affiche un sous menu
function sousmenu(smenu, etat) {
	montre('nav2-'+smenu, etat);
	var classe = etat==0?'':'active';
	document.getElementById('nav-'+smenu).className = classe;
}

// Met en surbrillance le menu sélectionné
function highlight(div) {
	var d = 'nav-'+div;
	var cn = document.getElementById(d).className;
	document.getElementById(d).className = cn+'active';
}

// Animation du bouton contact sur la homepage
window.addEvent('load', function() {
	boutonReactif('homecontact');
});

// Animation du bouton contact sur la fiche produit
window.addEvent('domready', function() {
	if($('bcontact')) {
		new Fx.Style('bcontact', 'opacity').set(0);
	}
});
window.addEvent('load', function() {
	var bContact = $('bcontact');
	if(bContact) {
		var bContactOpacity = new Fx.Style(bContact, 'opacity', {duration: 600});
		bContactOpacity.start(1);
		boutonReactif(bContact)
	}
});

function boutonReactif(elt, opacite, duree) {
	if(!opacite)
		opacite = 0.8;
	if(!duree)
		duree = 150;
	var b = $(elt);
	if(b) {
		var bHoverOpacity = new Fx.Style(b, 'opacity', {duration: duree});
		b.addEvent('mouseover', function() {
			bHoverOpacity.start(opacite);
		});
		b.addEvent('mouseout', function() {
			bHoverOpacity.start(1);
		});
	}
}