function newsListMasonry(){
	jQuery.noConflict();
	jQuery(document).ready(function($){



	// Set up some variables
		var $contentOverlay = '<div class="containerOverlay" onclick=""></div>';			
		var $container = $('.news-list');
		$('.news-list .article .text-wrapper, .news-list .article .news_main').hide();


	// Lets make sure that images load in nicely
		var listIndex = 0;
		
		$('.news_thumb').css({opacity: 0});
		
		renderNext.list = $('.news_thumb').get();
		renderNext();

		function renderNext() {
		
			var _image, item = renderNext.list.shift();

			if(!item){
				
				provideHoverStates();
				
				listIndex = 0;
				
				return false;
			}

			_image = $('<img />').bind("load", function() {
			
				$(item).stop().delay(listIndex * 150).animate({opacity: 1}, 300);
			
				listIndex++;
				renderNext();

			}).attr('src', $(item).attr('src'));
		
			return true;
		}


	// Detect orentation change and act accordingly
		window.onorientationchange = detectIPadOrientation;
		function detectIPadOrientation() {

			$('.containerOverlay').animate({
				opacity: 0
			}, 300, function(){
				$('.containerOverlay').remove();
				$('.news-list').masonry('reload');
			});				

			$('.news-list .article img.news_thumb').css({opacity: 1});	

		}



	// Set up masonry
		$container.imagesLoaded( function(){
			$container.masonry({
				columnWidth: 201,
				isAnimated: true,
				itemSelector: '.article'
	    	});
		});



		function provideHoverStates() {
			
			$('.news-list .article img.news_thumb').hover(function(){
			    $(this).stop().animate({opacity: 0.65}, 300);
			},function(){
			    $(this).stop().animate({opacity: 1}, 300);
			});
			
			return false;
		}


	// Lets set up a handler, we want it to show boxes when item is clicked, but when elsewhere on the page is clicked, hide




		$('.containerOverlay, #header').live('click', function(){
			$('.containerOverlay').stop().animate({
				opacity: 0
			}, 150, function(){
				$('.containerOverlay').remove();
			});
			//return false;
		});




		$('.news-list .article img.news_thumb').live('click', function() {

			var $pos = $(this).offset();
			var $width = $(window).width();
			var $height = $(document).height();
			var topPos, leftPos, newHeight;	
			$('.containerOverlay').remove();

			$($contentOverlay).appendTo('body').hide();

			$($(this).parent().parent().find('.text-wrapper')).clone().appendTo('.containerOverlay').show();

			newHeight = $('.containerOverlay').outerHeight();
			
			if(newHeight < 210) {
				newHeight = 201;
			} else if (newHeight > 201) {
				newHeight = 401;
			}

			if (($pos.left + 420) >= $('.news-list').width()) {
				leftPos = $pos.left - 202;
			} else {
				leftPos = $pos.left;
			}
			
			if ( (($pos.top + newHeight) >= $height) && (newHeight != 201) ) {
				topPos = $pos.top - 201;
			} else {
				topPos = $pos.top;
			}

			$('.containerOverlay').css({
				display: 'block',
				top: topPos,
				left: leftPos,
				height: newHeight,
				'z-index': 9000000000,
				'opacity': 0
			}).stop().animate({
				opacity: 0.9
			}, 150, function(){
				
				$('body, html').animate({
					scrollTop: ($pos.top - 200)
				}, 300, 'easeOutCubic');

			});

		});

	

	return false;
	});
}


