﻿		$(document).ready(function(){
			// "Select" the level-0 menu if one of its children is selected <-- #navContainer menu
			$("#navContainer .selected").parents().filter(".lv0").addClass("selected");
			
			// Change level-0 "bottom border" when selected <-- #navContainer menu
			$("#navContainer .selected").next().css("border-top-color","#7d7d7d");
			
			// Top bar on hover - change background color
			$(".topLink a").hover( function() {
					$(this).parent().css("background-color","#69ac3a");
				}, function() {
					$(this).parent().css("background-color","#9dc968");
				}
			);
				
			
			// Change the image of hoverable images
			$(".imgHoverable").hover( function() {
					var hoverImg = HoverImgOf($(this).attr("src"));
					$(this).attr("src", hoverImg);
				}, function() {
					var normalImg = NormalImgOf($(this).attr("src"));
					$(this).attr("src", normalImg);
				}
			);
			
		});
		
		function HoverImgOf(filename)
		{
			var re = new RegExp("(.+)\\.(gif|png|jpg)", "g");
			return filename.replace(re, "$1_hover.$2");
		}
		function NormalImgOf(filename)
		{
			var re = new RegExp("(.+)_hover\\.(gif|png|jpg)", "g");
			return filename.replace(re, "$1.$2");
		}

