window.onresize = doResize;
window.addEvent('domready', function(){
                  
        MenuActive()    
        SetMenuActive()
        
        $('menu').setStyle('display', "block")
        $('inner-container').setStyle('display', "block")
              
        if($('SlideItMoo_outer')!=null){   
            
            new SlideItMoo({
    				overallContainer: 'SlideItMoo_outer',
    				elementScrolled: 'SlideItMoo_inner',
    				thumbsContainer: 'SlideItMoo_items',		
    				itemsVisible:4,
    				elemsSlide:1,
    				duration:300,
    				itemsSelector: '.SlideItMoo_element',
    				itemWidth: 167,
    				showControls:1,
                    slideVertical:true,
                    mouseenter: true,
            });
            
        }

        if($('SlideItReels')!=null){        
            new SlideItMoo({
    				overallContainer: 'SlideItReels',
    				elementScrolled: 'SlideItReels_inner',
    				thumbsContainer: 'SlideItMoo_items',		
    				itemsVisible:2,
    				elemsSlide:1,
    				duration:300,
    				itemsSelector: '.SlideItMoo_element',
    				itemWidth: 167,
    				showControls:1
            });
        }        
        
        if($$(".gallery2").length>0){
            var gallery2 = new slideGallery($$(".gallery2"), {
                    	steps: 1,
                        mode: "circle",
                        random: true,
                        autoplayOpposite: true,
                        stop: ".stop",
                        start: ".start",
                        duration: 4000,                                        
                        speed: 700             
                        
                    });
        }       
        if($$('.mb').length>0)
            var box = new multiBox('mb', {overlay: new overlay()})
        if($$('.mb2').length>0)
            var box = new multiBox('mb2', {overlay: new overlay()})
        if($$('.mb-video').length>0)
            var box = new multiBox('mb-video', {descClassName:'MultiBoxDescription', overlay: new overlay()})
        if($$('.mb-video2').length>0)
            var box = new multiBox('mb-video2', {descClassName:'MultiBoxDescription', overlay: new overlay()})
        if($$('.mb-reels').length>0){
            var box = new multiBox('mb-reels', {overlay: new overlay()})    
        }         
        
       ShowHidePBox ()
       
       
     
   
   if($('mousemove')!=null)
    MouseSlice()  
   
   doResize()    
   
   
  init_gallery_video()
    
});


function MenuActive(){   
       active = $('menu').getElements('title');       
       active.each(SetMenuActive)
       if(_section!="")
       $(_section).addClass('x-menu-active')
       
}

function SetMenuActive() {    
    active.addEvent('click',function(){

    })
}
var _inner_size = 0;
var _inner_size_w = 0;

function doResize(){
    
    var w      = window.innerWidth
    var h      = window.innerHeight
    
    if(h<670){
        $('menu').setStyle('top', "370px")
        if(_inner_size==0){
            _inner_size   = $('inner-container').getSize().y
            _inner_size_w = $('inner-container').getSize().x
        }
        var innerY = $('menu').getPosition().y + $('menu').getStyle("height").toInt() - _inner_size - 5
        $('inner-container').setStyle('top', innerY+"px")      
        $('inner-container').setStyle('bottom', "auto")  
        $('menu').setStyle('bottom', "auto")  
    }else{
        $('menu').setStyle('top', "")
        $('menu').setStyle('bottom', "15px")  
        $('inner-container').setStyle('top', "")
        $('inner-container').setStyle('bottom', "15px")   
    }
    if(w<1000){
        if(_inner_size_w==0){
            _inner_size_w = $('inner-container').getSize().x   

        }
         var innerW = 1000 - _inner_size_w 
        $('inner-container').setStyle('left', innerW+"px") 
        $('inner-container').setStyle('right', "auto") 

    }else{
         $('inner-container').setStyle('left', "") 
         $('inner-container').setStyle('right', "15px")
    }
    
       
}

function ShowHidePBox() {
    $$('.showhover').each(function(el){
        el.addEvents({
            mouseover: function(){
                el.getElement(".hover").setStyle('display','block');
            },
            mouseout: function(){
                el.getElement(".hover").setStyle('display','none');
            }
        })  
    }); 

}

function MouseSlice(){
    var scroll2 = new Scroller($('mousemove'), {area: 300, velocity: 0.03});
        scroll2.start();
}; 


function init_gallery_video(){
    if($('j-view-video')!=null){
        $('j-video').set("href", $('j-view-video').get('href'))
        $('j-video').set("rel", $('j-view-video').get('rel'))

    }
}



