/*  Copyright 2008 Galen Wright-Watson

version: 1.0a
release: 20080801

*/

if (window.include) {
  window.include.register('/js/getComputedStyle.js');
}

function getCurrentStyle  (elt, pseudoElt) {
  if (elt.currentStyle) {
    return elt.currentStyle;
  }
  //elt.style is probably better than nothing
  return elt.style;
}
if (! document.defaultView) {
    //document.defaultView = {};
    document.defaultView = window;
}
if (! document.defaultView.getComputedStyle) {
    document.defaultView.getComputedStyle = getCurrentStyle;
}

if (! window.getComputedStyle) {
  // test on body won't always work, as this script may be loaded
  // before body tag.
  //if (document.body.currentStyle) {
    window.getComputedStyle = getCurrentStyle;
    alert('window.'+getCurrentStyle);
  //}
}

if (! document.getComputedStyle) {
  if (window.getComputedStyle) {
    /*for some reason, an exception is generated on Mozilla if 
      assign window.getComputerStyle to document.getComputedStyle; 
      hence, wrapper.
    */
    //document.getComputedStyle = window.getComputedStyle;
    document.getComputedStyle = function (elt, pseudoElt) {
      return window.getComputedStyle(elt, pseudoElt);
    }
  } else if (document.defaultView && document.defaultView.getComputedStyle) {
    document.getComputedStyle = function (elt, pseudoElt) {
      return document.defaultView.getComputedStyle(elt, pseudoElt);
    }
  } else {
    document.getComputedStyle = getCurrentStyle;
  }
}

