var FondoFX = function()
	{
	var self = this;
	this.directorio = '../images/';
	this.azarmagenes = ['burb.png', 'burb2.png', 'burb.png', 'burb4.png'];
	this.azar = this.azarmagenes[this.random(this.azarmagenes.length)];
	this.ruta = this.directorio + this.azar;
	this.elemento = document.createElement('img');
	this.nuevaVelocidad().newPoint().display().newPoint().fly();
	};

FondoFX.prototype.display = function()
	{
	//$(this.elemento).attr('src', this.ruta).css('position', 'absolute').css('z-index', this.random(20)).css('top', this.puntoY).css('left', this.puntoX);
        $(this.elemento).attr('src', this.ruta).css('position', 'absolute').css('top', this.puntoY).css('left', this.puntoX);
	$(document.body).append(this.elemento);
	return this;
	};

FondoFX.prototype.fly = function()
	{
	var self = this;
	$(this.elemento).animate({"top": this.puntoY,"left": this.puntoX,}, this.velocidad, 'linear', function()
		{
		self.nuevaVelocidad().newPoint().fly();
		});
	};

FondoFX.prototype.nuevaVelocidad = function()
	{
	this.velocidad = (this.random(10) + 5) * 1100;
	return this;
	};

FondoFX.prototype.newPoint = function()
	{
	this.puntoX = this.random(window.innerWidth - 100);
	//this.puntoY = this.random(350);
        this.puntoY = this.random(150);
	return this;
	};

FondoFX.prototype.random = function(max)
	{
	return Math.ceil(Math.random() * max) - 1;
	}

$(function()
	{
	// FondoFXs
	var totalFondoFXs = 20;
	var sparks = [];
	
	for (i = 0; i < totalFondoFXs; i++)
		{
		sparks[i] = new FondoFX();
		}
	});
