$(document).ready(function(){
	
	$(".nav").click(function () {
		var divname= this.value;
		$("#"+divname).delay(400).fadeIn("fast").siblings().fadeOut("fast");
	});

	$(".clearAll").click(function () {
		$(".content").fadeOut("fast");
		$("#Home").delay(400).fadeIn("fast");
	});
	
	$("a[rel=freelance]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$("a[rel=qxlva]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$("a[rel=tlemiad]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});

	function hideAllPortfolio(){
		$("#freelancePortfolio").hide();
		$("#qxlvaPortfolio").hide();
		$("#prnewswirePortfolio").hide();
		$("#tlemiadPortfolio").hide();
		$("#sandpitPortfolio").hide();
	}
	
	$("#freelance").click(function () {
		hideAllPortfolio();
		$("#freelancePortfolio").fadeIn();
	});
	
	$("#qxlva").click(function () {
		hideAllPortfolio();
		$("#qxlvaPortfolio").fadeIn();
	});
	
	$("#prnewswire").click(function () {
		hideAllPortfolio();
		$("#prnewswirePortfolio").fadeIn();
	});
	
	$("#tlemaid").click(function () {
		hideAllPortfolio();
		$("#tlemiadPortfolio").fadeIn();
	});
	
	$("#sandpit").click(function () {
		hideAllPortfolio();
		$("#sandpitPortfolio").fadeIn();
	});
});
