$(function(){
	
	$('<span class="nav_alt_text" />').insertBefore('ul.topnav li > span a:not(.active)');
	$(".topnav > li").each(function() {
		var linkText = $(this).find("a").html(); 
		$(this).find("span.nav_alt_text").show().html(linkText); 
	}); 

	$(".topnav > li").hover(function() {	//On hover...
		$(this).find("span.nav_alt_text").stop().animate({
			marginTop: "-40" 
		}, 200, "easeOutCirc");
	} , function() { 
		$(this).find("span.nav_alt_text").stop().animate({
			marginTop: "0"  
		}, 700, "easeOutBounce");
	});
	
	$('.topnav li').hover(function () {
		$('ul', this).slideDown(150, 'easeOutCirc');
	}, function () {
		$('ul', this).slideUp(100);
	});

	swfobject.embedSWF("/assets/flash/header.swf", "header_flash", "100", "150", "8.0.0", "/assets/flash/expressInstall.swf", {}, {
		wmode : 'transparent'
	});
	
});

$(window).load(function() {
	if ($('#work_slider').length > 0)
	{
		$('#work_slider').cycle({
			timeout : 4000,
			speed   : 500,
			pager   : '#work_slider_nav'
		});
	}

	if ($('#twitter_cycle').length > 0)
	{
		$('#twitter_cycle').cycle({
			timeout : 8000,
			speed   : 500
		});
		
		// VERTICALLY ALIGN FUNCTION
		$.fn.vAlign = function() {
			return this.each(function(i){
				var ah = $(this).height();
				var ph = $(this).parent().height();
				var mh = (ph - ah) / 2;
				$(this).css('margin-top', mh);
			});
		};
		
		$('#twitter_cycle span').vAlign();
	}
})
