
$(document).ready(function() {
	newsletter_field();
	setup_blog_scroller();

	main_menu();

});


function main_menu () {
	
$('ul#menu-primary-navigation ul li:first-child').addClass( 'first_item' );
$('ul#menu-primary-navigation ul li:last-child').addClass( 'last_item' );
		
}



function newsletter_field() {
	var first_click = true;
	$('#newsletter_email').val('Sign up for our e-newsletter!');
	
	$('#newsletter_email').click(function() {
		if(first_click) {
			$('#newsletter_email').val('');
			$('#newsletter_email').attr('style','color:#000') ;
			first_click = false;
		}
	});
}

function setup_blog_scroller() {

	var current_blog_post = 1;
	var max_blog_posts = $(".post_scroller > div").size();

	$('#prev_blog_post').click(function() {
		if(current_blog_post > 1 && !scroll_disabled) {
			swap_blog_post(current_blog_post, --current_blog_post);
		}
	});
	
	$('#next_blog_post').click(function() {
		if(current_blog_post < max_blog_posts && !scroll_disabled) {
			swap_blog_post(current_blog_post, ++current_blog_post);
		}
	});
}

var scroll_disabled = false;
var fade_speed = 1000;
function swap_blog_post(first_id, next_id) {
	scroll_disabled = true;
	$('#blog_post_'+first_id).fadeOut(fade_speed, function() {
		$('#blog_post_'+next_id).fadeIn(fade_speed, function() {
			scroll_disabled = false;
		});
	});
}
