// execute after the page loads
$(window).load(function(){


	// navigation will only show if JS is available (if the user doesn't have JS it wouldn't work anyway)
	$('#nav li').append(function(){
		var q = $(this).attr("BkImage");
		var BkImage = q.split(",");
		var s = $(this).attr("ChildBkImage");
		var ChildImage = s.split(",");
				
		var $app;
		$(this).attr('title');
		$app = '<div class="pop" style="background-image: url(' + BkImage[0] + ')"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="pop" valign="middle">' + $(this).attr('title') + '</td></tr></table><i style="background-image: url(' + ChildImage[0] + ')"></i> </div>';
		$(this).removeAttr('title'); // now remove title so it doesn't show as tooltip
		return $app;
	});

	$('#nav li').mouseenter(function(){ 
		var hColor = $(this).attr("HoverColor");
		var d = $('a', this).attr("href");
		var menuURL = d.split(",");
		
		if( $(this).attr('targetURL') == '1' ) {
			$('a', this).attr("target", "_blank");
		} else {
			$('a', this).attr("target", "_parent");
		}
		$('#MainMenuLink', this).attr("href", menuURL[0]);
		$('a', this).css('color',hColor);
		$('a', this).css('margin','0 0 16px');
		$(this).children('div').show(); 
		
		})
	.mouseleave(function(){
	 var fColor = $(this).attr("fontColor");
		$('a', this).css('color',fColor);
	 $(this).children('div').hide(); 
	 
	 });
	 
/*
	// set up nav to be fixed with JS, so if user doesn't have JS the nav will still work
	var $nav = $('#bd > .nav');

	$nav.css('position', 'fixed');
	$nav.css('height', '550px');

	var $footer_top = $('.foliage').offset().top;
	var $nav_bottom = $nav.offset().top + $nav.height();

	$(window).scroll(function () {
		console.log($footer_top);
		console.log($nav_bottom);
		
		if( $nav_bottom >= $footer_top ){
			$nav.css('position', 'absolute');
			$nav.css( 'top', '100' );
		}
	});
	
*/
}); // end windowload
