$(document).ready(function() {
	menuAnimation();
	topmenuAnimation();
	
	$(window).resize(function()
	{
		setBackground();
	});			
	setBackground();
	

});

/* Set background properties */
function setBackground()
	{
	// get BROWSER Height / width
		var browserwidth = $(window).width();
		var browserheight = $(window).height();	

	// set Height on #content (subtract 30px for top menu)
		$("#content").css({ 'min-height' : browserheight-30});

	// get new content height
		var contentHeight = $("#content").height();

		$("#wrapper").css({ 'height' : browserheight});	
		$("#bgwrapper").css({ 'height' : browserheight});

	
		$("#container").css({ 'height' : browserheight});	

		$("#blogright").css({ 'height' : contentHeight-100 });	
		$(".blogtransparent .transparency").css({ 'height' : contentHeight });	

	}

function topmenuAnimation() {
	
	$("ul#tmenu li").each(function() {
		
		$linkText = $(this).html();
		$linkTextClass = $($linkText).addClass("white");	
		$linkTextWidth = $(this).width();

		$(this).append($linkTextClass);

		$("<span></span>")
		     .css('width',$linkTextWidth+"px")
		     .appendTo(this);	
	
		$('.white').css({ opacity: 0});

		
	});
	
	$("ul#tmenu li a,ul#tmenu li span, ul#tmenu li .white").hover(function() {

		$(this).parents("li").children("span").stop().animate({ height: "20px" }, 400);
		
		$(this).parents("li").children("a.white").stop().animate({ opacity: 1 }, 100);
		
  		setTimeout ("$(this).parents('li').children('a').css('opacity','0');", 400);
		
		
	}, function() {
		
		$(this).parents("li").children("span").stop().animate({ height: 0 }, 200);
		$(this).parents("li").children("a.white").stop().animate({ opacity: 0 }, 100);

		setTimeout ("$(this).parents('li').children('a').css('opacity','1');", 400);

	});
	
}


function menuAnimation() 
{
	$("ul#leftmenu li").each(function() {
		
		$linkText = $(this).html();
		$linkTextClass = $($linkText).addClass("white");		

		$(this).append($linkTextClass);
		
		$(this).append("<span></span>");
		
		$('.white').css({ opacity: 0 });
		
	});
	
	$("ul#leftmenu li a,ul#leftmenu li span, ul#leftmenu li .white").hover(function() {
		
		$(this).parents("li").children("a").stop().animate({ opacity: 0 }, 100);
		$(this).parents("li").children("a.white").stop().animate({ opacity: 1 }, 200);
		$(this).parents("li").children("span").stop().animate({ left: 0 }, 400);
		
	}, function() {
		$(this).parents("li").children("a.white").stop().animate({ opacity: 0 }, 100);
		$(this).parents("li").children("a").stop().animate({ opacity: 1 }, 200);
		$(this).parents("li").children("span").stop().animate({ left: "190px" }, 400);
		
	});
	
}

