var fr = {
	
	_cnt : this._cnt || 0,
	
	convert : function(_sel,_swf,_attr) {
		
		if (!fr.detectCSS()) { return false }
		
		$(_sel).flash(
			
			{ src: _swf, flashvars: {} },
			
			{ version: 8  },
			
			function(_h) {
				
				var _id = '_fr_' + fr._cnt 		// Unique ID for each replaced element
				var _re = /<\S[^>]*>/g;			// Strip HTML tags from text
				var _link = $(_sel+'>a')[0]		// Anchor in title
				
				$(this).wrapInner('<div class="alt"></div>')
				
				if (_link) {
					_h.flashvars.uri = _link.href
					//_h.flashvars.uri = _link.getAttribute('href',2)
					var _relative = _link.getAttribute('href',2)
					if (window.location.href.indexOf(_link.href) == 0 && _relative.length > 0 && _relative != '#') {
						_h.flashvars.active = true
					}
				}
				
				_h.flashvars.text   = this.innerHTML.replace(_re,"")
				_h.height = $(this).height()
				_h.width  = $(this).width()
				_h.allowScriptAccess = "always"
				_h.flashvars.width  = $(this).width()
				_h.flashvars.height = $(this).height()
				_h.flashvars.color  = $(this).css('color')
				_h.flashvars.id = _id
				if ($(this).hasClass('active')) {
					_h.flashvars.active = true
				}
				
				for (var i in _attr) {
					_h.flashvars[i] = _attr[i]
				}
				
				$(this).css('height' ,_h.height)
				$(this).attr({ id:_id })
				$(this).addClass('flash-replaced').prepend($.fn.flash.transform(_h));
				
				fr._cnt ++;
			}
		);
	},
	
	setHeight : function(_h,_ref) {
		$('#'+_ref).height(_h-3)
		$('#'+_ref+' embed').attr('height',_h-3)
	},
	
	detectCSS : function() {
		var _d = document.createElement('div')
		_d.id = 'css_test'
		$('body').append(_d)
		$('#css_test').css({width:'1px',height:'1px',display:'none'})
		var _v = ($('#css_test').width() != 1) ? false : true
		$('#css_test').remove()
		return _v
	},
	
	traceMe : function(str) {
		//console.log('from AS: '+str)
		//alert('from AS: '+str)
	},
	
	statusBar : function(str) {
		str = str || ''
		window.status = str
	}
}
