jQuery(document).ready(function($){
	// Home
	jQuery(document).bind('keydown', {combi:'esc', disableInInput: true}, function(e){ 
		e.preventDefault(); 
		jQuery('.header').each(function(){
	    	window.location=$(this).find('a').attr('href');
	    	return false;
		});
	});
	
	// Info
	jQuery(document).bind('keydown', {combi:'i', disableInInput: true}, function(e){ 
		e.preventDefault(); 
		jQuery('.nav').each(function(){
	    	window.location=$(this).find('a').attr('href');
	    	return false;
		});
	});
	
	// Issue
	jQuery(document).bind('keydown', {combi:'1', disableInInput: true}, function(e){ 
		e.preventDefault();
		jQuery('#post_46').each(function(){
	    	window.location=$(this).find('a').attr('href');
	    	return false;
		});
	});
	
	jQuery(document).bind('keydown', {combi:'2', disableInInput: true}, function(e){ 
		e.preventDefault(); 
		jQuery('#post_52').each(function(){
	    	window.location=$(this).find('a').attr('href');
	    	return false;
		});
	});
	
	jQuery(document).bind('keydown', {combi:'3', disableInInput: true}, function(e){ 
		e.preventDefault(); 
		jQuery('#post_109').each(function(){
	    	window.location=$(this).find('a').attr('href');
	    	return false;
		});
	});

	// Previous and next links with keyboard shortcuts	
	jQuery(document).bind('keydown', 'j', function(){ 
		scrollTop = jQuery(window).scrollTop();
		jQuery('#content h2').each(function(i, h2){ 
			h2top = jQuery(h2).offset().top; 
			if (scrollTop < h2top) { 
				jQuery.scrollTo(h2, 800);
				return false; 
			}
		});
	});
	
	jQuery.fn.reverse = function(){
		return this.pushStack(this.get().reverse(), arguments);
	};
	
	jQuery(document).bind('keydown', 'k', function(){ scrollTop = jQuery(window).scrollTop();
		jQuery('#content h2').reverse().each(function(i, h2){ 
			h2top = jQuery(h2).offset().top; 
			if (scrollTop > h2top) { 
				jQuery.scrollTo(h2, 300);
				return false; 
			}
		});
	});	
	
	jQuery('<div id="next_arrow">Next (j)</div>')
		.prependTo("body.single")
		.click(function(){
			scrollTop = jQuery(window).scrollTop();
			jQuery('#content h2').each(function(i, h2){
				h2top = jQuery(h2).offset().top; 
				if (scrollTop < h2top) { 
					jQuery.scrollTo(h2, 300); 
					return false;
				}
		});
	});
	
	jQuery.fn.reverse = function(){
		return this.pushStack(this.get().reverse(), arguments);
	};
	
	jQuery('<div id="prev_arrow">Prev (k) / </div>')
		.prependTo("body.single")
		.click(function(){
			var scrollTop = jQuery(window).scrollTop();
			jQuery('#content h2').reverse().each(function(i, h2){
				h2top = jQuery(h2).offset().top; 
				if (scrollTop > h2top) { 
					jQuery.scrollTo(h2, 300); 
					return false;
				}
		});
	});
	
	$("#coloring").cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    next:   '#coloring'
	});
	
	$("#missjackson").cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    next:   '#missjackson'
	});
	
	$("#positions").cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    next:   '#positions'
	});
});