var elarray = [];
var totalength = 0;
window.addEvent('domready', function() {	
            //first, apply a class to each of your menu element
            //$$('.links') puts every element wearing the .links class into an array
            //$$('.links').each is to browse the array an apply a funtion to... each of them
            $$('.menyknapp').each(function(el, i){
            
                var RaskFade = new Fx.Tween(el.getFirst().getFirst(), { //the fact i apply the effect on el
                    wait: false, //and wait: false which make the effect not waiting (very useful on the mouseout or mouseleave function...
                    duration: 1
                });
                
                var MediumFade = new Fx.Tween(el.getFirst().getFirst(), { //the fact i apply the effect on el
                    wait: false, //and wait: false which make the effect not waiting (very useful on the mouseout or mouseleave function...
                    duration: '100'
                });
                
                var FadeTekst = new Fx.Tween(el.getLast(), { //the fact i apply the effect on el
                    wait: false, //and wait: false which make the effect not waiting (very useful on the mouseout or mouseleave function...
                    duration: '400'
                });
                
                var SakteFade = new Fx.Tween(el.getFirst().getFirst(), { //the fact i apply the effect on el
                    wait: false, //and wait: false which make the effect not waiting (very useful on the mouseout or mouseleave function...
                    duration: '800'
                });
                
                var fadeout	= function(){ SakteFade.start('top', 0, -36);  FadeTekst.start('color', '#23a1ca' ,'#FFFFFF'); /*el.getFirst().getFirst().fade(0);*/ }
                var fadein	= function(){ MediumFade.start('top', -36, 0); FadeTekst.start('color', '#FFFFFF', '#23a1ca'); /*el.getFirst().getFirst().fade(0.4);*/ }

             
                el.addEvents({
                    'mouseenter'	: fadein,
                    'mouseleave'	: fadeout
                });
                
            });
                        
            if (window.attachEvent && !window.opera) {
            
            } else {
            $$('.menyknapp').each(function(el, i) { elarray.push(el); totalength += el.getSize().x; });

            $$('.menyknapp').each(function(el, i){
               el.style.width = (el.getLast().getSize().x + ((662-totalength)/elarray.length)) +'px';
               el.getFirst().style.width = (el.getLast().getSize().x + ((662-totalength)/elarray.length)) +'px';
            });
           /*     if(window.getSize().x > 1600){
                    $('body').style.backgroundImage = 'url(/webgrafikk/forside_bg_stor.jpg)';
                    $('body').style.backgroundRepeat = 'no-repeat';
                }*/
            }
        /*window.addEvent('resize', function(e) {
            if(window.getSize().x > 1600){
                $('body').style.backgroundImage = 'url(/webgrafikk/forside_bg_stor.jpg)';
                $('body').style.backgroundRepeat = 'no-repeat';
            } else {
                $('body').style.backgroundImage = 'url(/webgrafikk/forside_bg.jpg)';
                $('body').style.backgroundRepeat = 'no-repeat';
            }
        });*/
        } );
