$(function () {
	var tagArray = [];
	tagArray['t0'] = 'Coming Soon';
	tagArray['t1'] = 'Beginner'; tagArray['t2'] = 'Intermediate'; tagArray['t3'] = 'Advanced';
	tagArray['t4'] = 'Designers'; tagArray['t5'] = 'Developers';
	tagArray['t6'] = 'Creative'; tagArray['t7'] = 'Technical'; tagArray['t8'] = 'Inspirational'; tagArray['t9'] = 'Other';
	tagArray['t10'] = 'Flash'; tagArray['t11'] = 'Flashbuilder'; tagArray['t12'] = 'Catalyst'; tagArray['t13'] = 'AIR';
	tagArray['t14'] = 'Actionscript'; tagArray['t15'] = 'Processing'; tagArray['t16'] = 'Open Frameworks'; tagArray['t17'] = '3D';
	tagArray['t18'] = 'Mobile'; tagArray['t19'] = 'Desktop'; tagArray['t20'] = 'Multi User'; tagArray['t21'] = 'Gaming';
	tagArray['t22'] = 'Touchscreen'; tagArray['t23'] = 'Sound'; tagArray['t24'] = 'Film/Video'; tagArray['t25'] = 'Motion Graphics';
	tagArray['t26'] = 'Photography'; tagArray['t27'] = 'Illustration'; tagArray['t28'] = 'Animation'; tagArray['t29'] = 'Typography';
	tagArray['t30'] = 'Interactive'; tagArray['t31'] = 'Experimental'; tagArray['t32'] = 'Print'; tagArray['t33'] = 'Branding';
	tagArray['t34'] = 'Narrative'; tagArray['t35'] = 'Process'; tagArray['t36'] = 'Workflow'; tagArray['t37'] = 'Deployment';
	tagArray['t38'] = 'Flex'; tagArray['t39'] = 'CS5'; tagArray['t40'] = 'Flash Player'; tagArray['t41'] = 'Optimisation';
	
	var html = [];
	for (var k in tagArray) {
		if ($('.' + k).length) html.push('<li><label class="label_check" for="' + k + '"><input type="checkbox" id="' + k + '" value="' + k + '" />' + tagArray[k] + '</label></li>');
	}
	
	$('<ul class="filters"></ul>').insertBefore('.filterThis').append(html.join(''));
	
	$('input[type=checkbox]').click(function () {
		var $checkbox = $(this),
			checked = $checkbox.is(':checked'),
			id = '.' + $checkbox.val();
		$('#portfolio').fadeOut(function () {
			hideFaces();
			showFaces();
			$(this).fadeIn();
		});
	});
	
	$('#portfolio').fadeOut();
});

function showFaces() {
	$( $('input[type=checkbox]:checked').map(function () {
		return '.' + this.value
	}).get().join(',') ).show();
}

function hideFaces() {
	$( $('input[type=checkbox]:not(:checked)').map(function () {
		return '.' + this.value
	}).get().join(',') ).hide();	
}

