$(function(){
	
	// Global Variables
	link = window.location.pathname.split("/")[2];
	sublink = window.location.pathname.split("/")[3];
	
	// Home Background
	if(link == "home")
	{
		$("body").css("background","#e6e6e6");
	}
	
	// Hover Event For The Menu
	$("div#nav li img").hover(
		function(){
			var title = $(this).attr('alt');
			$(this).attr("src", '/assets/image/nav/'+title+'_on.png');
		}, 
		function(){
			var title = $(this).attr('alt');
			$(this).attr("src", '/assets/image/nav/'+title+'_off.png');
			$("div#nav li."+link+" img").attr("src","/assets/image/nav/"+link+"_on.png"); // Reset Active Menu
	});
	
	// Hover Event For The SubMenu
	$("div#snav li img").hover(
		function(){
			var title = $(this).attr('alt');
			$(this).attr("src", '/assets/image/snav/'+title+'_on.png');
		}, 
		function(){
			var title = $(this).attr('alt');
			$(this).attr("src", '/assets/image/snav/'+title+'_off.png');
			
			// Reset Active
			$("div#snav li."+sublink+" img").attr("src","/assets/image/snav/"+sublink+"_on.png");
	});
	
	// Hover Event For the Sportsmenu
	$("div.sportmenu li img").hover(
		function(){
			var title = $(this).attr('alt');
			$(this).attr("src", '/assets/image/sportmenu/'+title+'_off.gif');
		}, 
		function(){
			var title = $(this).attr('alt');
			$(this).attr("src", '/assets/image/sportmenu/'+title+'_on.gif');
			
			// Reset Active
			$("div.sportmenu li."+sublink+" img").attr("src","/assets/image/sportmenu/"+sublink+"_off.gif");
	});
	
	// Active State For The Main Menu / Submenu	
	$("div#nav li."+link+" img").attr("src","/assets/image/nav/"+link+"_on.png"); // Check Menu
	
	if(sublink != ""){ // Check Submenu
		$("div#snav li."+sublink+" img").attr("src","/assets/image/snav/"+sublink+"_on.png");
		$("div.sportmenu li."+sublink+" img").attr("src","/assets/image/sportmenu/"+sublink+"_off.gif");
	}
	
	// Text Shadow for all classes with text-shadow
	/*
	$(".text-shadow").textShadow({
		color:   "#000",
		xoffset: "-2px",
		yoffset: "-2px",
		radius:  "3px",
		opacity: "85"
	});
	*/
});

function add_glow (id) {
	// Assumes that id of a div with position absolute with top and left defined
	document.getElementById(id).style.position = "relative";
	text = document.getElementById(id).innerHTML;
	document.getElementById(id).innerHTML = "";
	var shadcolor = "#111111";
	document.getElementById(id).appendChild( create_shadow (id, -2, -2, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id, -2,  0, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id, -2,  2, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id,  0, -2, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id,  0,  2, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id,  2, -2, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id,  2,  0, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id,  2,  2, shadcolor, text) );
	document.getElementById(id).appendChild( create_shadow (id,  0,  0, "#ffffff", text) );
}

function create_shadow (id, topmod, leftmod, color, text) {
	var shad = document.createElement('div');
	shad.style.position = "absolute";
	shad.style.marginTop = topmod +"px";
	shad.style.marginLeft = leftmod +"px";
	shad.style.color = color;
	shad.innerHTML = text;
	return shad;
//	shad.style.top = orig.style.top + topmod;
//	shad.style.left = orig.style.left + leftmod;
}

