$(document).ready(function() {
	var mapImage = $("#IRECmap_main");
	var easternButton = $("#b_eastern");
	var centralButton = $("#b_central");
	var mountainButton = $("#b_mountain");
	var pacificButton = $("#b_pacific");
	
	var map = $("#IRECmap_secondary1").parent();
	if (map) {
		map.css('width', '280px');
		map.css('float', 'right');
	}

	$("#easternregion").hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main1.gif');
			easternButton.toggleClass('selected');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
			easternButton.toggleClass('selected');
		}
	);
	
	easternButton.hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main1.gif');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
		}
	);
	
	$("#centralregion").hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main2.gif');
			centralButton.toggleClass('selected');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
			centralButton.toggleClass('selected');
		}
	);
	
	centralButton.hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main2.gif');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
		}
	);
	
	$("#mountainregion").hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main3.gif');
			mountainButton.toggleClass('selected');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
			mountainButton.toggleClass('selected');
		}
	);
	
	mountainButton.hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main3.gif');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
		}
	);
	
	$("#pacificregion").hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main4.gif');
			pacificButton.toggleClass('selected');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
			pacificButton.toggleClass('selected');
		}
	);
	
	pacificButton.hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main4.gif');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
		}
	);
	
	$("area.pacific").hover(
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main4.gif');
			pacificButton.toggleClass('selected');
		},
		function() {
			mapImage.attr('src', '/wp-content/themes/IREC/images/IREC-map_main.gif');
			pacificButton.toggleClass('selected');
		}
	);
	
	// secondary pages
	var curr_secondary_loc = $("#IRECmap_secondary1").attr('name');
	$("#eastern_secondary").hover(
		function() {
			$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary1.gif');
			//easternButton.toggleClass('selected');
		},
		function() {
			
			if (curr_secondary_loc == 'central_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary2.gif');
			} else
			if (curr_secondary_loc == 'eastern_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary1.gif');
			} else
			if (curr_secondary_loc == 'pacific_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			} else
			if (curr_secondary_loc == 'mountain_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary3.gif');
			} else
			if (curr_secondary_loc == 'pacific') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			}

		}
	);
	
	$("#central_secondary").hover(
		function() {
			$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary2.gif');
			//easternButton.toggleClass('selected');
		},
		function() {
			
			if (curr_secondary_loc == 'central_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary2.gif');
			} else
			if (curr_secondary_loc == 'eastern_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary1.gif');
			} else
			if (curr_secondary_loc == 'pacific_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			} else
			if (curr_secondary_loc == 'mountain_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary3.gif');
			} else
			if (curr_secondary_loc == 'pacific') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			}

		}
	);
	
	$("#mountain_secondary").hover(
		function() {
			$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary3.gif');
			//easternButton.toggleClass('selected');
		},
		function() {
			
			if (curr_secondary_loc == 'central_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary2.gif');
			} else
			if (curr_secondary_loc == 'eastern_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary1.gif');
			} else
			if (curr_secondary_loc == 'pacific_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			} else
			if (curr_secondary_loc == 'mountain_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary3.gif');
			} else
			if (curr_secondary_loc == 'pacific') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			}

		}
	);
	
	$("#pacific_secondary").hover(
		function() {
			$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			//easternButton.toggleClass('selected');
		},
		function() {
			
			if (curr_secondary_loc == 'central_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary2.gif');
			} else
			if (curr_secondary_loc == 'eastern_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary1.gif');
			} else
			if (curr_secondary_loc == 'pacific_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			} else
			if (curr_secondary_loc == 'mountain_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary3.gif');
			} else
			if (curr_secondary_loc == 'pacific') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			}
		}
	);
	
	$("area.pacific").hover(
		function() {
			$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			//easternButton.toggleClass('selected');
		},
		function() {
			if (curr_secondary_loc == 'central_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary2.gif');
			} else
			if (curr_secondary_loc == 'eastern_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary1.gif');
			} else
			if (curr_secondary_loc == 'pacific_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			} else
			if (curr_secondary_loc == 'mountain_secondary') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary3.gif');
			} else
			if (curr_secondary_loc == 'pacific') {
				$("#IRECmap_secondary1").attr('src', '/wp-content/themes/IREC/images/IREC-map_secondary4.gif');
			}

		}
	);
	
});