$(function () {

    var productSelector = $("#product_selector");

    $("#product_selector .inner .product > a, #content .product > a").hover(function () {
        $(this).parent().find("h3 a").addClass("hover");
    }, function () {
        $(this).parent().find("h3 a").removeClass("hover");
    });

    /*$("#content .product h3 a").each(function () {
        $(this).html($(this).html().replace(/\&reg;/g, '<sup>&reg;</sup>'));
    });*/

    productSelector.hover(function () {

        // Expand

        $(this).find(".inner, .product, .inner .product > a").stop(true);
        $(this).find(".inner").animate({
            'height': '150px'
        }, {
            duration: 500,
            easing: 'easeInOutExpo',
            complete: function () {
                $.each(
                    productSelector.find(".inner .product > a"),
	                function (index) {
	                    $(this).delay(100 * index).fadeIn();
	                }
                );
            }
        }).find(".product").animate({
            'bottom': '20px'
        }, {
            duration: 500,
            easing: 'easeInOutExpo'
        });

    }, function () {

        // Collapse

        $(this).find(".inner, .product").stop(true);
        $(this).find(".inner .product > a").stop(true, true).fadeOut(100, function () {
            productSelector.find(".inner").animate({
                'height': '80px'
            }, {
                duration: 500,
                easing: 'easeInOutExpo'
            }).find(".product").animate({
                'bottom': '30px'
            }, {
                duration: 500,
                easing: 'easeInOutExpo'
            });
        });
    });

});
