﻿    
if(document.attachEvent)
    window.attachEvent("onload",  fitIFrame);  
else
    window.addEventListener('load',  fitIFrame,  false);  
 
      
function fitIFrame( ) 
{
    this.frameElement.style.height =parseInt( this.frameElement.contentWindow.document.body.scrollHeight)+ 50 + 'px';
    this.frameElement.style.width  = this.frameElement.contentWindow.document.body.scrollWidth + 'px';
    parent.window.scrollTo(0,0);
}

// not used anymore
function iframeAutoFit()
{
      try
      {
        if(window!=parent)
        {
          var nFrames = parent.document.getElementsByTagName("IFRAME");
            for(var i=0; i<nFrames.length; i++) //author:meizz
            {
              if(nFrames[i].contentWindow==window)
              {
                  var height = document.body.scrollHeight;
                  if(document.all) {height += 30;}
                  if(window.opera) {height += 1;}
                  nFrames[i].style.height = height;
              }
            }
        }
      }
      catch (ex)
      {
          alert( "" );
      }
 
} 