﻿//Hides Header, Menu and Footer when inside a frame

function hideInFrame() {
   if (parent!=window) { //isInsideFrame
       document.write('<style>.Header { display:none; } .Menu_Container { display:none; } .Footer { display:none; }</style>');
   }
}

//Sets the frame height if inside an Enterprise Manager frame

function goSetHeight() {
 if(parent== window) return;
 if(parent==null) return;
 if(parent.setIframeHeight==null) return;
 parent.setIframeHeight('ifrm');
 if(parent.parent==null) return;
 var iframe = parent.parent.document.getElementById('cfgiframe');
 if (iframe!= null) {
  iframe.style.height= '0px';
  iframe.style.height = (getPageHeight(iframe.contentWindow) + 30) + 'px'
 }
};

if (window.addEventListener) {
 window.addEventListener('load',goSetHeight,false);
} else if (window.attachEvent) {
 window.attachEvent('onload',goSetHeight);
}

(function() {
  var OsRefreshElementOld = OsRefreshElement;
  OsRefreshElement = function(elem, newElemInner, newElemAttributes) {
   OsRefreshElementOld.apply(this, arguments);
 elem.queue(function () { 
  goSetHeight(); 
  elem.dequeue();
  });   
  };
})();

function getPageHeight(win){
    var yScroll;
    if (win.innerHeight && win.scrollMaxY) {    
        yScroll = win.innerHeight + win.scrollMaxY;
    } else if (win.document.body.parentNode.scrollHeight > win.document.body.offsetHeight){
        yScroll = win.document.body.parentNode.scrollHeight;
    } else {
        yScroll = win.document.body.offsetHeight;
    }
    var windowHeight;
    if (win.innerHeight) {
        windowHeight = win.innerHeight;
    } else if (win.document.documentElement && win.document.documentElement.clientHeight) {
        windowHeight = win.document.documentElement.clientHeight;
    } else if (win.document.body) {
        windowHeight = win.document.body.clientHeight;
    }    

    
    if(yScroll < windowHeight){
        return windowHeight;
    } else {
        return yScroll;
    }
}
