﻿
// When the page loads:
window.onload = function(){
    var strBrowser = navigator.userAgent.toLowerCase();
    if (strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0) 
    {
        var theObjects = document.getElementsByTagName('object');
        var theObjectsLen = theObjects.length;
        for (var i = 0; i < theObjectsLen; i++) 
        {
            if (theObjects[i].outerHTML) 
            {
                // does the object use the 'data' attribute?
                // if so msie completely ignores any <param> in the outerHTML
                // so lets ditch it, as msie doesn't use it, only mozilla etc
                if (theObjects[i].data) 
                {
                    theObjects[i].removeAttribute('data');
                }
                theObjects[i].outerHTML = theObjects[i].outerHTML;
            }
        }
    }
}

// When the page unloads:
window.onunload = function() {
  if (document.getElementsByTagName) {
    //Get all the tags of type object in the page.
    var objs = document.getElementsByTagName("object");
    for (i=0; i<objs.length; i++) {
      // Clear out the HTML content of each object tag
      // to prevent an IE memory leak issue.
      objs[i].outerHTML = "";
    }
  }
}
