
$(document).ready(function(){


	$('p').filter(function() {
	        return $.trim($(this).text()) === ''
	    }).addClass('maybe-empty');
	    
	$('p.maybe-empty').each(function(){
		if( $(this).find('img').length ) {
			// has image
		}
		else {
			$(this).remove();
		}
	});
	


	///////////////// SPINNING EARTH SPLASH PAGE ///////////////////////
	
	if( $('body').hasClass('home') ) {

		var t = (($(window).height()/2)-250-30);
/* 		var l = (($(window).width()/2)-250); */
		var earth = $('.home .entry-content img');
		earth.wrap('<div id="earth-wrapper"/>');
		$('#earth-wrapper').css({'position':'absolute', 'top': t });

		$(window).load(function(){


			var first = 1;
		
			function spin() {
				if(first == 1) {
					var deg = 360;
					first = 0;
				}
				else {
					deg = 420;
				}
				
				
				earth.stop().animate({rotate: '+='+deg+'deg'}, 5000);
				
				window.setTimeout(function(){		
					earth.stop().animate({rotate: '-=60deg'}, 3000);
				}, 5000);
		
				window.setTimeout(function(){
					spin();		
				}, 7500);
			}	
			spin();
		});
	}
	
	$('.tab').hover(function(){
		$(this).stop().animate({'opacity':1}, 300);
	}, function(){
		$(this).stop().animate({'opacity':0.7}, 300);
	});
	
	$("p:empty").remove();

	$('p:first a img').closest('p').css({ 'margin-bottom': 0 });

	////////////////////////////////////////////////////////////////
	
});
