$(document).ready(function() {

	$("#prevImage").live("click",function(){
		$.fancybox.prev();
	});
	
	$("#nextImage").live("click",function(){
		$.fancybox.next();
	});

	//fancybox controls
	$("a.fancybox").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200,
		'titlePosition'	:	'over',
		'overlayColor'	:	'#000',
		'overlayShow'	:	true,
		'showNavArrows'	:	true,
		'titleFormat'   : 	function(title, currentArray, currentIndex, currentOpts) {
			if (!title) { title = "";}
			
			if (currentArray.length > 1) {
		    var titleHTML =  '<span id="fancybox-title-over"><strong style="color: #999">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</strong><br/>';
		   		
		   		if ((currentIndex + 1) > 1)
		   		{
		   			titleHTML += " <span id=\"prevImage\">Prev</span>"
		   		}
		   		else
		   		{
		   			titleHTML += " <span id=\"prevImageDisabled\">Prev</span>"
		   		}
		   		
		   		if ((currentIndex + 1) < currentArray.length)
		   		{
		   			titleHTML += " / <span id=\"nextImage\">Next</span>"
		   		}
		   		else
		   		{
		   			titleHTML += "/ <span id=\"nextImageDisabled\">Next</span>"
		   		}
		   	
		   	titleHTML += title + '</span>';
		    return titleHTML
		    
		    }
		    
		    }
	});
	
	//Hide Related articles if empty
	if ($("#similar_articles li").size() == 0) {
		$("#similar_articles").hide();
	}
	
	//Hide article tags if empty
	if ($("#article_tags li").size() == 0) {
		$("#article_tags").hide();
	}
	
	
	
});
