jQuery(function($) {
	$.footnoteLinks();
	
//	$('#menu').hide();
//	$('#menu>div').hide();
//	$('#content').hide();
//	
//	$('#nav-networks a').click(showNetworks);
//	$('#nav-contact a').click(showContact);
//	$('#nav-writing a').click(showWriting);
//
//	if( $('body.default').length > 0 ) {
//		$('#container').css("width","333px");
//		var queryhash = window.location.hash
//		switch (queryhash) {
//			case "#writing":
//				$('#nav-writing a').click();
//				break;
//			case "#contact":
//				$('#nav-contact a').click();
//				break;
//			default:
//				$('#nav-networks a').click();
//				break;
//		}
//	} else {
//		$('#nav-writing a').click();
//	}
	
	$('.section.main a.embed[href*=youtube.com]').each(function() {
		var $this = $(this);
		var par = $this.parent('p,li');
		if ( par.length == 1 ) {
			var cnt = par.contents();
			par.replaceWith(cnt);
		};
		$this.wrap('<div class="youtube"></div>').flash(
			{ height: 385, width: 480 },
			{ version: 8 },
			function(htmlOptions) {
				$this = $(this);
				htmlOptions.src = $this.attr('href').replace("watch?v=", "v/");
				$this.before($.fn.flash.transform(htmlOptions));						
			}
		).remove();
	});

});

function showNetworks() {
	hider();
	$(this).addClass("active");
	setTimeout("$('#networks').show(); $('#menu').slideDown('slow');", 1000);
}

function showContact() {
	hider();
	$(this).addClass("active");
	setTimeout("$('#contact').show(); $('#menu').slideDown('slow');", 1000);	
}

function showWriting() {
	hider();
	if( $('#content:visible').length == 0 ) {
		$('#container').animate({width: "900px"}, 1500);
		$('#content').fadeIn(1000);
	}
	$(this).addClass("active");
	setTimeout("$('#writing').show(); $('#menu').slideDown('slow');", 1000);
	// return false;
}

function hider() {
	if( $('#menu>div:visible').length > 0 ) {
		$('#menulinks a').removeClass();
		$("#menu").slideUp(500);
		$("#menu>div").fadeOut(500, function(){$("#menu>div").hide();});
	}
}