var DATADISCOVERY = {}

DATADISCOVERY.main = function() {
    var pub = {},
        navigation = null;
        
    pub.init = function(e) {
        navigation = $('ul.navigation');
        navigation.find('li').hover(
            function(e) {
                var li = $(this);
                li.addClass('hover');
                var ul = li.children('ul');
                ul.fadeIn('fast');
            },
            function(e) {
                var li = $(this);
                li.removeClass('hover');
                li.children('ul').fadeOut('fast');
            }
        ).each(function() {
            var li = $(this);
            var ul = li.children('ul');
            if (ul.length > 0) {
                li.children('a').attr('url','#').click(function(e) {return false;});
                li.children('a').addClass('has-children');
            }
        });

        // floaters
        var floater = $('.floater');
        if (floater.size() > 0) {
            var win = $(window);
            var top = floater.offset().top - parseFloat(floater.css('marginTop').replace(/auto/,0));
            var left = floater.offset().left;
            win.scroll(function(e) {
                var y = win.scrollTop();
                if (y >= top) {
                  floater.addClass('fixed');
                  floater.offset({ left: left });
                } else {
                  floater.removeClass('fixed');
                }            
            });
        }
        
        //likebox
        var likebox = $('#likebox').hover(
            function(e) {
                likebox.stop(true);
                likebox.animate({
                    marginLeft: '-235px'
                },500, function(e) {
                    likebox.addClass('expanded');
                });
            },
            function(e) {
                likebox.stop(true);
                likebox.animate({
                    marginLeft: '-30px'
                },500, function(e) {
                    likebox.removeClass('expanded');
                });
            }
        ).click(function(e) { return false; });        
        
        // social        
        $('#social li a').hover(
            function(e) {
                var a = $(this);
                a.children('img').stop(true,true).fadeIn();
            },
            function(e) {
                var a = $(this);
                a.children('img').stop(true,true).fadeOut();
            }
        );
        
    };
    
    return pub;    
}();

$(document).ready(DATADISCOVERY.main.init);



