(function ($) {
	
    $.promoMenu = function (el, options) {
        var self = this,
			node = $(el),
			blocks = $('> li', node),
			holder = $('.holder', blocks),
			bottoms = $('.b', holder),
			tops = $('.t', holder),
			icons = $('.trigger img', holder),
			ie = $.browser.msie;
			
        node.data('promoMenu', this);

        this.init = function () {
            this.options = $.extend({}, $.promoMenu.defaultOptions, options);
			
			holder.hover(this._hover);
			bottoms.height(node.height() - 200);
			if (!ie) {
				bottoms.css({opacity: 0});
			}
        };
		
		this._hover = function (e) {
			var target = $(this),
				b = $('.b', target),
				t = $('.t', target),
				icon = $('.trigger img', target);
			
			tops.stop().animate({height: 0});
			if (ie) {
				bottoms.hide();
			} else {
				bottoms.stop().animate({opacity: 0}, function () {
					$(this).hide();
				});
			}
			icons.stop().animate({opacity: 1});
			
			if (e.type == 'mouseenter') {
				t.stop().animate({height: 114});
				b.stop().show();
				if (!ie) {
					b.animate({opacity: 1});
				}
				icon.stop().animate({opacity: 0});
			}
		};
		
        this.init();
    };

    $.promoMenu.defaultOptions = {
    };

    $.fn.promoMenu = function (options) {
        return this.each(function () {
            (new $.promoMenu(this, options));
        });
    };
	
})(jQuery);

$('#promo-menu').promoMenu();
