$(document).ready(function(){


  window.setTimeout('floatPosts()', 300);   
  
  var $loader		= $('#st_loading');
		var $currImage 	= $('#wrappone');
		$loader.hide();
		$currImage.fadeIn(1000);
		  $('#test').rssfeed('http://www.baricittafutura.it/rodcast/content/readfeed.php?podcast=pool', {
		limit: 50,
		header: false,
		date: false,
		snippet:false
	});
 
});    	 


function floatPosts() { 
  if ($('.focus').length > 0) { 
    var focus_height = $('.focus').height();
    var focus_height_and_margin = focus_height + 10;
    $('#normals').css({'margin-top':focus_height_and_margin});
  }

	$('#posts').masonry({ 
	   animate: true,
	   columnWidth: 1,
	   itemSelector: '.main'	   
  });
 
	
	$('#normals').masonry({ 
	  itemSelector: '.normal'  
	});

	$('#post-related').masonry({ 
	  itemSelector: '.inside'  
	});

} 


missionimg = {
	current: 0,
	timer: 5000,
	start: function() {
		missionimg.images = $('#missionimg img');
		setInterval("missionimg.changeImg()", missionimg.timer);
	 },
	 changeImg: function() {
	 	if(missionimg.current == 0) {
	 		$(missionimg.images).eq(0).fadeOut('slow', function() {
	 			$(missionimg.images).eq(1).fadeIn('slow');
	 			missionimg.current = 1;
	 		});
	 	}
	 	else {
	 		$(missionimg.images).eq(1).fadeOut('slow', function() {
	 			$(missionimg.images).eq(0).fadeIn('slow');
	 			missionimg.current = 0;
	 		});
	 	}
	 }
	 	
}

collectionimg = {
	current: 0,
	timer: 5000,
	start: function() {
		collectionimg.images = $('#collectionimg img');
		setInterval("collectionimg.changeImg()", collectionimg.timer);
	 },
	 changeImg: function() {
	 	if(collectionimg.current == 0) {
	 		$(collectionimg.images).eq(0).fadeOut('slow', function() {
	 			$(collectionimg.images).eq(1).fadeIn('slow');
	 			collectionimg.current = 1;
	 		});
	 	}
	 	else {
	 		$(collectionimg.images).eq(1).fadeOut('slow', function() {
	 			$(collectionimg.images).eq(0).fadeIn('slow');
	 			collectionimg.current = 0;
	 		});
	 	}
	 }
	 	
}



advimg = {
	current: 0,
	timer: 4000,
	start: function() {
		advimg.images = $('#advimg img');
		setInterval("advimg.changeImg()", advimg.timer);
	 },
	 changeImg: function() {
	 	if(advimg.current == 0) {
	 		$(advimg.images).eq(0).fadeOut('slow', function() {
	 			$(advimg.images).eq(1).fadeIn('slow');
	 			advimg.current = 1;
	 		});
	 	}
		else if(advimg.current == 1) {
	 		$(advimg.images).eq(1).fadeOut('slow', function() {
	 			$(advimg.images).eq(2).fadeIn('slow');
	 			advimg.current = 2;
	 		});
	 	}
	 	else {
	 		$(advimg.images).eq(2).fadeOut('slow', function() {
	 			$(advimg.images).eq(0).fadeIn('slow');
	 			advimg.current = 0;
	 		});
	 	}
	 }
	 	
}

celebrityimg = {
	current: 0,
	timer: 6000,
	start: function() {
		celebrityimg.images = $('#celebrityimg img');
		setInterval("celebrityimg.changeImg()", celebrityimg.timer);
	 },
	 changeImg: function() {
	 	if(celebrityimg.current == 0) {
	 		$(celebrityimg.images).eq(0).fadeOut('slow', function() {
	 			$(celebrityimg.images).eq(1).fadeIn('slow');
	 			celebrityimg.current = 1;
	 		});
	 	}
		else if(celebrityimg.current == 1) {
	 		$(celebrityimg.images).eq(1).fadeOut('slow', function() {
	 			$(celebrityimg.images).eq(2).fadeIn('slow');
	 			celebrityimg.current = 2;
	 		});
	 	}
	 	else {
	 		$(celebrityimg.images).eq(2).fadeOut('slow', function() {
	 			$(celebrityimg.images).eq(0).fadeIn('slow');
	 			celebrityimg.current = 0;
	 		});
	 	}
	 }
	 	
}
