$('document').ready(function() {

	
		
	// highlights lables	
	$("input").change(function() { 
	
		if ($(this).attr("checked") == true){
			$(this).parent().addClass("selected");  
		}else{   
			$(this).parent().removeClass("selected");
		}
	
	});


	// first animations
	/*
	var containerheight = 1500;
	var containerwidth = 960;
	$("#container").hide();
	$("#black_box").show();
    $("#black_box").animate( { width:containerwidth }, { queue:false, duration:500 } )
	  			   .animate( { top:"10px" }, 500 )
         		   .animate( { height:containerheight }, 500, "linear" );
	*/		
			
					 
	//  show content
	$(this).delay(0,function(){
		$("#black_box").hide();
		$("#container").show();
		$("#page_header").fadeIn(2000);
		$("#page_footer").fadeIn(2000);
		$("#content").fadeIn(2000);
		$(this).delay(2000,function(){


		
		
			// make email slide with browser
			var msie6 = $.browser == 'msie' && $.browser.version < 7;
			if (!msie6) {
				var top = $('#sidebar_content').offset().top - parseFloat($('#sidebar_content').css('margin-top').replace(/auto/, 0));
				$(window).scroll(function (event) {
				  // what the y position of the scroll is
				  var y = $(this).scrollTop();
				  
				  // whether that's below the form
				  if (y >= top) {
					// if so, ad the fixed class
					$('#sidebar_content').addClass('fixed');
				  } else {
					// otherwise remove it
					$('#sidebar_content').removeClass('fixed');
				  }
				});
			}
		
		

			// animate logo
			$("#logo").animate( { top:"20px" }, 500, "swing" );
			$(this).delay(500,function(){
			
				$("#tag_line").animate( { top:"-25px" }, 500, "swing" );
			
			});
			
			
			
		});
	});
	

	// animations
	$(this).delay(4000,function(){
		
		// 1st plant
		$("#bg1").fadeIn(18000);
		

		$(this).delay(12000,function(){
		
			// grass
			$("#bg2").fadeIn(10000);
			$("#bg2").animate( { top:"-20px" }, 5000 );
			$("#sidebar_plant").fadeIn(5000);
			
			
			$(this).delay(15000,function(){
				
				// tree branch
				$("#branch").fadeIn(10000);
				$(this).delay(11000,function(){
				
					// red bird & subset
					$("#bird").fadeIn(2000);
					$("#bg_sun").fadeIn(15000);
					$(this).delay(10000,function(){
					
						// cat comes up
						$("#cat").animate( { top:"71px" }, { queue:false, duration:10000 } )
							 .animate( { left:"100px" }, 10000 )
							 .animate( { left:"227px" }, 20000, "swing")
							 .animate( { top:"75px" }, 2000);
						$(this).delay(42000,function(){
								
							// cat get ready to pounce	
							$("#cat").animate( { top:"110px" }, { queue:false, duration:10000 } );
							$(this).delay(12000,function(){
								
								// cat jumps misses bird
								$("#cat_jump1").fadeIn(2000);
								$("#bird2").fadeIn(2000);
								$("#bird").fadeOut(1000);
								$(this).delay(1000,function(){
								
									// cat misses, feathers fall
									$("#cat_jump1").hide();
									$("#bird2").fadeOut(500);
									$("#cat_jump2").fadeIn(500);
									$("#feather").show(500);
									$("#feather").animate({ top:"177px" }, { queue:false, duration:5000 })
												.animate( { right:"50px" },{ queue:false, duration:5000 })
												.fadeOut(5000);

									$(this).delay(500,function(){
									
										// cat fade out
										$("#cat_jump2").fadeOut(1000);
										$(this).delay(12000,function(){
										
											/// go midcay
											$("#bg_sun").fadeOut(60000);
											$(this).delay(5000,function(){
											
												// bird comes back
												$("#bird").fadeIn(4000);
												$("#cat2").show();
												$("#cat2").animate( { top:"60px" }, { queue:false, duration:6000 } )
														 .animate( { left:"234px" }, 20000, "linear");
												
											});
										});
									});
								});
							});
						});
					});
				});	
			});
		});
	});
}); 