$(function(){

var $container = $("#specialtyStoresIntro"),
	 $select = $("<select id='stateChooser'><option>select a state</option></select>").appendTo($container),
	 $list = $("div#specialtyStoresList"),
	 $states = $list.find("ol > li");

	
$states.each(function(){
	var $this = $(this),
		 anchor = $this.find("a[name]").attr("name"),
		 label = $this.find("h5").text(),
		 $option = $("<option>"+ label +"</option>").appendTo($select).val(anchor);
	$this.hide();
});

$select
	.find("option")
		.eq(0)
			.val("__ALL")
		.end()
	.end()
	.change(function(e){
		var $this = $(this),
			 $target = $(e.target),
			 jumpto = $target.val();
		if(jumpto == "__ALL"){ $states.show(); }
		else{ 
			$states.hide();
			$states.each(function(){
				var $this = $(this);
				if($this.find("a").attr("name") == jumpto){ $this.show(); }
			});
		}
	});
	


}); // END document.ready
