jQuery(document).ready(function($){
		function load_post(post){
			if(typeof(post) != 'undefined'){
	                        window.location = post;
		        }
		}

	$(document).keydown(function(event){
                url = location.href.replace(/page\/([0-9]|[1-9][0-9]|[1-9][0-9][0-9])\//,'');
		if(event.keyCode == '39'){
			if($("body").hasClass('page-browse') && $('div.pagination-top a:contains("Last")').length){
				next = parseInt($("div.pagination-top a.current").text()) + 1;
				post = url+"page/"+next+"/"
			} else {
			post = $("div#next_link a").attr('href');
			}
			load_post(post);
		}
		if(event.keyCode == '37'){
			if($("body").hasClass('page-browse') && $('div.pagination-top a:contains("First")').length){
				last = parseInt($("div.pagination-top a.current").text()) - 1;
	                	post = url+"page/"+last+"/";
			} else {
				post = $("div#previous_link a").attr('href');
			}
			load_post(post);
		}
		
	});
});

