function Wave(){var o,p;function B(){if(o<6||p<6){var b=Math.random()*j,i=Math.random()*10-5;(b=c[Math.round(b/j*c.length)])&&(b.force.y+=i)}}function C(){var b=f.createLinearGradient(0,0,0,250);b.addColorStop(0,"#D2DCE6");b.addColorStop(1,"rgba(255,255,255,0)");f.clearRect(0,0,j,l);f.fillStyle=b;f.beginPath();f.moveTo(c[0].x,c[0].y);var b=c.length,i,a,d,e;for(i=0;i<b;i++)if(a=c[i],d=c[i-1],e=c[i+1],d&&e){var g=0;g+=-t*(d.y-a.y);g+=t*(a.y-e.y);g+=t/15*(a.y-a.original.y);a.velocity.y+=-(g/a.mass)+
a.force.y;a.velocity.y/=w;a.force.y/=w;a.y+=a.velocity.y;e=q(k,a);e<r&&(e=q(k,{x:a.original.x,y:a.original.y}),o*=0.98,p*=0.98,a.force.y+=x*(1-e/r)*p);f.quadraticCurveTo(d.x,d.y,d.x+(a.x-d.x)/2,d.y+(a.y-d.y)/2)}f.lineTo(c[c.length-1].x,c[c.length-1].y);f.lineTo(j,0);f.lineTo(0,0);f.lineTo(c[0].x,c[0].y);f.fill();b=h.length;f.beginPath();for(i=0;i<b;i++){d=a=h[i];e=0;for(var g=1E3,n=c.length,s=0;s<n;s++){var m=q(c[s],d);m<g&&(g=m,e=s)}d=c[e];e=q(k,a);a.velocity.y/=a.y>d.y-a.currentSize?D:E;a.velocity.y+=
d.y>a.y-a.currentSize?1/a.mass:-((a.y-d.y-a.currentSize)*0.01)/a.mass;a.y+=a.velocity.y;a.y<d.y+a.currentSize&&u(i);if(a.x>j-a.currentSize)a.velocity.x=-a.velocity.x;if(a.x<a.currentSize)a.velocity.x=Math.abs(a.velocity.x);a.velocity.x/=1.04;a.velocity.x=a.velocity.x<0?Math.min(a.velocity.x,-0.8/a.mass):Math.max(a.velocity.x,0.8/a.mass);a.x+=a.velocity.x;e<r&&(a.velocity.x+=x*(r-e)/r*a.mass*o);if(a.dissolved==false)f.moveTo(a.x,a.y),f.arc(a.x,a.y,a.currentSize,0,Math.PI*2,false);else{a.velocity.x/=
1.15;for(a.velocity.y/=1.05;a.children.length<a.dissolveSize;)a.children.push({x:0,y:0,size:Math.random()*a.dissolveSize,velocity:{x:Math.random()*20-10,y:-(Math.random()*10)}});for(d=0;d<a.children.length;d++)e=a.children[d],e.x+=e.velocity.x,e.y+=e.velocity.y,e.velocity.x/=1.1,e.velocity.y+=0.4,e.size/=1.1,f.moveTo(a.x+e.x,a.y+e.y),f.arc(a.x+e.x,a.y+e.y,e.size,0,Math.PI*2,false)}}b=f.createLinearGradient(0,0,0,l);b.addColorStop(0,"#dfe9f4");b.addColorStop(1,"rgba(255,255,255,0.5)");f.fillStyle=
b;f.fill()}function m(){if(h.length>F){var b=0;if(h[b].dissolved)for(;b<h.length;b++){if(h[b].dissolved==false){h[b].dissolveSize=G;u(b);break}}else u(b)}b=8+Math.random()*7;b={x:15+Math.random()*(j-15),y:l-15,velocity:{x:Math.random()*0-0,y:0},size:b,mass:b/15+1,dissolved:false,dissolveSize:H,children:[]};b.currentSize=b.size;h.push(b);clearTimeout(v);y=Math.floor(Math.random()*4E3+1);v=setTimeout(m,y)}function u(b){var c=h[b];if(c.dissolved==false)c.dissolved=true,setTimeout(function(){for(var a=
0;a<h.length;a++)if(h[a]==c){h.splice(a,1);break}},2E3)}function z(b){o=Math.max(Math.min(b.layerX-k.x,40),-40);p=Math.max(Math.min(b.layerY-k.y,40),-40);k.x=b.layerX;k.y=b.layerY}function I(){for(var b=h.length,c=1E3,a=0;a<b;a++){var d=q(h[a],k);d<c&&(c=d)}}function J(){}function A(){j=window.innerWidth;g.width=j;g.height=l;for(var b=0;b<n+1;b++)c[b].x=j/(n-4)*(b-2),c[b].y=K,c[b].original.x=c[b].x,c[b].original.y=c[b].y}function q(b,c){var a=c.x-b.x,d=c.y-b.y;return Math.sqrt(a*a+d*d)}var j=window.innerWidth,
l=500,t=0.75,w=1.14,x=0.04,r=200,n=Math.round(j/80),D=1.2,E=1.02,K=140,F=10,H=8,G=6;o=0;p=0;var k={x:0,y:0},g,f,c,h,v,y;this.Initialize=function(b){if((g=document.getElementById(b))&&g.getContext){f=g.getContext("2d");c=[];h=[];$("body").append('<div id="tweet"></div>');for(b=0;b<n+1;b++)c.push({x:j/(n-4)*(b-2),y:l*0.5,original:{x:0,y:l*0.5},velocity:{x:0,y:Math.random()*3},force:{x:0,y:0},mass:10});$(g,"#header").mousemove(z);$("#header").mousemove(z);$(g).mousedown(I);$(g).mouseup(J);$(window).resize(A);
setInterval(C,40);v=setTimeout(m,Math.floor(Math.random()*2E3+1));setInterval(B,2E3);m();A()}}}var wave=new Wave;wave.Initialize("animacao_agua");
