﻿/*
Plugin: iframe autoheight jQuery Plugin
Version: 1.5.0
Description: when the page loads set the height of an iframe based on the height of its contents
see README: http://github.com/house9/jquery-iframe-auto-height 
*/
(function (a) {
    a.fn.iframeAutoHeight = function (b) {
        function e(b, c) {
            d("Diagnostics from '" + c + "'");
            try {
                d("  " + a(b, window.top.document).contents().find("body")[0].scrollHeight + " for ...find('body')[0].scrollHeight"), d("  " + a(b.contentWindow.document).height() + " for ...contentWindow.document).height()"), d("  " + a(b.contentWindow.document.body).height() + " for ...contentWindow.document.body).height()")
            } catch (e) {
                d("  unable to check in this state")
            }
            d("End diagnostics -> results vary by browser and when diagnostics are requested")
        }
        function d(a) {
            c.debug && c.debug === !0 && window.console && console.log(a)
        }
        var c = a.extend({
            heightOffset: 0,
            minHeight: 0,
            callback: function (a) { },
            debug: !1,
            diagnostics: !1
        }, b);
        d(c), a(this).each(function () {
            function f(b) {
                c.diagnostics && e(b, "resizeHeight");
                var f = a(b, window.top.document).contents().find("body"),
                    g = f[0].scrollHeight + c.heightOffset;
                g < c.minHeight && (d("new height is less than minHeight"), g = c.minHeight + c.heightOffset), d("New Height: " + g), b.style.height = g + "px", c.callback({
                    newFrameHeight: g
                })
            }
            var b = 0;
            d(this), c.diagnostics && e(this, "each iframe");
            if (a.browser.opera) {
                d("browser is opera"), a(this).load(function () {
                    var a = 0,
                        c = this;
                    c.style.height = "0px";
                    var e = function () {
                        f(c)
                    };
                    b === 0 && (a = 500), d("load delay: " + a), setTimeout(e, a), b++
                });
                var g = a(this).attr("src");
                a(this).attr("src", ""), a(this).attr("src", g)
            } else a(this).load(function () {
                f(this)
            })
        })
    }
})(jQuery);
