// Fitted Settings //////////////////////////////////////

 $(document).ready(function() { 
	$('.list .item').fitted();
		
	if ($('a').parent().is('.feature')) {
		$('.feature').fitted();
	};
	
	// turn each "blog-list" link into a list of posts... Magic!			
	$('a.blog-list').each(function(index) {
		// base URL
		var url = 'http://pem.org/viewpoints/wp-content/themes/connections/loop.php?';
		// get parameter portion of URL
		var href = String($(this).attr('href')).split('?', 2);
		
		$(this).replaceWith('<div class="blog-list" id="blog-list-'+index+'"></div>');
		
		// load post list page (with callback)
		$('div#blog-list-'+index).load(url+href[1], function(){
			// add hover
			$('div#blog-list-'+index+' .post').bind('mouseenter', function() {
				$(this).addClass('hover');
			}).bind('mouseleave', function() {
				$(this).removeClass('hover');
			});
			
			// add click for whole element
			$('div#blog-list-'+index+' .post').click(function(e) {
				window.location = $(this).find('a.thumb-link').attr('href');
			});
		});
	});
		
});
