$(function() {
	go();

});


// Set up navigation and transitions.
function go() {
	//alert(s.cur());	
	
	// 
	// Set up the logo hover.
	//
	
	$('#logo-hover').css({ 'display': 'block', 'opacity': 0 });
	
	$('#logo a').hover(function() {
		
		$('#logo_hover').stop().animate({
			'opacity': 1
		},  n.anim.logo.on.time(), n.anim.logo.on.easing);
		
	}, function() {
		$('#logo_hover').stop().animate({
			'opacity': 0
		},  n.anim.logo.off.time(), n.anim.logo.off.easing);

	});
	
	// 
	// Set up the navigation clicks and hovers.
	//
	
	$('#navigation')
		.find('.hover')
			.css('opacity', 0)
			.css('display', 'block')
		.end()
		.find('a')
			//
			// Hover in
			//
			.hover(function() {
				var selectedId = $(this).parent()[0].id.substring(2);

				if (s.cur() == selectedId || s.sub.list[selectedId]) return;

				$('#h-' + selectedId).stop().animate({
					'opacity': 1
				},  n.anim.nav.on.time(), n.anim.nav.on.easing);
				
				
			//
			// Hover out
			//
			}, function() {
				var selectedId = $(this).parent()[0].id.substring(2);
		//		var curInfo = n.blips[$('body')[0].className];
				
				if (s.cur() == selectedId || s.sub.list[selectedId]) return;
				
				$('#h-' + selectedId).stop().animate({
					'opacity': 0
				},  n.anim.nav.off.time(), n.anim.nav.off.easing);

			})
			
			//
			// Mousedown
			//
			.mousedown(function() {
				var selectedId = $(this).parent()[0].id.substring(2);

				if (s.cur() == selectedId || s.sub.list[selectedId]) return;

				$('#h-' + selectedId).stop().css('opacity', 0.2);
			})
			
			//
			// Mouseup
			//
			.mouseup(function() {
				var selectedId = $(this).parent()[0].id.substring(2);
				
				// If it's the current or [not sure what that was supposed to be]
				if (s.cur() == selectedId || s.sub.list[selectedId]) return;

				$('#h-' + selectedId).stop().animate({
					'opacity': 0.4
				},  n.anim.nav.off.time(), n.anim.nav.off.easing);
			})
			
			// 
			// Click
			//
			.click(function(e) {

				// todo: shift animations
				// if (this.shiftKey) 
				// info.shift = n.shift;
				
				var newSection = $(this).parent()[0].id.substring(2);
				
				try {
					var selectedId = $(this).parent()[0].id.substring(2);
				
					$('#h-' + selectedId).stop().css('opacity', 0.0);
				
					s.sswitch(newSection);
				} catch(e) {
					//alert(e);
				}

				return false;
			});
}

