<?xml version="1.0"?>

<!-- http://www.squarefree.com/userstyles/xbl.html -->

<bindings
   xmlns="http://www.mozilla.org/xbl"
   xmlns:html="http://www.w3.org/1999/xhtml"
>

<binding id="ctv">
  <implementation>
    <constructor>
      <![CDATA[


var doomed = this;

// Check parent too (case of working EMBED inside broken OBJECT)
if (doomed.overrideCTV || doomed.parentNode.overrideCTV)
  return;
doomed.overrideCTV = true;

var placeholder = document.createElement("div");


// === Styling ===

var w = parseInt(doomed.width || doomed.style.width);
var h = parseInt(doomed.height || doomed.style.height);

if (!w || w < 32) w = 32; // !w catches e.g. NaN
if (!h || h < 32) h = 32;

placeholder.style.width = w + "px";
placeholder.style.height = h + "px";
placeholder.style.backgroundColor = "yellow";
placeholder.style.MozOutline = "1px solid red";
placeholder.style.textAlign = "center";
placeholder.style.color = "black";
placeholder.style.background = "white";
placeholder.style.cursor = "pointer";
placeholder.style.overflow = "hidden";

var red = document.createElement("span");
red.style.fontWeight = "bold";
red.style.fontStyle = "italic";
red.style.color = "red";
red.appendChild(document.createTextNode("flash"))

var text = document.createTextNode(" [[Click to play]]");

placeholder.appendChild(red);
placeholder.appendChild(text);

placeholder.onmouseover = function()
{
  this.style.MozOutline='3px outset white';
  this.style.background='lightgrey'        
}
placeholder.onmouseout = function()
{
  this.style.background='white';
  this.style.MozOutline='1px solid red';
}


// === Replacement ===

var p = doomed.parentNode;

// Do in a timeout to avoid bugginess
setTimeout ( function () 
{
  p.insertBefore(placeholder, doomed);
  p.removeChild(doomed); 
}, 0);

// I love closures
placeholder.onclick = function() 
{
  p.insertBefore(doomed, placeholder);
  p.removeChild(placeholder);
}



      ]]>
    </constructor>
  </implementation>
</binding>

</bindings>