$(document).ready(function(){

	/* Main Map */
	if($('#interactive-map').length){
		
		$('#im-sidebar input').keyup(function(){
			var $input = $(this);
			var val = $input.val();
			var $listitems = $('#im-sidebar li');
			
			if(val.length > 0){
				$listitems.each(function(){
					var $li = $(this);
					var $a = $(this).find('a');
					if($a.html().search(new RegExp(val, 'i')) < 0){
						$li.fadeOut('slow');
					} else {
						$li.fadeIn('slow');
					}
				});
			} else {
				$listitems.each(function(){
					$(this).fadeIn('slow');
				});
			}
		});
		
		$('#im-map a .hidden').hide().removeClass('hidden');
		$('#im-map a').each(function(){
			$a = $(this);
			var xpos = Number(Number($a.attr('xpos')) - 25) + 'px';
			var ypos = Number(Number($a.attr('ypos')) - 10) + 'px';
			
			$a.css({
				top: ypos,
				left: xpos
			});		
		})
		.hover(function(){
			$(this).find('span').fadeIn();
		},function(){
			$(this).find('span').fadeOut();
		});
		
	}
	
	/* County Page */
	if($('#county-positions').length){
	
		$('#county-positions a[rel=colorbox]').colorbox();
	
		$('#county-positions .hidden').hide().removeClass('hidden');
		
		$('#county-positions h3').click(function(){
			$(this).next().slideToggle();
		});
	
	}
});