jQuery(function ($) {
$(document).ready(function() {  
		$('#newer a').live('click',function(){  
		var toLoad = $(this).attr('href');
		$('.post').fadeOut();
		$.get(toLoad, function(data){
			$(data).find('#content_inner .post:first').prependTo('#first-line-box').hide();
			$('#content_inner .post:last').remove();
			$('#first-line-box .post:last').remove().insertBefore('#second-line-box .post:first').hide('fast', function(){$('.post').fadeIn()});
			$('#nav').replaceWith($(data).find('#nav'));
		 });

		return false;  
	  
		});
		
		$('#older a').live('click',function(){  
			var toLoad = $(this).attr('href');
		
			$('.post').fadeOut();
			//alert("all done");
			$.get(toLoad, function(data){
					$('#first-line-box .post:first').remove();
					$(data).find('#content_inner .post:last').appendTo('#second-line-box').hide();

					$('#second-line-box .post:first').remove().insertAfter('#first-line-box .post:last').hide('fast', function(){$('.post').fadeIn()});
					$('#nav').replaceWith($(data).find('#nav'));

			});
			
			return false;
		});

	/*
		if (/http:\/\/edijsmajors\.lv\/newsuperblog\/?(page\/1\/|index\.php|$)/.test(document.location.href)) {
			var newPostCheckInterval = 5;
			setInterval(function(){
				if (!$('#newer').is(':empty')) return true;
				var toLoad = document.location.href;
				$.get(toLoad, function (data) {
					var $fPost = $(data).find('#first-line-box .post:first');
					if ($fPost.attr('id') == $('#first-line-box .post:first').attr('id')) return true;
					var $lefty1 = $('#first-line-box .post:last');
						$lefty1.animate({width: 'toggle'},function(){
					var $righty = $fPost.hide().prependTo('#first-line-box');
						$righty.show('slide',{direction: 'left'},function(){});
					var $lefty = $('#second-line-box .post:first');
						$lefty.animate({width: 'toggle'},function(){$(this).remove();
					var $righty = $lefty1.hide().appendTo('#second-line-box');
						$righty.show('slide',{direction: 'left'});
					});
					});
				});
			},(newPostCheckInterval*1000));
		}
		*/

		$('.post').live('mouseover mouseout', function(event) {
		if (event.type == 'mouseover') {
			$(this).children('.front').hide();
			$(this).children('.back').show();
		} else {
			$(this).children('.back').hide();
			$(this).children('.front').show();
		}
		});
	});
}); 