(function ($) {
/*
    MVD.Expander = function (el, max, b) {
        if (el.length) {
            max = max || 16;
            el.css("visibility", "hidden").show();
            if (!b) {
                b = $('.expandBtn', el);
            }
            b.hide();
            console.log("boton expandir:", b);
            var h = el.height();
            console.log("max=", max, "h=", h);
            if (h > max) {
                el.height(max).css("overflow", "hidden");
                b.css("float","right").show().click(function () {
                    b.hide().unbind("click");
                    el.animate({height:h}, 500);
                    return false;
                });
            }
            el.css("visibility", "");
        }
    };
*/
    MVD.getLinesHeight = function(el, lines) {
        var cont = el.html();
        var max = el.css("display", "block").html('A').css("height", "").height() * lines;
        el.css("display", "").html(cont);
        return max;
    };

    /*
     * el: Elemento a expandir, b: link que expande, max: tamaño máximo de altura, redir: Si el link redirecciona en vez de expandir
     */
    MVD.Expander = function (el, b, max, redir) {
        if (el.length) {
            var h = el.css("visibility", "hidden").show().css("height", "").height();
            // console.log("max=", max, "h=", h);
            // alert("max=" + max + " h=" + h);
            if (h > max) {
                // console.log("boton expandir:", b);
                b.show();
                if (!redir) {
                    b.unbind("click").click(function () {
                        b.hide().unbind("click");
                        el.animate({height:h}, 500);
                        return false;
                    });
                }
                // console.log("fixed");
                el.height(max).css("overflow", "hidden");
            } else {
                b.hide();
            }
            el.css("visibility", "");
        }
    };
}) (jQuery);