﻿﻿function _normarResize(iframe){
	var viewportheight;
	var i = 1;
	iframe.removeAttribute('style');
/*	
	if (typeof iframe.contentWindow.window.innerWidth != 'undefined'){
		alert(i++);
		viewportheight = iframe.contentWindow.innerHeight;
	}
	else
	*/
	if (typeof iframe.contentWindow.document.documentElement != 'undefined' && typeof iframe.contentWindow.document.documentElement.clientWidth != 'undefined' && iframe.contentWindow.document.documentElement.clientWidth != 0){
		viewportheight = iframe.contentWindow.document.documentElement.scrollHeight;
	}
	// older versions of IE
	else{
		viewportheight = iframe.contentWindow.document.getElementsByTagName('body')[0].clientHeight;
	}
	iframe.style.height = viewportheight + 'px';
	/*	
	if( typeof iframe.contentWindow.document.documentElement != 'undefined' ){
		iframe.style.height = iframe.contentWindow.document.documentElement.scrollHeight + 'px';
	}else{
		iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
	}
*/
}	
function _normarResize2(){
    this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
}
$(document).ready(function()
	{
		// Set specific variable to represent all iframe tags.
		var iFrames = document.getElementsByTagName('iframe');

		// 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 + 'px';
			}
		}

		// Check if browser is Safari or Opera.
		if ($.browser.safari || $.browser.opera)
		{
			// Start timer when loaded.
			$('iframe').load(function()
				{
					setTimeout(iResize, 0);
				}
			);

			// 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
		{
			$('iframe').each(function()
				{
					_normarResize(this);
				}
			);
			// For other good browsers.
			$('iframe').load(function()
				{
					_normarResize(this);
				}
			);
		}
	}
);
