jQuery(window).load(function(){
	$('#brickbuilder').isotope({
		itemSelector: '.post-container',
		layoutMode: 'masonry',
		masonry : {
          columnWidth : 160
        }
	});
});

jQuery(document).ready(function(){
	$('#option-set li.filternav a').click(function(){
		$(document).find('.current_page').removeClass('current_page');
		$(this).parent('li').addClass('current_page');
		var href = $(this).attr('href').replace( /^#/, '' ),
		option = $.deparam( href, true );
		$.bbq.pushState( option );
		var selector = $(this).attr('data-filter');
		$('#brickbuilder').isotope({ filter: selector, columnWidth : 160 });
		return false;
	});
	$(window).bind( 'hashchange', function( event ){
		var hashOptions = $.deparam.fragment();
		$('#brickbuilder').isotope( hashOptions, 'columnWidth : 160' );
	}).trigger('hashchange');
	resize_on_start();
});

function resize_on_start() {
	var wh = $(window).height();
	var ww = $(window).width();
	if ( wh > ww ) {
		$("#bgfix img").css('height', '100%');
		$("#bgfix img").css('width', 'auto');
	}
	if (ww > wh ) {
		$("#bgfix img").css('width', '100%');
		$("#bgfix img").css('height', 'auto');
	}
}

$(function(){
	$(window).resize(function(){
		resize_on_start();
	});
});




