$(document).ready(function() {

	function nothing() {
		console.log('not much');
	}

	$(document).pngFix();

	$('ul#nav li.primary').hover(
		function() {
			$(this).addClass('active');
		},
		function() {
			$(this).removeClass('active');
		});

	$('ul#nav').superfish({
		animation: {opacity:'show',height:'show'}
		});
		
	$('ul#nav li a.pop').click(function() {
		window.open($(this).attr('href'),'pec17','resizable=1,width=600,height=400');
		return false;
	});

	$('ul#nav li').click(function() {
		if(exists($('> span a',this))) {
			if ($('> span a',this).is('.pop')) {
				window.open($('span a',this).attr('href'),'pec17','resizable=1,width=600,height=400');
			} else {
				window.location = $('span a',this).attr('href');
			}
		}
	});


		
		
		
		
		
		
		
	// Prompt Routines

	if (exists($('#alert'))) {

		// Elevate Prompt
		$('ul#nav li span.const').click(function() {
			$('#alert').ready(function() {
				// Elevate
				var ml = ($(document).width()/2)-($('#alert').width()/2);
				$('#alert').addClass('elevated').css('left',ml+'px');
				$('#alert').fadeIn('slow');
				// Mask Body
				mask();
			});

			// Show Prompt
			$('.induce_p').click(function() {
				// Mask Body
				mask();
				$('#alert').fadeIn('slow');
			});
		});

		// Excuse Prompt
		$('.excuse').click(function() {
			$('#alert').fadeOut('slow',reveal());
			return false;
		});

	}



	// Mask Functions

	function mask() {
		$('.mask').remove();
		var dh = $(document).height();
		var dw = $(document).width();
		$('<div class="mask"></div>').height(dh).width(dw).appendTo($('body')).fadeIn('slow');
	}

	function reveal() {
		$('.mask').fadeOut('slow');
	}



	// Misc Functions
	
	function exists(e) {
		return (e.width()!=null)? true: false;
	}

});