/**
 * Snow
 * @classDescription  
 * @dependence        Mootools (http://www.mootools.net)
 * @author            Aken.li (http://www.kxbd.com)
 * @created           2009-11-25
 */
var Snow = new Class({

	Implements: [Options,Events],
	
	options:{
		sign:'*',
		interval:30,
		speedX:0,
		rangeX:1+2 * Math.random(),
		speedY: 1.5+Math.random(),
		scale: parseInt(10 + Math.random() * 10)
	},
	
	initialize:function(pX, pY, pHolder, options){
		this.setOptions(options);
		this.x = pX;
		this.y = pY;
		this.snow = this.create();
		this.holder = $(pHolder);
		this.snow.inject(this.holder);

		this.init();
	},

	create:function(){
		return new Element('div', {
			'class': 'snow',
			'text': this.options.sign,
			'styles': {
				'left':this.x,
				'top':this.y,
				'font-size': this.options.scale+'px'
			}
		});
	},

	init:function(){
		this.moveTimer = this.move.periodical(this.options.interval,this);
	},

	render:function(){
		this.snow.setStyles({
			left:this.x,
			top:this.y
		});
	},

	move:function(){
		this.y += this.options.speedY;
		this.x += Math.sin(this.options.speedX++*0.1)*this.options.rangeX;
		this.render();
		if (this.y > 550) {
			this.remove();
		}
	},

	remove:function(){
		this.fireEvent('snowRemove',this);
		this.moveTimer = $clear(this.moveTimer);
		this.snow.destroy();
	}
});

