$(function() {
	var height = 100;
	var numOfPages = Math.ceil($('ul#list li:visible').length / 2);
	var currentPage = 1;
	
	$('#map area').mouseover(function() {
		$('#mapChanger').attr('class', $(this).attr('id'));
	}).mouseout(function() {
		$('#mapChanger').attr('class', '');
	}).click(function() {
		var id = $(this).attr('id');
		$('#mapSelection').attr('class', id);
		$('ul#list li').hide();
		$('ul#list li.' + id).show();
		$('ul#list').scrollTop(0);
		numOfPages = Math.ceil($('ul#list li:visible').length / 2);
		currentPage = 1;
		
		if(numOfPages > 2)
			$('#showNext').show();
		else
			$('#showNext').hide();
		
		return false;
	});
	
	
	$('#showNext').click(function() {
		currentPage = (currentPage >= numOfPages) ? 1 : currentPage + 2;
		var page = (currentPage == numOfPages && numOfPages % 2 == 1) ? currentPage - 1 : currentPage;
		
		$('ul#list').scrollTop((page - 1) * height);
		return false;
	});
});
