$(document).ready(function(){

// ---------- BACKGROUND ---------- //
/*
	$(function(){
		$.fn.supersized.options = { 
			slideshow: 1,
			transition_speed: 2000,
			slide_interval: 8000
		};
		$('#background').supersized(); 
	});
*/
// ---------- HEADER ---------- //

	// intro
	$('#header_logo').animate({opacity:1}, 1000).animate({opacity:0}, 2000);
	$('#header_photo').animate({opacity:1}, 1000).animate({opacity:0}, 2000);

	// interactive
	$('#header_logo').hover(
		function() { $(this).stop().animate({opacity:1}, 200); },
		function() { $(this).stop().animate({opacity:0}, 800); });
	$('#header_photo').hover(
		function() { $(this).stop().animate({opacity:1}, 200); },
		function() { $(this).stop().animate({opacity:0}, 800); });
	
// ---------- PAGE NAVIGATION ---------- //
/*
	// change the page content
	function showPage($id) {
		$('#main_container').gx({'left': 980}, 800, 'Quad', function() {
			var newContentURL = $id + '.php';
			//var newContentURL = '/' + $id + '.php';
			$.get(newContentURL, function(data) {
				$('#main_container .page').replaceWith(data);
				$('#main_container').gx({'left': 0}, 800, 'Quad');
				activateNav('#main_content');
				//activateContent($id);
				//pageTracker._trackPageview(newContentURL); // call to Google Analytics
			});
		});
	}
	// update the nav bar
	function updateNav($id) {
		var $nav = $('#main_nav').find('a[href$="' + $id + '"]').get(0); // go find the navigation link that has this target
		selectNav.call($nav);
	}
	// handle nav selection
	function selectNav() {
		$(this)
			.parents('ul:first')
				.find('a')
					.removeClass('nav_active')
				.end()
			.end()
			.addClass('nav_active');
	}
	
	// hit it!
	function trigger($id) {
		var $id = $id.split('?')[1];
		showPage($id); 
		updateNav($id); 
	}
	// activate nav elements
	function activateNav($nav_element) {
		$($nav_element + ' a[href*=?]').click(function() {
			var $link = $(this).attr('href');
			trigger($link);
		    return false;
		});
	}
	// check if specific nav is being requested and update the nav (content is done by PHP)
	if (window.location.search) {
		var $id = window.location.search.split('?')[1];
		updateNav($id); 
	} else {
		var $id = "home";
		updateNav($id); 
	}
	// for navigation elements
	activateNav('#main_nav');
	activateNav('#bottom_nav');
	// for content embedded navigation
	activateNav('#main_content');
	//activateContent();

// ---------- FANCYBOX ACTIVATION ---------- //

	// overlays the requested image/ajax content (uses jQuery.fancybox plugin)
	$('#portfolio_content a.fancybox_call').fancybox({
		zoomOpacity : false,
		zoomSpeedIn: 0, 
		zoomSpeedOut: 0,
		zoomSpeedChange: 100, 
		overlayShow: true,
		overlayOpacity: .85,
		centerOnScroll: false, // better for small screens...
		hideOnContentClick: true
	});
*/
});
