/**
 * Enhance the distributor jump-to navigation.
 */
$(document).ready(function() {
	var $page_nav = $('div.jump_nav');
	var label = $('<label for="jump_nav_list"></label>').append($('p:eq(0)', $page_nav).text());
	var dd = $('<select id="jump_nav_list"></select>');
	
	$('a', $page_nav).each(function(index) {
		$('<option></option>').appendTo($(dd))
		.attr('value', $(this).attr('href'))
		.append($(this).text());
	});
	
	// Replace the existing navigation list with a form	
	$page_nav.replaceWith(
		$('<form class="jump_nav"></form>')																						// Creates the form
		.append('<fieldset class="clearfix"></fieldset>')															// Creates and appends the fieldset
		.children('fieldset')																													// Moves focus to the fieldset
		.append('<div class="field"></div>')																					// Creates and appends the drop-down field wrapper
		.append('<div class="field submit">')																					// Creates and appends the submit field wrapper
		.children('div:eq(0)')																												// Moves focus to the drop-down field wrapper
		.append(label)																																// Appends the label
		.append(dd)																																		// Appends the drop-down
		.next()																																				// Moves focus to the submit field wrapper
		.append('<input type="image" src="/Arbury/assets/images/btn_jump_nav_go.gif" alt="Go" />')			// Appends the submit button
		.parents('.jump_nav')																													// Moves focus back to the form
	);
	
	$('form.jump_nav').submit(function(event) {
		$.scrollTo($('#jump_nav_list').attr('value'), 500);
		event.preventDefault();
	}); // submit
});