﻿(function(a){a.fn.iframeAutoHeight=function(e){var c=a.extend({heightOffset:0,minHeight:0,callback:function(){},debug:false,diagnostics:false},e);function b(a){if(c.debug&&c.debug===true&&window.console)console.log(a)}function d(c,d){b("Diagnostics from '"+d+"'");try{b("  "+a(c,window.top.document).contents().find("body")[0].scrollHeight+" for ...find('body')[0].scrollHeight");b("  "+a(c.contentWindow.document).height()+" for ...contentWindow.document).height()");b("  "+a(c.contentWindow.document.body).height()+" for ...contentWindow.document.body).height()")}catch(e){b("  unable to check in this state")}b("End diagnostics -> results vary by browser and when diagnostics are requested")}b(c);a(this).each(function(){var f=0;function e(f){if(c.diagnostics)d(f,"resizeHeight");var g=a(f,window.top.document).contents().find("body"),e=g[0].scrollHeight+c.heightOffset;if(e<c.minHeight){b("new height is less than minHeight");e=c.minHeight+c.heightOffset}b("New Height: "+e);f.style.height=e+"px";c.callback({newFrameHeight:e})}b(this);if(c.diagnostics)d(this,"each iframe");if(a.browser.safari||a.browser.opera){b("browser is webkit or opera");a(this).load(function(){var a=0,c=this;c.style.height="0px";var d=function(){e(c)};if(f===0)a=500;b("load delay: "+a);setTimeout(d,a);f++});var g=a(this).attr("src");a(this).attr("src","");a(this).attr("src",g)}else a(this).load(function(){e(this)})})}})(jQuery)
