$(document).ready(function() {
	$("#bg").cycle({ 
		timeout: 0, 
		speed:   500,
		fx: 'fade'
	});
});

/* --- CLICK EVENTS --- */
$(document).ready(function() {
						   
	$("#portfolio-nav").click( function() {
				$("#bg").cycle(0); 
				return false;
	});
	
	$("#cv-nav").click( function() {
				$("#bg").cycle(2); 
				return false;
	});
	
	$("#about-nav").click( function() {
				$("#bg").cycle(1); 
				return false;
	});

});

/* --- AJAX --- */

	/* --- DEFAULT PAGE --- */
	$(document).ready(function () {
			getPage();
			return false;	
	});
	
	/* --- AJAX NAV --- */
	$(document).ready(function () {
	
		$.history.init(pageload);	
		
		$('a[rel=ajax]').click(function () {
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
			$.history.load(hash);	
			
			$('#content').hide();
			$('.loading').show();

			getPage();
			return false;
		});	
	});
	
	function pageload(hash) {
		if (hash) getPage();    
	}
		
	function getPage() {
		var data = 'page=' + encodeURIComponent(document.location.hash);
		$.ajax({
			url: "loader.php",	
			type: "GET",		
			data: data,		
			cache: false,
			success: function (html) {	
				$('.loading').hide();				
				$('#content').html(html);
				$('#content').show();
			}
		});
		
	}
	
/* --- END AJAX --- */





