/****************************************************
//
// Emmanuel BELAIR 2009 V 1.0
// Fichier contenant les diverses fonctions mootools du site 
//
//**************************************************/

/**
** ASCENSEURS DE MENU
**/
function calculateHeightList(titleHeight,linkHeight,IdName) {
	var nbLink = document.getElementById(IdName).getElementsByTagName('a').length;
	var size = (linkHeight * nbLink) + titleHeight;
	
	return size;
}

window.addEvent('domready', function(){

	// Gammes
	var heightGammes = calculateHeightList(26, 21, "gammeList");
	
	$('gammeList').addEvents({
		'mouseenter':function(){
			this.set('tween', {
				duration: 600
			}).tween('height',heightGammes+"px");
		},
		'mouseleave': function(){
			this.set('tween',{}).tween('height','25px');
		}
	});
	
	// Produits
	$('produitList').addEvents({
		'mouseenter':function(){
			this.set('tween', {
				duration: 600
			}).tween('height',"250px");
			
		},
		'mouseleave': function(){
			this.set('tween',{}).tween('height','25px');
		}
	});
});

/**
** ACCORDEONS DANS L'ADMIN
**/
window.addEvent('domready', function() {
    //create our Accordion instance
    var myAccordion = new Accordion($('accordion'), 'h4.toggler', 'div.element', {
        opacity: false,
        display: 0,
		alwaysHide: true,
		onActive: function(toggler, element){
            //selectionne la premiere image trouvée dans toggler
            new Fx.Tween(toggler).start('opacity', 0.3, 1);
            toggler.getElement('img').src = '/images/togglerTop.png';
        },
        onBackground: function(toggler, element){
            //selectionne la premiere image trouvée dans toggler
            toggler.getElement('img').src = '/images/togglerBottom.png';
        }
	});
});