/**
 * ScoreText
 * @classDescription  
 * @dependence        Mootools (http://www.mootools.net)
 * @author            Aken.li (http://www.kxbd.com)
 * @created           2009-11-25
 */
var ScoreText = new Class({

	Implements: [Options,Events],
	
	options:{
		sign:'L',
		interval:30,
		score:1,
		opacity:1
	},
	
	initialize:function(pX, pY, pHolder, options){
		this.setOptions(options);
		this.x = pX+40;
		this.y = pY-20;
		this.scoreText = this.create();
		this.holder = $(pHolder);
		this.scoreText.inject(this.holder);

		this.init();
	},

	create:function(){
		return new Element('div',{
			'class':'scoreText',
			'text':'+'+this.options.score,
			'styles':{
				left:this.x,
				top:this.y
			}
		});
	},

	init:function(){
		this.fadeTimer = this.fadeOut.periodical(this.options.interval,this);
	},

	fadeOut:function(){
		this.options.opacity -= 0.05;
		this.scoreText.setStyle('opacity',this.options.opacity);
		if (this.options.opacity <= 0) {
			this.fadeTimer = $clear(this.fadeTimer);
			this.scoreText.destroy();
		}
	}
});