// JavaScript Document

$(document).ready(function() {
	var map = $("#map");
	$("dl dt:not(.non), dl dd:not(.non)", map).hover(function() {
		var index = $("dl", map).index($(this).parent());
		rollOver(index);
	}, function() {
		var index = $("dl", map).index($(this).parent());
		rollOut(index);
	});
	$("ul li:not(.non)", map).hover(function() {
		var index = $("li", map).index($(this));
		listRollOver(index);
	}, function() {
		var index = $("li", map).index($(this));
		listRollOut(index);
	});
	function rollOver(index) {
		var uIndex = ( index == 3 ) ? 0 : index;
		$("dl dt img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('_off', '_none') );
		} );
		$("dl dd img, ul li img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('.jpg', '_none.jpg') );
		} );
		$("dl dt:eq("+index+") img", map).attr("src", $("dl dt:eq("+index+") img", map).attr("src").replace('_none', '_on') );
		$("dl dd:eq("+index+") img, ul li:eq("+uIndex+") img", map).each(function() {
			$(this).attr("src", $(this).attr("src").replace('_none.jpg', '.jpg') );
		} );
	}
	function rollOut(index) {
		$("dl dt img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('_none', '_off') );
		} );
		$("dl dd img, ul li img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('_none.jpg', '.jpg') );
		} );
		$("dl dt:eq("+index+") img", map).attr("src", $("dl dt:eq("+index+") img", map).attr("src").replace('_on', '_off') );
	}
	function listRollOver( index ) {
		$("dl dt img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('_off', '_none') );
		} );
		$("dl dd img, ul li img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('.jpg', '_none.jpg') );
		} );
		
		$("dl dt:eq("+index+") img", map).attr("src", $("dl dt:eq("+index+") img", map).attr("src").replace('_none', '_on') );
		$("dl dd:eq("+index+") img, ul li:eq("+index+") img", map).each(function() {
			$(this).attr("src", $(this).attr("src").replace('_none.jpg', '.jpg') );
		} );
		if( index == 0 ) {
			var index = 3;
			$("dl dt:eq("+index+") img", map).attr("src", $("dl dt:eq("+index+") img", map).attr("src").replace('_none', '_on') );
			$("dl dd:eq("+index+") img, ul li:eq("+index+") img", map).each(function() {
				$(this).attr("src", $(this).attr("src").replace('_none.jpg', '.jpg') );
			} );
		}
	}
	function listRollOut( index ) {
		$("dl dt img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('_none', '_off') );
		} );
		$("dl dd img, ul li img", map).each( function() {
			$(this).attr("src", $(this).attr("src").replace('_none.jpg', '.jpg') );
		} );
		$("dl dt:eq("+index+") img", map).attr("src", $("dl dt:eq("+index+") img", map).attr("src").replace('_on', '_off') );
		if( index == 0 ) {
			index = 3;
			$("dl dt:eq("+index+") img", map).attr("src", $("dl dt:eq("+index+") img", map).attr("src").replace('_on', '_off') );
		}
	}
});