Odx.FontReplacement = new Class({

	/**************************************
		Constructor
	**************************************/
	initialize: function(id, element, swfUrl, text)
	{
		this.$_id		= id;
		this.$_element	= $(element);
		this.$_url		= swfUrl;
		this.$_text		= text || element.innerHTML;
		
		return this.Replace();
	},
	
	/**************************************
		Public Properties
	**************************************/
	GetId: function()
	{
		return this.$_id;
	},
	
	GetElement: function()
	{
		return this.$_element;
	},
	
	GetUrl: function()
	{
		return this.$_url;
	},
	
	GetText: function()
	{
		return this.$_text;
	},
	
	SetText: function(text)
	{
		this.$_text = text;
		return this;
	},
	
	
	/**************************************
		Public Methods
	**************************************/
	Replace: function()
	{
		var
			e = this.GetElement(),
			size = e.getSize().scrollSize,
			w = size.x,
			h = size.y,
			text = escape(this.GetText().replace(/&amp;/, '&'));
		
		var flashObject = new SWFObject(this.GetUrl(), this.GetId(), w, h - 2, '7');
		
		flashObject.addParam('wmode', 'transparent');
		flashObject.addVariable('Text', text);
		flashObject.addVariable('Width', w);
		flashObject.addVariable('Height', h);
		flashObject.addVariable('FontColor', e.getStyle('color').substr(1,7));
		flashObject.write(e);
		
		return this;
	}
});

Odx.FontReplacement.ReplaceAll = function(id, query, url)
{
	var elements = $$(query);
	
	for (var i = 0, l = elements.length; i < l; i++)
	{
		new Odx.FontReplacement(id + i.toString(), elements[i], url);
	}
}