$(document).ready(function(){



	// Hides the arrow on navigation items w/o a dropdown
	
	$('#navigation li').not(':has(ul)').hover().css('background-image', 'none');
	
	
	
	// Arranges the footer widgets with Masonry
	
	$('#footer .sidebar').masonry({ columnWidth: 330 });
	
	
	
	// Clears fields on focus, resets value on blur
	
	$.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();
	
	
	
	// Enables the tabbed widget
	
	$('.wct-tabs a').click(function(){
		$('.widget-create-tabbed a').removeClass('current');
		$(this).addClass('current');
		$('.widget-create-tabbed ul:not(.wct-tabs)').hide();
		$('.wct-' + $(this).html().toLowerCase()).fadeIn();
		return false;
	});
	
	
	
	// Fades store/portfolio link overlays
	
	jQuery('.thumbnails .post-thumbnail').hover( function () {
		jQuery(this).find('ul').css('display','inline').animate({opacity: 0}, 0).stop().animate({opacity: 1}, 300);
	}, function () {
		jQuery(this).find('ul').stop().animate({opacity: 0}, 300);
	});
	
	
	
	// Filters
	
	jQuery('#create-filters a').click(function(){
		jQuery('#create-filters a').removeClass('active');
		jQuery(this).addClass('active');
		var tag = jQuery(this).html().toLowerCase();
		jQuery('.thumbnails > li').each(function(){
			if ( jQuery(this).hasClass(tag) ) {
				jQuery(this).removeClass('hidden').show();
			} else {
				jQuery(this).addClass('hidden').hide();
			}
		});
		if (tag == 'all') jQuery('.thumbnails > li').removeClass('hidden').show();
		return false;
	});
	
	
	
});
