jQuery(document).ready(function($) {   
    $('#social').css( 'opacity', '0.4' );
    /*hiding submenu's'*/
    $('.inside_navi').each(function(){
        if( $(this).find("span.current_gallery").length == 0 ){
            $(this).css( 'left' , '-' + $(this).width() -10 + 'px');
            $(this).parents('.navi_right').hide(); 
        }     
    })
    
    $("#navi_portfolio , #navi_projects").click(function(){
        return false;
    })
    
   /* submenu's slider's logic'  */
    
    $('#navi_portfolio_wrapper, #navi_projects_wrapper').each(function(){
        if( $(this).find("span.current_gallery").length == 0 ){  
            $(this).hover( function(){
                this.is_cursor_over = 1; 
                if( $(this).find('.navi_left a').get()[0].is_cursor_over == 1 ){
                    if( this.is_action != 1 && !$(this).find('.navi_right').is(':visible') ){ 
                        this.is_action = 1;
                        this.is_load = 1;
                        $(this).find('.navi_right').show();
                        $(this).find('.inside_navi').animate({
                            left: "0px"
                          }, 300 , function(){
                            $(this).parents('li').get()[0].is_action = 0; 
                            $(this).parents('li').get()[0].is_load = 0; 
                            if( $(this).parents('li').get()[0].is_cursor_over == 0 && $(this).parents('li').find('.navi_left a').get()[0].is_cursor_over == 0 ) {
                                $(this).parents('li').mouseleave();      
                            } 
                          });
                    }
                }

            } , function(){  
                this.is_cursor_over = 0; 
                if( this.is_action != 1 && this.is_load != 1 && $(this).find('.navi_right').is(':visible') && $(this).find('.navi_left a').get()[0].is_cursor_over == 0 ){   
                    this.is_action = 1; 
                    inner_pointer = $(this).find('.navi_right');
                    inner_width = $(this).find('.inside_navi').width() +10 ; 
                    $(this).find('.inside_navi').animate({
                        left: "-" + inner_width + "px"
                      }, 300, function(){
                        inner_pointer.hide();
                        $(this).parents('li').get()[0].is_action = 0;        
                      } );  
                }          
            } ) 
        }    
        
    })
    
    $('#navi_portfolio, #navi_projects').hover( 
        function(){
            this.is_cursor_over = 1;   
            $(this).parents('li').hover();   
        },
        function(){
            this.is_cursor_over = 0;                  
        }
    ) 
    
    
           
   
    /*remove last delimiter */  
    $('.inside_navi li:last-child').find('a, span').css({ border: 'none'} );

})
