$(document).ready(function() {
	pieces = location.href.split('/');
	last = pieces.length - 1;
	size = pieces[last].length;
	if(size == 1 || pieces[last] == 'companies') {
		$('#county_selector').hide();
		$('.company_nav').show();
		$(".sort_radio:first").attr("checked", "checked"); 
	}
	else if(pieces[last] == 'Statewide') {
		$('.company_nav').hide();
		$(".sort_radio:last").attr("checked", "checked");
	}
	else {
		$('.company_nav').hide();
		$(".sort_radio:eq(1)").attr("checked", "checked");
		$()
	}
	$('.sort_radio').change(function() {
		if($(this).attr('value') == "letter") {
			location.href = "/companies";
		} else if($(this).attr('value') == "statewide") {
			location.href = "/companies/index/Statewide";
		} else {
			$('.company_nav').hide();
			$('#county_selector').show();
			$('#county_selector').focus();
		}
	});
	$('#county_selector').change(function() {
		if($(this).attr('value') != 0) {
			location.href = "/companies/index/" + $(this).attr('value');
		}
	})
});

