//Simle Animated Menu for Mootools 1.2 v1
//Released June 2008 
//Dedicated to the public domain by www.consideropen.com
var url = '';


var navArrowSlider = function(navWrap, navElementsArray, activeID, arrowY, leftOffset) {

    var youAreHere = new Fx.Tween($(navWrap), {
        duration: 2200,
        transition: Fx.Transitions.Elastic.easeOut
    });

    $$(navElementsArray).each(function(item){
            
        item.addEvent('mouseenter', function() {
            var thisPos = item.getPosition($('menu')).x  - leftOffset;
            youAreHere.cancel();

            if (item.id != activeID)
                $('nav_wrap').tween('width', (item.getSize().x+20) + 'px');
            youAreHere.start('left', thisPos + 'px ' + arrowY + 'px');
            $('title').innerHTML = item.innerHTML;

            $('nav_wrap').item = item;
                       
        });
    });

    $('nav_wrap').addEvent('click', function() {
        if (this.item) {
            $(activeID).id = '';
            this.item.id = activeID;
            var link = this.item.getAttribute('link');
            new Request.HTML({
                url:link,
                update:$('iframecontenu'),
                onSuccess:function() {
                    //TB_init();
                    milkbox.reloadGalleries();
                    milkbox.setAutoPlay([
		{ gallery:'gall1', autoplay:true, delay:5 }]);
                    
                    SqueezeBox.assign($$('a[class=iframe]'), {handler: 'iframe'});
                    $$('.googlemap').setStyles({
                        'width':'150px',
                        'height':'150px'
                    });
                }
            }).send();
        }
    });
	
    var currentArrow = function() {
        var activePos = $(activeID).getPosition($('menu')).x  - leftOffset;
        youAreHere.cancel();
        youAreHere.start('left', activePos + 'px ' + arrowY + 'px');

           
        $('nav_wrap').tween('width', ($(activeID).getSize().x+20) + 'px');
        $('title').innerHTML = $(activeID).innerHTML;

              
    };
	
    //correct IE rendering problem (without this, it wont go to the active nav onload)
    var activePos = $(activeID).getPosition($('menu')).x  - leftOffset;
    youAreHere.start('left', activePos + 'px ' + arrowY + 'px');
      
	
    //works to set image to starting position in other browsers
    currentArrow();
	
    $(navWrap).addEvent('mouseleave', currentArrow);
}; 
	
window.addEvent('domready', function() {
    navArrowSlider(
        'nav_wrap', // ID of nav wrap
        '#menu ul li', // Array selector of nav elements
        'active_nav', // ID of current nav element
        '0px', //  Background position y of background image
        '10' //  INT ONLY - How far left from the right edge of the nav element that the image settles
        );

    $$('#bephoto,#ami').fade('0.5');
    $('bephoto').addEvent('click', function() {

        window.location.href = 'http://www.bephoto.be';
    });

    $$('#bephoto,#ami').addEvent('mouseover', function() {
        this.fade('0.9');
    });
    $$('#bephoto,#ami').addEvent('mouseleave', function() {
        this.fade('0.5');
    });
}); 

