function contentFadeIn() {
	$('#content').animate(
				{
					opacity: 1,
					top: -50
				}, 1000, 
				function() {
				
					footer();
				}					
				);
}

function contentFadeOut() {
	$('#content').animate({
				opacity: 0,
				top: 20
				}, 1000, function() {
		});
}

function footerFadeIn() {
				$('#footer').animate({
					opacity: 1
					}, 500, function() {				
				});
}

function subMenuFadeIn(theSubMenu) {
	theSubMenu = "#" + theSubMenu;
	$(theSubMenu).css({'visibility':'visible'});
	$('#menu').animate({
				opacity: 0.5
			}, 200, function() {});	
		
		$(theSubMenu).show();
		
		var i = -1;
		var subMenuItems = $(theSubMenu+' li');
		var recursiveSubMenuAnimation = function() {
					if (++i < subMenuItems.length)
									$(subMenuItems[i]).stop().animate({ opacity: 1, top: 10 }, 150, recursiveSubMenuAnimation );
		}
		recursiveSubMenuAnimation();
}

function subMenuFadeOut() {
	$('.submenu li').stop().animate({ opacity: 0, top: 0 }, 150, function() { $('.submenu').hide(); } );
	
	$('#menu').animate({
				opacity: 1
			}, 200, function() { });	
		
}

function subMenuFadeTransition(theSubMenu) {
	//theSubMenu is the B part of the transitions from submenu A
	$('.submenu li').stop().animate({ opacity: 0, top: 0 }, 150, function() { $('.submenu').hide(); subMenuFadeIn(theSubMenu); } );
		
}


function footer(){
		//Positions footer according to window size and content height
		variable = $('#content').height() + 215;
		
		if($(window).height() < variable){
		
		$('#footer').css({'position':'relative'});
		
		}else{
			
			$('#footer').css({'bottom': '10px', 'position':'absolute'});
		}
		footerFadeIn();
}
