// monkey patch for jstools lightbox bug rendering flash in firefox/camino mac
// include after jstools
// requires /cbbc/images/lightbox/opacity60.png

new function()
{
	if ( navigator.platform.indexOf("Mac") != -1
			&& ( navigator.userAgent.indexOf("Firefox") != -1 || navigator.vendor.indexOf("Camino") != -1 )
			&& bbcjs && bbcjs.ui && bbcjs.ui.LightBox )
	{
		// hide flash behind lb
		bbcjs.ui.LightBox.prototype.overriddenOpen = bbcjs.ui.LightBox.prototype.open;
		bbcjs.ui.LightBox.prototype.open = function()
		{
			var embeds = document.getElementsByTagName("embed");
			for ( var i in embeds )
			{
				embeds[i]._realWidth = embeds[i].width;
				embeds[i]._realHeight = embeds[i].height;
				embeds[i].width = embeds[i].height = 1;
			}
			return this.overriddenOpen();
		}
		// reshow flash flash
		bbcjs.ui.LightBox.prototype.overriddenClose = bbcjs.ui.LightBox.prototype.close;
		bbcjs.ui.LightBox.prototype.close = function()
		{
			var ret = this.overriddenClose();
			var embeds = document.getElementsByTagName("embed");
			for ( var i in embeds )
			{
				embeds[i].width = embeds[i]._realWidth;
				embeds[i].height = embeds[i]._realHeight;
			}
			return ret;
		}
		// replace mask opacity with translucent png
		bbcjs.ui.LightBox.prototype.overriddenDrawMask = bbcjs.ui.LightBox.prototype.drawMask;
		bbcjs.ui.LightBox.prototype.drawMask = function()
		{
			this.overriddenDrawMask();
			bbcjs.dom.setStyle( this.elemMask, {
				backgroundColor: "transparent",
				backgroundImage: "url(/cbbc/images/lightbox/opacity60.png)",
				opacity: 1.0
			});
		}
		
		
	}
}();