Effect.HighlightText = Class.create(Effect.Base, 
{
	initialize: 	function(element) 
					{
					    this.element = $(element);
					    if (!this.element) 
					    	throw(Effect._elementDoesNotExistError);
					    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { });
					    this.start(options);
					},
					
  	setup: 			function() 
  					{
					    // Prevent executing on elements not in the layout flow
					    if (this.element.getStyle('display')=='none') 
					    { 
					    	this.cancel(); 
					    	return; 
					    }
					    this.oldStyle = { };
					    
					    if (!this.options.endcolor)
					      this.options.endcolor = this.element.getStyle('color').parseColor('#ffffff');
					      
					    if (!this.options.restorecolor)
					      this.options.restorecolor = this.element.getStyle('color');
					      
					    // init color calculations
					    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
					    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
					},
					
  	update: 		function(position) 
  					{
    					this.element.setStyle(
    					{
    						'color': $R(0,2).inject('#',function(m,v,i)
														{
															return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); 
														}.bind(this)
											) 
      					});
  					},
  					
  	finish: 		function() 
  					{
    					this.element.setStyle(
    						Object.extend
    						(
	    						this.oldStyle, 
	    						{
	      							color: this.options.restorecolor
	    						}
    						)
    					);
 					}
}
);
