/* e-matters FAT MENU PLUGIN */

jQuery.fn.eFatMenu = function($params) {

    var $defaults = {
        //
    };

    var $p = jQuery.extend($defaults, $params);
    var $this = jQuery(this);
    var ie6 = false;
    var newMethods = {
        initiate_global: function() {
            $('#eFatMenu > li').menu_dropdown();
            ie6 = $.browser.msie&&($.browser.version == "6.0")&&!window.XMLHttpRequest;

        },
        menu_dropdown: function() {
            $(this).each(function() {
                var id = $(this).attr('data-eFM');
                $(this).append($('#'+id));
                $(this).hover(
                    function() {
                        if(ie6) $('select').css('visibility', 'hidden'); //Hide select elements to fix issue on IE6
                        if(ie6) $(this).addClass('ie6active'); 		 //Set Class for hover if IE6 (li:hover doesn't work for IE6)
                        $(this).find('.dropdown').show();
                    },
                    function() {
                        if(ie6) $('select').css('visibility', 'visible'); //Reset visibility
                        if(ie6) $(this).removeClass('ie6active'); 		  //Set Class for hover if IE6 (li:hover doesn't work for IE6)
                        $(this).find('.dropdown').hide();
                    }
                );
            });
        }
    };

    jQuery.each(newMethods, function(i) {
        jQuery.fn[i] = this;
    });

    return this.each(function() {
        $this = $(this);
    });

};

$( function() {
    $().eFatMenu().initiate_global();
});
