$(function() {
     			$("#aquarium").hover(function() {
					$("#appHover1").animate({opacity: "show", top: "150"}, "fast");
				}, function() {
					$("#appHover1").animate({opacity: "hide", top: "140"}, "fast");
				});
				
  				$("#sketchbooks").hover(function() {
					$("#appHover2").animate({opacity: "show", top: "150"}, "fast");
				}, function() {
					$("#appHover2").animate({opacity: "hide", top: "140"}, "fast");
				});
				
				$("#comingsoon").hover(function() {
					$("#appHover3").animate({opacity: "show", top: "150"}, "fast");
				}, function() {
					$("#appHover3").animate({opacity: "hide", top: "140"}, "fast");
				});
				
				$("#aquarium").click(function(event) {
					window.open("http://itunes.com/app/aquarium");
				});
				
				$("#sketchbooks").click(function(event) {
					window.open("http://artistsketchbooks.com");
				});
				
				$(".contactButton").click(function(event) {
					$(".contact").animate({height: "90%"}, "fast");
					$(".contactButton").animate({opacity: "hide"}, "fast");
				});
				
				$("#cancel").click(function(event) {
					$(".contact").animate({height: "42"}, "fast");
					$(".contactButton").animate({opacity: "show"}, "fast");
				});
				
				$("#contactForm").validate({
					submitHandler: function(form) {
						$(form).ajaxSubmit({ 
    						success: function() { 
       							$(".contactBox").animate({height: "0"}, "fast").delay(4000).animate({height: "100%"}, "fast");
       							
    						}
						});
					}
				});
				
				
				
			    var totalBubbles = 20;
			    var bubbles = [];
			    
			    for (i = 0; i < totalBubbles; i++){  
			      bubbles[i] = new Bubble();
			    }
				




			});
			
			
			
			var Bubble = function() {
			  var self = this;
			  this.b = 'images/';
			  this.s = ['smallbubble.png', 'mediumbubble.png', 'smallbubble.png', 'smallbubble.png'];
			  this.changeBubble();
			  this.n = document.createElement('img');  
			     
			  this.newSpeed().newPoint().display().float();
			};
			
			Bubble.prototype.display = function() {
				
			  $(this.n)
			   .attr('src', this.f)
			   .css('position', 'absolute')
			   .css('top', this.random(window.innerHeight) + window.innerHeight/2)
			   .css('left', this.pointX);
			                
			  $(document.body).append(this.n);
			  
			  return this;
			};
			
			
			Bubble.prototype.changeBubble = function() {
			  
			  this.i = this.s[this.random(this.s.length)];
			  this.f = this.b + this.i; 
			}
			
			Bubble.prototype.float = function() {
			  var self = this;
			  
			   $(this.n)
			   .attr('src', this.f)
			   .css('left', this.pointX)
			    .css('opacity', 1);
			  
			  $(this.n).animate({
			      "top": this.pointY,
			      "left": this.pointX,
			      "opacity": 0.3,
			  }, this.speed, 'linear', function(){
			  	
			    self.newSpeed().newPoint().changeBubble();
			    $(this)
			    .css('top', window.innerHeight);
			    self.float();  
			  });
			};
			
			Bubble.prototype.newSpeed = function() {
			  this.speed = (this.random(10) + 5) * 1100;
			  
			  return this;
			};
			
			Bubble.prototype.newPoint = function() {
			  this.pointX = this.random(window.innerWidth);
			  this.pointY = -40;
			        
			  return this;
			};
			
			Bubble.prototype.random = function(max) {
			  return Math.ceil(Math.random() * max) - 1;
			}

