$(document).ready(function() {

    if ($.browser.msie) {
        // IE
        $('iframe.heighten').load(function() {
            try {
              var frame = $(this).get(0);
              var innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
              var objToResize = (frame.style) ? frame.style : frame;
              
              objToResize.height = innerDoc.body.scrollHeight + 120;
              
            } catch(err) {
            }
        });
   
    
    } else if ($.browser.safari || $.browser.opera || $.browser.webkit) {
        // Safari/Opera
        
        // Set specific variable to represent all iframe tags.
        var iFrames = document.getElementsByTagName('iframe.heighten');

        // Resize heights.
        function iResize() {
            // Iterate through all iframes in the page.
            for (var i = 0, j = iFrames.length; i < j; i++) {
              // Set inline style to equal the body height of the iframed content.
              iFrames[i].style.height = (iFrames[i].contentWindow.document.body.offsetHeight + 120) + 'px';
            }
        }
        
        // Start timer when loaded.
        $('iframe.heighten').load(function() {
            setTimeout(iResize, 10);
        });

        // Safari and Opera need a kick-start.
        for (var i = 0, j = iFrames.length; i < j; i++) {
            var iSource = iFrames[i].src;
            iFrames[i].src = '';
            iFrames[i].src = iSource;
        }
        
        
    } else {
        // For other good browsers.
        $('iframe.heighten').load(function() {
            // Set inline style to equal the body height of the iframed content.
            var height = 120;
            
            if (this.contentWindow.document.body.offsetHeight == 0) {
              height += $('#main-content', this.contentWindow.document.body).height();
            } else {
              height += this.contentWindow.document.body.offsetHeight;
            }
            
            this.style.height = height + 'px';
        });
    
    }
});

