// MAKE FULLSCREEN ICON SMALLER WHEN APP IS FULLSCREEN
function changeFullscreenIcon() {
       const isFullscreen = window.innerWidth === screen.width && window.innerHeight === screen.height;
       const button = document.getElementById('fullscreen-tab'); 
       if (isFullscreen) {
           button.classList.remove('small');
       } else {
           button.classList.add('small');
       }
}

// SEND FULLSCREEN REQUEST TO PARENT WINDOW
$(document).ready(function () {
    $(document).on('click', "#fullscreen-tab", function () {
	parent.postMessage('fullscreen', '*');
	changeFullscreenIcon();
	})	
});

// DETECT IFRAME AND REMOVE FULLSCREEN BUTTON
$(window).on('load', function removeFullscreen () {
    const tab = document.getElementById('fullscreen-tab');
    if (tab != null) {
	if (window.self === window.top){
	    tab.style.visibility = "hidden";
	}
    } else {
	setTimeout(removeFullscreen, 5); 
    }
});

