(function ($) {

    $.extend(com.luigibormioli, {products: {
        Guarantee: function () {

            var self, $open, $view, $mask, $content, $close, height, position;

            (function () {

                self = this;

                $open = $('a#guarantee-open').bind('click', show);

                $view = $('div#guarantee-view');

                $mask = $('div#guarantee-mask');

                $content = $('div#guarantee-content');

                $close = $('a#guarantee-close');

                height = $content.outerHeight();

                position = height * -1;

				$mask.css({top: position});

            })();

            this.show = show;

            function show() {

                $open.unbind('click', show);

                $view.css({height: height});

                $mask.animate({top: 0}, 500, 'easeInOutQuad', function () {

                    $open.bind('click', hide);

                    $close.bind('click', hide);

                    $content.animate({opacity: 1}, 500, 'easeInOutQuad');

                });

                return false;

            }

            function hide() {

                $open.unbind('click', hide);

                $close.unbind('click', hide);

                $content.animate({opacity: 0}, 500, 'easeInOutQuad', function () {

                    $mask.animate({top: position}, 500, 'easeInOutQuad', function () {

                        $view.css({height: 0});

                        $open.bind('click', show);

                    });

                });

                return false;

            }

        }
    }});

})(jQuery);