﻿$(document).ready(function () {

     //Check if browser is Opera or Safari(Webkit so Chrome as well)            
        if ($.browser.safari || $.browser.opera) {
            // Start timer when loaded.                
            $('.Wam').load(function () {
                    setTimeout(iResize(), 200);
            });
        }
        else if ($.browser.mozilla) {
            jQuery.event.add(window, "load", iResize);
        }
        else {
            $('.Wam').load(function () {
                    iResize();
            });
        }

        function iResize() {

            $('.Wam').each(function () {
                try {
                   
                    this.style.height = '0px';
                    //alert(this.src);

                    var heightDiv = 0;
                    heightDiv = $(this).contents().find('html').attr('scrollHeight');
                    heightDiv = $(this).contents().find('html').attr('scrollHeight');
                    //alert('Htmlheight ' + heightDiv);
                    if (heightDiv < 30) {
                        heightDiv = $(this).contents().find('body').attr('scrollHeight');
                        //alert('Bodyheight ' + heightDiv);
                        if (heightDiv < 30) {
                            heightDiv = '800';
                            //alert('Overheight ' + heightDiv);
                        }
                    }
                    heightDiv = heightDiv + 30;

                    this.style.height = heightDiv + 'px';
                }
                catch (e) {
                    //alert(e.Message);
                    this.style.height = '800px';
                }
            });

        }
});
