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

FondoFX.prototype.display = function()
	{
	$(this.elemento).attr('src', this.ruta).css('position', 'absolute').css('z-index', this.random(-2)).css('top', this.puntoY).css('left', this.puntoX);
	$(document.body).append(this.elemento);
	$(this.elemento2).attr('src', this.ruta).css('position', 'absolute').css('z-index', this.random(-2)).css('top', this.puntoY2).css('left', this.puntoX2);
	$(document.body).append(this.elemento2);
	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 = 100000//(this.random(10) + 5) * 1100;
	return this;
	};

FondoFX.prototype.newPoint = function()
	{
	this.puntoX = this.random(-window.innerWidth);
	this.puntoY = this.random(80);
	return this;
	};

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


FondoFX.prototype.fly2 = function()
	{
	var self = this;
	$(this.elemento2).animate({"top": this.puntoY2,"left": this.puntoX2,}, this.velocidad2, 'linear', function()
		{
		self.nuevaVelocidad2().newPoint2().fly2();
		});
	};

FondoFX.prototype.nuevaVelocidad2 = function()
	{
	this.velocidad2 = 100000//(this.random(10) + 5) * 1100;
	return this;
	};

FondoFX.prototype.newPoint2 = function()
	{
	this.puntoX2 = this.random(window.innerWidth -5);
	this.puntoY2 = this.random(30);
	return this;
	};

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

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