$(function() {

	$('.featured_block').each(function(i) {
		$(this).cycle({
			delay:   -2000 + (500 * (i+1)),
			timeout:  2000
		});
	});
	
	$('a.lightbox').lightBox(); // Lightbox	
	$("#mp3").jmp3(); // jMP3 player basics

		
	// Set all DIVs to hidden before the animation starts/page is loaded
	//$('#menu').css('display', 'none');
	//$('div#portfolio_menu ul').css('display', 'none');
	$('div#portfolio_image_details').css('display', 'none');
	$('div#folio_image_links').css('display', 'none');
	$('.home').css('display', 'none');
	
});

$(document).ready(function(){

	// This function triggers three loading sections in a row
	
	$('.home').fadeIn(1500);
	
	//$('#menu').show(1000, function() {
		// Load menu bar from the side
		//$('#portfolio_menu ul').slideDown(600, function() {
			$('#loading').hide();
			// Fade ind portfolio image	
			$('#portfolio_image_details').fadeIn(2000);
			$('#folio_image_links').fadeIn(2000);
		//});
	//});


	/* Portfolio image chips, to load new image */

	$('a.image_link').click(function() {
	
		var link = $(this).attr("href");

		// Fade out the current image
		$('#portfolio_image_details').fadeOut(1200, function() {

			// Show the loading button
			$('#loading').show();
			
			// Load new text in the background
			$("#portfolio_image_details").load(link + " #portfolio_image_details",  function() {
				$('#portfolio_image_details').fadeIn(1200);
				$('#loading').hide();			
			});
		});
		
		return false;
	});


	$('#portfolio_menu ul li.parent a').click(function() {
	
		/*
		var link = $(this).attr("href");
		$("#portfolio_menu ul").slideUp(400, function() { 
			alert('here');
			parent.location = link;
		});
		return false;*/
		
	});
	

	/* FOR CHILD LINKS IN THE PORTFOLIO */
	
	$('#portfolio_menu ul li.child a').click(function() {
		
		/*
		var link = $(this).attr("href");
		
		$("#portfolio_menu ul li.child a").removeClass("current");
		$(this).addClass("current");

		// Fade out image selection
		$('#folio_image_links').fadeOut(1200, function() {
			$("#folio_image_links").load(link + " #folio_image_links", { ajax: 1 },  function() {
				$('#folio_image_links').fadeIn(1200);
			});
		});
				
		// Fade out the current image
		$('#portfolio_image_details').fadeOut(1200, function() {

			// Show the loading button
			$('#loading').show();
			
			// Load new text in the background
			$("#portfolio_image_details").load(link + " #portfolio_image_details",  function() {
				$('#portfolio_image_details').fadeIn(1200);
				$('#loading').hide();			
			});
		});

		return false;		
		*/
		
	});

});

