var active_section = "page1";

function change_section(old_section, new_section) {

	$('a#' + old_section + '-nav').removeClass('bold');	
		
	$('fieldset#' + old_section).fadeOut(500);
	$('fieldset#' + old_section).hide();
	$('fieldset#' + new_section).fadeIn(500)
	active_section = new_section;
	
	$('a#' + new_section + '-nav').addClass('bold');
}

$(document).ready(function(){

	$('div#form_navigation a').each(function() {
		
		$(this).click(function() {
			var next_section = $(this).attr("id").split('-')[0];
			change_section(active_section, next_section);
		});
		
	});
	
	$('a.submit-link').click(function() {
		var this_section = $(this).attr("id").split('-')[0];
		
		var page_num = parseInt(this_section.substr(4, 1));
		page_num++
		
		change_section(active_section, 'page' + page_num);
		
	});
	
	$('form#contact_form').submit(function() {
		
		var message = '';
		$('input[type!=hidden][type!=submit], select, textarea').each(function() {
		
			var id = $(this).attr("id");
			var value = $(this).val();
			var heading = $('#' + id + '-label').text();
			
			message += heading + '\n-->' + value + "\n\n";
			
		});
		
		
		$('input#message').val(message);
			
	});

});