var _fo =   {
    root:   '',
    
    init: {
        _:  function() {

            this.nav._();
            this.video._();
        },
        
        nav: {
            _:  function() {

                //this.click._();
                //this.roll._();
            },
            
            click: {
                _:  function() {
                    
                    $('#nav .roll-theme').click(function() {
                        
                        var l_code  =   $_nav.attr('id');
                        var l_ref   =   'reference-' + l_code;
                        $('#'+l_ref).show();
                    });
                }
            },
            
            roll: {
                _:  function() {
                          
                    $('#nav .roll-theme')
                        .each(function(){
                            
                            var $_nav   =   $(this);
                            
                            $_nav.data('isover', false);
                            
                            var l_code  =   $_nav.attr('id');
                            var l_ref   =   'reference-' + l_code;
                            
                            //  roll seulement si on est sur une page différente
                            if (!$('#'+l_ref).hasClass('visible')) 
                            {
                                $('#'+l_ref)
                                    .data('isover', false)
                                    .mouseover(function() {

                                        $(this)
                                            .data('isover', true)
                                            .delay(500)
                                            .each(function() {

                                                if ($(this).data('isover') || $('#'+l_code).data('isover')) 
                                                {
                                                    $(this).show();
                                                } 
                                            })
                                        ;

                                    })
                                    .mouseout(function() {

                                        $(this)
                                            .data('isover', false)
                                            .delay(500)
                                            .each(function() {

                                                if (!$(this).data('isover') && !$('#'+l_code).data('isover')) 
                                                {
                                                    $(this).hide();
                                                } 
                                            })
                                        ;
                                    })
                                    .hide()
                                ;

                                $_nav
                                    .mouseover(function() {

                                        $(this)
                                            .data('isover', true)
                                            .delay(500)
                                            .each(function() {

                                                if ($(this).data('isover') || $('#'+l_code).data('isover')) 
                                                {
                                                    $('#'+l_ref).show();
                                                } 
                                            })
                                        ;
                                    })
                                    .mouseout(function() {

                                        $(this)
                                            .data('isover', false)
                                            .delay(500)
                                            .each(function() {

                                                if (!$(this).data('isover') && !$('#'+l_ref).data('isover')) 
                                                {
                                                    $('#'+l_ref).hide();
                                                } 
                                            })
                                        ;
                                    })
                                ;
                            }
                        })                
                        .click(function() {
                            
                            return false;
                        })
                    ;
                }
            }
        },
        
        video: {
            _:  function() {

                $('img._video').each(function() {
                    
                    var $_video =   $('<div></div>');
                    
                    $_video
                        .css({
                            width:  $(this).width() + 'px',
                            height: $(this).height() + 'px',
                            margin: $(this).css('margin'),
                            'float':$(this).css('float') 
                        })
                        .flashembed({

                            src: '_public/flash/player.swf?skin=_public/flash/ClearOverPlaySeekMute.swf&path=' + _fo.root + '/' + $(this).attr('rel'),
                            wmode: 'opaque',
                            scale: 'exactfit'
                        })
                    ;
                    $(this).replaceWith($_video);
                    
                });
            }
        }
    }
}

$(document).ready(function() {_fo.init._();});
