$(document).ready(function() {
  $("body").css('display', 'none');	
});

$(window).bind("load", function() {
	$('html').waitForImages(function() {
	    $("body").fadeIn();
			setTimeout(function() {
		    $('#wrap').stop().animate({ height:'100%', top:20 }, 750);
				$('.hide').fadeIn();
		  }, 1250, 'linear');
	});	
});


var SCREEN_WIDTH  = window.innerWidth;
var SCREEN_HEIGHT = window.innerHeight;
var QUANTITY = 60;
var MAX_DIAMETER = 50;
var COLORS = ['#81b1ac','#81b1ac','#81b1ac','#81b1ac','#81b1ac','#81b1ac'];
var P = Raphael("holder", SCREEN_WIDTH, SCREEN_HEIGHT);

var R = {};
R.fills = ["#41dfd0","#e8d668","#a9d679","#c1b48a","#e9e4d5",'#fff','#b1e545','#036f65','#fbc10a','#574e2f','#2a8497'];
R.strokes = ["#49827d","#e8d668","#a9d679","#c1b48a","#e9e4d5","#fff","#b1e545",'#036f65','#fbc10a','#574e2f','#2a8497','#574e2f','#2a8497'];
R.strokeWidths = 200;
R.strokeOpacities = [];



function animRaphael()
{
  P.clear();
  for (var i = 0; i < QUANTITY; i++)
  {
		P.circle(getX(), getY(), getWH()).attr("fill", R.fills[Math.floor(Math.random()*R.fills.length)]).attr("stroke", "#fff")
     .animate({
       fill: R.fills[Math.floor(Math.random()*R.fills.length)],
       stroke: R.strokes[Math.floor(Math.random()*R.strokes.length)],
			 cy: Math.floor(Math.random()) - 200,
			 x: Math.floor(Math.random()*(getX())),
			 y: Math.floor(Math.random()*(getY())),
			 easing: "linear",
			 r: Math.floor(Math.random()*10),
       "stroke-width": Math.floor(Math.random()*R.strokeWidths),
       "stroke-opacity": 0.3
     }, 8000);
  }
}


function getX()
{
  return (Math.floor(Math.random() * (2*SCREEN_WIDTH)) - (SCREEN_WIDTH/2));
}
function getY()
{
  return Math.floor(Math.random() * (2*SCREEN_HEIGHT)) - (SCREEN_HEIGHT/2);
}


function getWH()
{
  return Math.floor(Math.random() * MAX_DIAMETER);
}


var timerRaphael = setInterval(animRaphael, 8000);
setTimeout(function() {
  animRaphael();
}, 4250);

