/**
	Frédéric Saunier
	http://www.tekool.net/javascript/backtothehtml

	This program is part of a free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

**/

/*****************************************************************************
* BackToTheHtml Command
*///**************************************************************************
function BackToTheHtml(node)
{
	if(node == null)
		this.node = document; 
	else
		this.node = node; 
};
BackToTheHtml.prototype.node = null;

BackToTheHtml.prototype.execute = function()
{
	var aNoscript = document.getElementsByTagName('object');
	for(var i=0; i<aNoscript.length; i++)
		new ActivateObject(aNoscript[i]).execute();

	document.styleSheets[document.styleSheets.length-1].addRule("OBJECT","visibility:visible;");
}

/*****************************************************************************
* ActivateObject Command
*///**************************************************************************
function ActivateObject(domNoscript)
{
	this.domNoscript = domNoscript;
}
ActivateObject.prototype.domNoscript = null;

ActivateObject.prototype.execute = function()
{
	this.htmlContentReplace();
}

ActivateObject.prototype.htmlContentReplace = function()
{
	//That works only with Flash for now
	if(this.domNoscript.classid == 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000')
	{
		var domDiv = document.createElement('div');
		domDiv.style.display = 'none';
		domDiv.innerHTML = this.domNoscript.outerHTML;
		this.domNoscript.parentNode.insertBefore(domDiv,this.domNoscript);

		this.domNoscript.parentNode.replaceChild(domDiv.firstChild,domDiv);
		this.domNoscript.parentNode.removeChild(this.domNoscript);
	}
};

if(typeof document.onreadystatechange != 'undefined')
{
	document.write('<style type="text/css">OBJECT{visibility:hidden;}</style>');
	document.onreadystatechange = function()
	{
		if(document.readyState == 'complete')
			new BackToTheHtml().execute();
	}
}