//<![CDATA[
$(document).ready(function() { 
	$('#menu-picker').show();
	//build the menu
	$('table h2').each(function(i){
	
		var country = $(this).text();
		
		$(this).next().andSelf().attr('class', 'option_'+i);
		$('<option/>').attr('value', 'option_'+i).text(country).appendTo('#menu-picker select');
		if(/(^|\s)(UK|Kingdom)(\s|$)/.test(country)) {
			// has UK in it, so select it:
			$("#menu-picker option[value='option_" + i + "']").attr("selected", "selected");
			
		}
	});
	$('#menu-picker select').change(function()
		{
			$("table h2").each(function() { 
	    		$(this).parents().filter('tr').hide(); 
			}); //hide all
			// and open this one:
			var openClass = $(this).val();
			$('table h2.' + openClass).parents().filter('tr').show();
		});
	
	// initialise: get the UK one to default
	// it shd alredy be selected, so just run the change() event:
	$('#menu-picker select').change();

	/* link replacer */
	// callback: makes links from URLs in text
	function linkUrl( str ){
	  return "<a href='"+str+"'>"+str+"</a>";
	};
	// uses the ba replace text plugin - pass it a callback defined above!
	$('table li').replaceText( /(\b(http|https|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi, linkUrl );


});

//]]>
