// Project page functionality
$(document).ready(function() {
	
	// Hiding all LI's on page load.
	$('#bigImage li').hide();
	// Except the first one - 
	$('#bigImage li:first').addClass('currentlyViewing').show();
	
	// Click a thumbnail to replace the big image with the corresponsing ID
	$('#projectThumbs a').click(function() {
		$('.currentlyViewing').hide();
		$('.currentlyViewing').removeClass("currentlyViewing");
		var tid = $(this).attr('href');
		$(tid).fadeIn("fast"); 
		$(tid).addClass("currentlyViewing"); 
		return false;
	});
	
	// Next Arrow
	$('.rightbutton').click(function() {
		var nextImage = $('.currentlyViewing').next('li').attr('id');
		// if this is the first slide
		if (nextImage == null) {
		   return false;
		}
		// otherwise get the next slide
		$('.currentlyViewing').hide();
		$('.currentlyViewing').removeClass("currentlyViewing");
		$('#'+nextImage).fadeIn("fast"); 
		$('#'+nextImage).addClass("currentlyViewing"); 
		return false;
	});
	
	// Prev Arrow
	$('.leftbutton').click(function() {
		var prevImage = $('.currentlyViewing').prev('li').attr('id');
		// if this is the first slide
		if (prevImage == null) {
		   return false;
		}
		// otherwise get the previous slide
		$('.currentlyViewing').hide();
		$('.currentlyViewing').removeClass("currentlyViewing");
		$('#'+prevImage).fadeIn("fast"); 
		$('#'+prevImage).addClass("currentlyViewing"); 
		return false;
	});
	
	// Temporary - remove this 
	/*
	$('.tempLight').click(function() {
		alert('This opens full image size with lightbox effect')
		return false;
	});
	*/
	
	// Lightbox effect 
		$(document).ready(function() {
			$(".tempLight").fancybox({ 'zoomSpeedIn': 700, 'zoomSpeedOut': 500, 'overlayShow': true, 'overlayOpacity': 0.7, 'easingIn': 'easeInSine', 'easingOut': 'easeOutCubic' });
			return false;
		});
		
});

