$(function(){
	
	$('#startpage').css({ opacity: 0 }) ;
	$('#startpage').fadeTo('slow', 1);
	$('.text_container').hide() ;

	
	$('.box').css({ opacity: 0 }) ;
	
	var delay = 100;
		$('.box').each(function(){
			var fade = $(this);
			showItem(fade,delay);
			delay += 200;	
		});
		
		
	$('.email').hover(
		function(){
			$(this).find('.email_normal').hide() ;
			$(this).find('.email_underline').show() ;
		},
		function(){
			$(this).find('.email_underline').hide() ;
			$(this).find('.email_normal').show() ;
		}
	) ;
	
	$('.box').hover(mouseEnter, mouseLeave) ;
	
	
	$(window).resize(function(){
		var browserHeight = $(this).height() ;
		var itemHeight = $('#centered').height() ;
		var space = Math.ceil((browserHeight-itemHeight));
		
		if (space > 17) {
			$('#centered').css('margin-top',space/2) ;
		}
		else {
			$('#centered').css('margin-top',17) ;
		}
		
	}
	) ;
	
	$(window).resize() ;
	
}) ;

function showItem($o,delay) { 
  setTimeout(function() {
     $o.fadeTo('slow', 1);
  }, delay); 
}

function mouseEnter() {	
	var one = $(this).find('.logo') ;
	var two = $(this).find('.text_container') ;
	

	$(two)
		.stop()
		.hide() ;
		
	$(one)
		.stop()
		.fadeTo(400,0.3) ;
			
				
	$(two)
		.css({ opacity: 0 })
		.css('filter', 'alpha(opacity=40)') //IE8 fix
		.show() 
		.fadeTo(300,1) ;	
			
	
}

function mouseLeave() {
	var one = $(this).find('.logo') ;
	var two = $(this).find('.text_container') ;
	
	$(two)
		.stop()
		.fadeTo(300,0)
		.hide() ;
		
	$(one)
		.stop()
		.fadeTo(500,1) ;
}
