function SwfText(){
     Object.extend(this,{ 		  
          text:null,
          version:8,
          width:null,
          height:null,
          cssWidth:null,
          cssHeight:null,
          cssNames:new Array(),
          options:{
               color:'#ffffff',
               firstColor:'#ffffff',
               lastColor:'#ffffff',
               linkColor:'#ffffff',
               bgColor:'#000000',
               fontSize:14
          },
          
          trimTags:function(str) {
               while(str.split("> <").length>1){
                    str=str.split("> <").join('><');
               }
               return str;
          },
          
          trimExtra:function(str)
          { 
               while(str.split("  ").length>1){
                    str=str.split("  ").join(' ');
               }
               return str;
          },
          
          removeClass:function(str)
          {
               this.cssNames.push(str);
          },
          
          reCase:function(str){
               var M= str.match(/(< *\w+)/g);
			   if (M==null) return str;
               var L= M.length;
               var temp='';
               for (var i=0; i<L;i++){
                    var tem= M[i].substring(1);
                    tem=tem.toLowerCase();
                    if(temp.search(tem+';')!=-1)continue;
                    var rx= new RegExp("(< *\/? *)"+tem,'gi');
                    temp+= tem+'; '
                    str= str.replace(rx,'$1'+tem);
               }
               str=str.replace(/> *</g,'><');
               return str;	
          },

          parseString:function(str) {
               str = this.reCase(str); //tags to lower
               //
               re= /<(?!\/?(span|a))[^>]*>/gi
               str= str.replace(re,""); //remove all except span|a
               str=str.split("\r").join(''); //remove breaklines
               str=str.split("\t").join('');
               str=str.split("\n").join('');
               //
               str=str.split("\"").join("'");
               //
               re= /class=''/gi
               str= str.replace(re,""); //remove class=''
               //
               str=str.split("&").join(escape("&"));
               //
               str = str.strip(); //remove white
               str = this.trimExtra(str); //remove extra white between chars
               str = this.trimTags(str); //remove extra white between tags
               return str;	
          },
          setCssSize:function(w, h){
			  
               this.cssWidth = w;
               this.cssHeight =h;
			   if(w==undefined) this.cssWidth = null;
			   if(h==undefined) this.cssHeight = null;
               
          },
          
          replaceElement: function(elm, swf, width, height, options){
               Object.extend(this.options, options || {});
               
               var so = new SWFObject(swf, elm+"_swftext", width, height, this.version, this.options.bgColor);
               if(!so.installedVer.versionIsValid(so.getAttribute('version'))){
                    //$(elm).innerHTML = this.text;
                    return;	
               }

               this.width= width;
               this.height= height;
               this.options.firstColor = this.options.linkColor;
               //clean css class
               var s = $(elm).innerHTML;
               this.text=s; //backup html
               var elementos = $(elm).descendants();
               var css_names = this.cssNames;
               elementos.each(function(elm){ //remover class
                         css_names.each(function(val){
                              $(elm).removeClassName(val);						
                         });
               });
               
               s = $(elm).innerHTML
               s = this.parseString(s);
               //so.addVariable("t", escape(s));
               so.addVariable("t", s);
               so.addVariable("c", this.options.color);
               so.addVariable("fc", this.options.firstColor);
               so.addVariable("lc", this.options.lastColor);
               so.addVariable("uc", this.options.linkColor);
               so.addVariable("f", this.options.fontSize);
			   if(this.options.wMode!=undefined){
				  so.addParam("wmode", "transparent");
			   }
               //so.addVariable("selector", 'span');
               so.addParam("scale", "noscale");
               so.write(elm);
               
               if(this.cssWidth!=null && this.cssHeight!=null){
                    $(elm+"_swftext").setStyle({
                         width: this.cssWidth,
                         height:  this.cssHeight
                    });
               }
          }
          
     });
     //
}