$(document).ready(function(){
	var img_path = '/img/rollovers/';
	var $default = $('#map_img');
	var default_img = $default.attr('src');

	/*
	 * This will just reset the image to the default.gif
	 */
	var set_default_img = function(){
		var id = $(this).attr('id');
		$default.attr('src',default_img);
		$('#float_'+id).hide();
	}

	/*
	 * This will change the default image, as well as load the
	 * name & location that belongs to the rollover aka named Individual, City, State
	 */
	var display_mouseover = function(){
		var id = $(this).attr('id');
		$default.attr('src',$('#map_'+id).attr('src'));
		$('#float_'+id).html($('#floatinfo_'+id+' h3, #floatinfo_'+id+' p').clone()).show();
	}

	/*
	 * This is a list of all the diff people and their territory image
	 */
	var map_list = new Array(
		'peteburnett',
		'craiglunt',
		'briankaye',
		'reedbenson',
		'joejanes',
		'jeffnybeck',
		'charliewiles',
		'markblanc',
		'headquarters',
		'billyjoerichardson',
		'markrice',
		'johnlano',
		'dwaynerandall',
		'brandonkop'
	);

	/*
	 * Looping through all the people
	 */
	for(var i = 0; i < map_list.length; i++)
	{
		var name = map_list[i].toString();
		// preloading the images of the people
		$('<img id="map_' + name +'" class="preload" src="' + img_path + name + '.gif" />').appendTo('#preload');
		// binding the rollovers for the people
		$('#'+name).mouseover(display_mouseover).mouseout(set_default_img);
		// assembling the DOM needed for the css
		$('#maps').append('<div class="floaters" id="float_' + name + '"></div>');
	}

	$('area').click(function(){
		return false;
	});

});

function display_manual(sName){
	//var id = $(this).attr('id');
	$('#map_img').attr('src',$('#map_'+sName).attr('src'));
	$('#float_'+sName).html($('#floatinfo_'+sName+' h3, #floatinfo_'+sName+' p').clone()).show();
}

function set_default_img(sName){
	$('#map_img').attr('src','/img/rollovers/default.gif');
	$('#float_'+sName).hide();
}
