var rgb_pop_settings = {
					link_attribute: 'href',		// attribute to find the url from
					loading_text: 'loading',	// what to toss up when something is loading
					next_text: '+',				// what to put in for the next button
					prev_text: '−',			// what to put in for the prev button
					close_text: 'x',			// what to put in for the close button
					counter_separator: ' / ',	// what to put between the current index and the total
					alternate_counter_content: '', // if we want to use something other than the count
					vimeo_color: 'E63D90',		// object to base x position off of
					html5_video_maybe_not_supported_text: 'Your browser may not support this video format.<br />',
					html5_video_maybe_not_supported_download_text: 'Right click here to download the video.',
					html5_video_not_supported_text: 'Your browser does not support html5 video playback.<br />',
					html5_video_not_supported_download_text: 'Right click here to download the video.'
				};


// Things to run on load
jQuery(document).ready(function($) {

	
	
	// Looks for a section with infinite scrolling and preps it
	$('section#infinite_scroll').prep_infinite_scroll();
	
	// Setup the sticky nav
	/*$('#header').scroll_n_stick( {
				left_anchor: 'body',		// object to base x position off of
				left_anchor_edge: 'left',	// side to base x position off of
				left_anchor_offset: 0, 		// offset from left_anchor_edge to left position of obj
				top_anchor: 'body',			// object to base y position off of
				top_anchor_edge: 'top',		// position to measure start/catch from
				top_anchor_offset: 0
			});*/
	
	$('.single-albums .super_thumb a').rgb_pop();
	
	
	var pop_nav = $('#rgb_pop_nav').each(function(){
		$(this).find('a[href*="portfolio"]').attr('onclick','event.preventDefault();').parent().addClass('current');
	}).html();
		
	rgb_pop_settings = $.extend(rgb_pop_settings,{ pop_class: 'portfolio_pop', alternate_counter_content: pop_nav });
	
	$('footer .portfolio a').rgb_pop( rgb_pop_settings );
	
	$('nav a[href*="portfolio"]').click(function(event){
		event.preventDefault();
		
		$('footer .portfolio a:first').click();
	});
	
	/*$('#nav_blog  a.archive_link').toggle(function(event){
		event.preventDefault();

		$(this).addClass('current');

		$('li.archive_nav ul.years').slideDown();
	}, function(event){
		event.preventDefault();

		$('li.archive_nav ul.years, li.archive_nav ul.months').slideUp();

		$('li.archive_nav a.current').removeClass('current');
	});*/
	
	$('#nav_blog a.year').click(function(event){
		event.preventDefault();

		var the_year = $(this).parent();
		var the_months = $(the_year).find('ul.months');
				
		if ( $(the_months).is(':hidden') ) {
			//$(the_months).slideUp();
			
			//$(this).removeClass('current');
			
		//} else {
			$(the_year)
				.siblings('.current').removeClass('current')
				.find('ul.months').slideUp('normal',function(){
					$(the_months).slideDown();
				});
			
			$(the_year).addClass('current');
		}
	});
	
	// post slide viewer
	var single_post_images = $('.single-post .images a');
	
	if ( single_post_images[1] ) {
		$('.single-post .images').append('<div class="prev_single_image">−</div><div class="next_single_image">+</div>');
	}
	
	$('.prev_single_image').click(function(){
		$('.single-post .images a.current').fadeOut('normal',function(){
			$(this).removeClass('current');

			var next_img = $(this).prev('a');
			
			if ( $(next_img).length == 0 ) {
				next_img = $('.single-post .images a').last();
			}
			
			$(next_img).fadeIn('normal',function() {
				$(this).addClass('current');
			});
		});
	});
	
	$('.next_single_image').click(function(){
		$('.single-post .images a.current').fadeOut('normal',function(){
			$(this).removeClass('current');

			var next_img = $(this).next('a');
			
			if ( $(next_img).length == 0 ) {
				next_img = $('.single-post .images a').first();
			}
			
			$(next_img).fadeIn('normal',function() {
				$(this).addClass('current');
			});
		});
	});
	
});


// Things to run on new content when loaded through ajax
(function($) {
	
	// Preparation for newly loaded content
	$.fn.prep_content_specific = function() {
		$(this)
			// Remove the search button to make it just a field
			.remove_search_button()
			// Adjust audio file links
			.audio_prep()
			// Anything else
			.each(function() {
				// Insert find and action for anything to add
				$(this)
					.find()
			});	
		return this;
	}
	
	// Add additional custom functions here
	
})(jQuery);
