$(document).ready(function(){
	$('a').each(function() {
		var a = new RegExp('/' + window.location.host + '/');
		if(!a.test(this.href)) {
			$(this).click(function(event) {
				event.preventDefault();
				event.stopPropagation();
				window.open(this.href, '_blank');
			});
		}
	});
	$('#blog').masonry({
		itemSelector: 'li'
	});
	$.fn.clear_field = function() {
		return this.focus( function() {
			if ( this.value == this.defaultValue ) this.value = "";
		}).blur( function() {
			if ( !this.value.length ) this.value = this.defaultValue;
		});
	};
	/*$('input[name=s]').clear_field();
	jQuery('.tab-content > li').addClass('hidden').hide();
	$('.tab-menu a').click(function(){
		$('.tab-menu a').removeClass('current');
		$(this).addClass('current');
		var $class = $.trim(jQuery(this).html().toLowerCase());
		jQuery('.tab-content > li').each(function(){
			if ( jQuery(this).hasClass($class) ) {
				window.location = "#" + $class;
				jQuery(this).removeClass('hidden').show();
			} else {
				jQuery(this).addClass('hidden').hide();
			}
		});
		return false;
	});
	$(".tab-menu a:first").click();
	
	jQuery('#layout ul .post-thumbnail').each(function(){
		jQuery(this).find('img').stop().animate({opacity: 0.8}, 0);					 
	});
	jQuery('#layout ul .post-thumbnail').hover( function () {
		jQuery(this).find('img').animate({opacity: 0.8}, 0).stop().animate({opacity: 1}, 100);
	}, function () {
		jQuery(this).find('img').stop().animate({opacity: 0.8}, 100);
	});*/
	jQuery('#filters a').click(function(){
		jQuery('#filters a').removeClass('active');
		var tag = jQuery(this).attr("class");
		jQuery(this).addClass('active');
		jQuery('#layout ul > li').each(function(){
			if ( jQuery(this).hasClass(tag) ) {
				jQuery(this).removeClass('hidden').show();
				window.location = "#" + tag;
			} else {
				jQuery(this).addClass('hidden').hide();
			}
		});
		if (tag == 'all') {
			window.location = "#all";
			jQuery('#layout ul > li').removeClass('hidden').show();
			
		}
		return false;	
	});
	var $hash = window.location.hash;
	$hash = $hash.replace('#','.');
	jQuery('#filters').find($hash).click();
});
