var Snow = {
	total: 13,
	_cache: {},
	_i: 0,
	init: function(){
		return false;
		this.body = $(document.body);
		var dim = document.viewport.getDimensions();
		this.height = dim['height'];
		this.width = dim['width'];
		this.addSnow(this._i, this.getInterval(this.width));
		this.secondPart = 0;
		new PeriodicalExecuter(function(){
			if(this.secondPart == 18){
				if(this._i < this.total){
					this._i++;
					this.addSnow(this._i, this.getInterval(this.width));
					this.secondPart = 0;
				}
			}
			for(var i=0; i < this.total; i++){
				if(this._cache[i]){
					if(this._cache[i]._left < -10 || this._cache[i]._left > this.width+10){
						this._cache[i]._left = this.getInterval(this.width);
						this._cache[i]._top = -35;
					}
					if(this._cache[i]._top > this.height+45){
						this._cache[i]._left = this.getInterval(this.width);
						this._cache[i]._top = -35;
					}
					var _left = Math.ceil(Math.random()*5);
					if(Math.ceil(Math.random()*20) < 10){
						_left = -_left;
					}
					var _top = Math.ceil(Math.random()*5);
					this._cache[i]._left +=_left;
					this._cache[i]._top +=_top;
					this._cache[i].setStyle({'left': this._cache[i]._left+"px", 'top': this._cache[i]._top+"px"});
				}
			}

			this.secondPart++;
		}.bind(this), 0.5);
	},
	getInterval: function(width){
		return Math.ceil(Math.random()*width);
	},
	addSnow: function(i, start){
		this._cache[i] = new Element('div');
		this._cache[i]._left = start;
		this._cache[i]._top = -35;
		this._cache[i].setStyle({
				'width': '28px',
				'height': '25px',
				'position': 'absolute',
				'left': this._cache[i]._left+'px',
				'top': this._cache[i]._top+'px',
				'zIndex': '1000',
				'background': 'url(http://public.kh.ua/images/snow.png) no-repeat left top'
		});
		this.body.insert(this._cache[i]);
	}
};
Main.onReady(Snow.init, Snow);