/**
 * Star
 * @classDescription  
 * @dependence        Mootools (http://www.mootools.net)
 * @author            Aken.li (http://www.kxbd.com)
 * @created           2009-11-25
 */
var Star = new Class({

	Implements: [Options,Events],
	
	options:{
		sign:'$',
		distance: 100,
		interval:30,
		score:1,
		opacity:1,
		duration:20
	},
	
	initialize:function(pX, pY, pAngle, pHolder, options){
		this.setOptions(options);
		this.x = pX;
		this.y = pY;
		this.step = 0;
		this.distanceX = pX+ this.options.distance*Math.cos(pAngle);
		this.distanceY = pY+ this.options.distance*Math.sin(pAngle);

		this.star = this.create();
		this.holder = $(pHolder);
		this.star.inject(this.holder);

		this.init();
	},

	create:function(){
		return new Element('div',{
			'class':'star',
			'text':this.options.sign,
			'styles':{
				left:this.x,
				top:this.y
			}
		});
	},

	render:function(){
		this.star.setStyles({
			left:this.x,
			top:this.y
		});
	},

	init:function(){
		this.moveTimer = this.move.periodical(this.options.interval,this);
	},

	move:function(){
		this.step++;
		if (this.step < this.options.duration * 0.5) {
			this.x += (this.distanceX - this.x) * 0.3;
			this.y += (this.distanceY - this.y) * 0.3;
			this.render();
		}else {
			this.options.opacity -= 0.1;
			this.star.setStyle('opacity',this.options.opacity);
			if (this.options.opacity <= 0) {
				this.moveTimer = $clear(this.moveTimer);
				this.star.destroy();
			}
		}
	}
});