$(document).ready(function() {
//on page load get hash
if (window.location.hash) {
filterVal = window.location.hash.substr(1);
		if(filterVal == 'all') {
			$(postsContainer + ' div.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$(postsContainer + ' div.post').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}

}


//clicking function
	$('ul#filters a').click(function() {
		$(this).css('outline','none');
		$('ul#filters .current').removeClass('current');
		$(this).parent().addClass('current');
	
		var filterVal = 'category-' + $(this).text().toLowerCase().replace(' ','-');
		window.location.hash = filterVal;
		if(filterVal == 'category-all') {
			$(postsContainer + ' div.hidden').fadeIn('slow').removeClass('hidden');
			window.location.hash = '';

		} else {
			
			$(postsContainer + ' div.post').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});
});

