// remap jQuery to $
(function($){})(window.jQuery);

/* trigger when page is ready */
$(document).ready(function (){

	// Fancybox
	$("a.fancybox,.gallery-item a").fancybox({
		'titlePosition':'inside'
	});

	// Stylistic Updates for non-modern browsers (these changes are done
	// with CSS, but older browsers won't see it)
	// -------------------------------------------------------------------
	$('.blog-post:last-child').addClass('last');
	
	// Medium & Small Galleries
	// -------------------------------------------------------------------
	
	var mediumAndSmallBlocks = $('.medium-gallery a,.small-gallery a');
	
	// Medium & Small Gallery Hovers
	$(mediumAndSmallBlocks).hover(function(){
		$(this).find('.hovers').fadeIn('fast');
	},function(){
		$(this).find('.hovers').hide();
	});
	
	// Text Fields & Search
	// -------------------------------------------------------------------
	
	// Text field clearing on focus
	$('.blink').focus(function(){
		if( $(this).val() == $(this).attr('title') ) {
			$(this).val('');
		}
	}).blur(function(){
		if( $(this).val() == '' ) {
			$(this).val( $(this).attr('title') );
		}
	});
	
	// Search field expanding on focus
	$('.search').focus(function(){
		$(this).animate({'width':240},300,'easeInOutQuad');
	}).blur(function(){
		$(this).animate({'width':120},300,'easeInOutQuad');
	});
	
	// Blockquote Styling
	$('blockquote').wrapInner('<div class="inner" />');
	
	// Table Styling
	$('article table tr:last').addClass('last');
	$('article table tr').each(function(){
		$('td:last', this).addClass('last');
	});
	$('article table tr:even').addClass('even');
	
	// Dropdowns
	// -------------------------------------------------------------------
	
	$('nav ul li').hover(function(){
		$(this).find('a:first-child').addClass('hover');
		$(this).find('ul.sub-menu').fadeIn('fast');
	},function(){
		$(this).find('a:first-child').removeClass('hover');
		$(this).find('ul.sub-menu').hide();
	});
	
	
});
