var $j = jQuery.noConflict();

$j(document).ready(function() {
	$j('.close-content').live('click', function(){
		$j('#content').fadeOut();
	});
	
	//$j('#content').fadeIn('slow');
	
	// Function to fade images in Sequentially
	var i = 0;
	var bgimgs = $j('#image-background img').hide();
	function displayImages() {
		bgimgs.eq(i++).fadeIn(80, displayImages);  
	};
	
	// On window load, preload images, randomly place and then display	
	$j(window).load(function() {	
		$j('#image-loader img').imgpreload(function() {
			$j('#image-background img').imgpreload(function()
			{	
				$j('#image-loader').fadeOut('fast', function() {
					displayImages();
				});
			});
		});
	});
	
	// Image rollovers
	$j("img.rollover").hover(
		function()
		{
			this.src = this.src.replace(".png","-over.png");
		},
		function()
		{
			this.src = this.src.replace("-over","");
		}
	);
	
	$j("img.rollover").each(function() {
		rollsrc = $j(this).attr("src");
		rollON = rollsrc.replace(/.png$/ig,"-over.png");
		$j("<img>").attr("src", rollON);
	});
	
	// outgoing links
	$j(".single .entry a").attr('target','_blank');
	
	// top
	$j('.backtotop').click(function(){
		$j('html, body').animate({scrollTop:0}, 'slow');
	});
	
});
