function clickShowProj( clickedA )
{
	switchProjectImage( clickedA );

	projectSlideShowIsActive = false;
}

function switchProjectImage(clickedA)
{
	var activeIndex = $(clickedA).parent().parent().find('li.active').index();
	
	if( $(clickedA).parent().parent().parent().children('a:nth-child(' + (activeIndex+1) +')').queue().length > 0 )
	{
		return;
	}
	
	var liIndex = $(clickedA).parent().index();
	
	$(clickedA).parent().parent().parent().children('a:nth-child(' + (activeIndex+1) +')').fadeOut('fast', function(){
		
		$(clickedA).parent().siblings('li').each(function(){
			
			$(this).removeClass();
			$(this).find('img').attr('src', '/public/images/layout/slide-nav.png');
		});
		
		$(clickedA).parent('li').addClass('active');
		$(clickedA).children('img').attr('src', '/public/images/layout/slide-nav-active.png');
		
		$(this).parent().find(':nth-child('+(1 + liIndex)+')').fadeIn();

	});

}

function cycleProjects(clickA)
{
	if( ! projectSlideShowIsActive ) return; 
	
	var divIndex = 1 + clickA.parents('div.portfolio-item').index();
	var liIndex = 1 + clickA.parent().index();
	
	if(clickA.parent('li').siblings().length > (liIndex-1))
	{
		setTimeout("cycleProjects($('.secondary-holder div.portfolio-item:nth-child("+divIndex+")').find('.slideshow-nav li:nth-child("+(liIndex+1)+") > a'));",projectSlideShowTimeout + 500*Math.random());
	}
	else
	{
		setTimeout("cycleProjects($('.secondary-holder div.portfolio-item:nth-child("+divIndex+")').find('.slideshow-nav li:nth-child(1) > a'));",projectSlideShowTimeout + 500*Math.random());
	}
	
	switchProjectImage(clickA);
}

function cycleHomePageProjects(clickA)
{
	if( ! projectSlideShowIsActive ) return; 
	
	var liIndex = 1 + clickA.parent().index();
	
	if(clickA.parent('li').siblings().length > (liIndex-1))
	{
		setTimeout("cycleHomePageProjects($('div.illustration-promo').find('.slideshow-nav li:nth-child("+(liIndex+1)+") > a'));",projectSlideShowTimeout + 500*Math.random());
	}
	else
	{
		setTimeout("cycleHomePageProjects($('div.illustration-promo').find('.slideshow-nav li:nth-child(1) > a'));",projectSlideShowTimeout + 500*Math.random());
	}
	
	switchProjectImage(clickA);
}






