$(document).ready(function() {
	
	$('body').noisy({
				intensity: 1,
				size: 300,
				opacity: 0.1,
				fallback: 'images/fallback.png',
				monochrome: false
			}).css('background-color', '#edefef');
			
	$('#ilverbo').hide();
			
	$('#helicopter').animate({bottom: '-=610',left: '+=300'}, 2000, 'linear'); 
	
	$('#twitter_say').animate({bottom: '+=40',left: '+=30', opacity: 0.6}, 1500, 'easeInBack').hover(
		function(){
			$(this).animate({opacity: 1}, 300, 'linear');
			$('#ilverbo').show('bounce',300);
		},
		function(){
			$(this).animate({opacity: 0.6}, 300, 'linear');
			$('#ilverbo').fadeOut('fast');
		});
	
	$('#ilverboinner').jQTwitter({
	username: 'errikodotit',
	count: 1,
	show_image: false
	});
			
	$('#motto').hover(function(){
		$('#car').animate({right: '-=30'}, 600, 'linear');
	},
	
	function(){
		$('#car').animate({right: '+=30'}, 600, 'linear');
	});
	
	$('.contact textarea').focus(function(){
	
		$('.contact').find('input[type=submit]').fadeIn(500);
	
	});
	
	$(".contact").submit(function(event) {
	  
	  event.preventDefault();
      
     	/* Send the data using post and put the results in a div */
    	$.post('sendmail.php', $(this).serialize(), function(data) {
  			$('.result').html(data);
  			$('.contact').find('input[name=nome]').val('Nome');
  			$('.contact').find('input[name=email]').val('E-mail');
  			$('.contact').find('textarea').val('');
		});
    			
    });


var timer;

$(function() {
        timer = setTimeout(Cloud, 0);
});

function Cloud() {

				
        $("#clouds_uno").animate({left: '+='+$.randomBetween(10, 40)}, $.randomBetween(4000, 10000), "linear").
        		animate({left: '+='+$.randomBetween(10, 40)}, $.randomBetween(4000, 10000), "linear").
        		animate({left: '-='+$.randomBetween(10, 40)}, $.randomBetween(4000, 10000), "easeOutBack").delay($.randomBetween(4000, 10000)).
                animate({left: '-='+$.randomBetween(10, 40)}, $.randomBetween(4000, 10000), "linear", function() {
                        timer = setTimeout(Cloud, 0);
                });
        $("#clouds_due").delay($.randomBetween(2000, 5000)).animate({left: '+='+$.randomBetween(20, 40)}, $.randomBetween(4000, 10000), "easeInOutCubic").delay($.randomBetween(4000, 10000)).
                animate({left: '-='+$.randomBetween(20, 40)}, $.randomBetween(4000, 10000), "linear", function() {
                        timer = setTimeout(Cloud, 0);
                });
}
			
});
