var h = 0;
var w = 0;
(function($) {
	h = $( window ).height();
	w = $( window ).width();
	$.fn.hasScrollBar = function() {
        return this.get(0).scrollHeight > this.height();
    }
})(jQuery);
function autoHeight() {
	var myParent = this.top; 
	if (myParent !== this) {
		$('#box-frame-footer').hide();
		var myParentIframes = myParent.document.getElementById('iframe-doc');// 64364:
		var ffFixIframeHeight = $(myParentIframes).height(); 
		var ffFixReportHeight = $(document).height();
		if($('*[class^="WordSection"]').length){
			// 69769
			ffFixReportHeight = 0;
			$('*[class^="WordSection"]').each(function(index, value){
				ffFixReportHeight += $(this).height();
			});
		}
		if($('*[x\\:publishsource^="Excel"]').length){
			// 70912
			ffFixReportHeight = 0;
			$('*[x\\:publishsource^="Excel"]').each(function(index, value){
				ffFixReportHeight += $(this).height();
			});
		}
		console.log(ffFixReportHeight + ' ' + ffFixIframeHeight);
		if (ffFixReportHeight + 160 <= ffFixIframeHeight )
		{
			$('#box-frame-footer').css('position','absolute').css('bottom', 0).css('width', '100%');
			$('html').css('position','relative').css('min-height','100%');
			$('body').css('height','100%');
		} else {
			$('#box-frame-footer').css('margin-top','20px'); //  69410
		}		
		$('#box-frame-footer').show();
		h = $( window ).height();
		w = $( window ).width();
	}
}

function autoHeightIE() {
	var myParent = this.top; 
	if (myParent !== this) {
		var myParentIframes = myParent.document.getElementById('iframe-doc');// 64364:
		var ffFixIframeHeight = $(myParentIframes).height(); 
		var ffFixReportHeight = $(document).height();
		if($('*[class^="WordSection"]').length){
			// 69769
			ffFixReportHeight = 0;
			$('*[class^="WordSection"]').each(function(index, value){
				ffFixReportHeight += $(this).height();
			});
		}

		if($('*[x\\:publishsource^="Excel"]').length){
			// 70912
			ffFixReportHeight = 0;
			$('*[x\\:publishsource^="Excel"]').each(function(index, value){
				ffFixReportHeight += $(this).height();
			});
		}

		if (ffFixReportHeight + 160 <= ffFixIframeHeight )
		{
			$('#box-frame-footer').css('position','absolute').css('bottom', 0).css('width', '100%');
			$('html').css('position','relative').css('min-height','100%');
			$('body').css('height','100%');
		} else {
			$('#box-frame-footer').css('margin-top','20px'); //  69410
		}		
		$('#box-frame-footer').show();		
		h = $( window ).height();
		w = $( window ).width();
	}
}

$(document).ready(function() {
	var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");
    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))  // If Internet Explorer
    {
		setTimeout(autoHeightIE, 150);
	} else {
		setTimeout(autoHeight, 150); //Task 64272
	}
	$(window).resize(function() {
		if (typeof isSVGZoomAction != undefined && isSVGZoomAction) {
			isSVGZoomAction = false; // 70248
			h = $( window ).height();
			w = $( window ).width();
			return 0;
		}
		if( h != $( window ).height() ||  w != $( window ).width()  ){
			//	location.reload(true);
			$(window).scroll(); // 72158
		}
	});

	$(window).scroll(function() {
		var left = $(window).scrollLeft();
		var width = $(window).width();
		$('#box-frame-footer').css("margin-left", left + 'px').css("width", width + 'px');
		$('#box-frame-objectversion-cover').css("margin-left", left + 'px').css("width", width + 'px');
	});	

});