var root_page = this.location.pathname.replace(/^\/(index|s-test)\.(php|htm|html)/i, "/") == "/" ? true : false;
var forum_page = this.location.pathname.toLowerCase().indexOf("/interact") === 0 ? true : false;
var filename = this.location.pathname.substr(this.location.pathname.lastIndexOf('/') + 1);
var navLinkClasses = ["debrief", "research", "interact", "launches", "commlink"];

function display_navlink()
{
	if (navLinkClasses.length > 0)
	{
		$("ul.navigation .nav_" + navLinkClasses[0] + " ").fadeIn(150, function() { navLinkClasses.shift(); display_navlink(); });
	}
	else
	{
		//display_main_content();
	}
}
function display_navlinks()
{
	if ($("ul.navigation li div").css("visibility") == "hidden")
	{
		$("ul.navigation div").hide().css({"visibility" : "visible"});
		display_navlink();
	}
}

function display_main_content()
{
	if ($("div.main").css("visibility") == "hidden")
	{
		$("div.main,div.page_footer").hide().css({"visibility":"visible"}).slideDown('fast');
	}
	else if (root_page)
	{
		$("#large_logo").animate({"width":"455px", "height": "80px", "opacity": "100%"}, "slow");
	}
}
function register_navlink_animation()
{
	$("ul.navigation div").mouseenter(function(){
		$(this).animate({marginLeft:"4px"}, 50);
	});
	$("ul.navigation div").mouseleave(function(){
		$(this).animate({marginLeft:"0"}, 50);
	});
}
function register_thumbnail_effect()
{
	var w_pad = 5, h_pad = 10;
	$("ul.thumb li").each(function(index) {
			var img = $(this).find('img').eq(0);
			var w = ($(this).data('w')) ? $(this).data('w') : parseInt($(img).attr('width'));
			var h = ($(this).data('h')) ? $(this).data('h') : parseInt($(img).attr('height'));
			$(this).css('width', (w + w_pad) + 'px').css('height', (h + h_pad) + 'px');
			$(this).data('w', w);
			$(this).data('h', h);
		}
	);
	
	$("ul.thumb li").hover(function() {
		var img = $(this).find('img').eq(0);
		var w = ($(this).data('w')) ? parseInt($(this).data('w')) : parseInt($(img).attr('width'));
		var h = ($(this).data('h')) ? parseInt($(this).data('h')) : parseInt($(img).attr('height'));

		$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
		$(img).addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
			.animate({
				marginTop: '-' + (h + w_pad) + 'px', /* The next 4 lines will vertically align this image */ 
				marginLeft: '-' + (w + h_pad) + 'px',
				top: '50%',
				left: '0',
				width: (w * 2) + 'px', /* Set new width */
				height: (h * 2) + 'px' /* Set new height */
				//padding: '20px'
			}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
	
		} , function() {
		var img = $(this).find('img').eq(0);
		var w = ($(this).data('w')) ? $(this).data('w') : parseInt($(img).attr('width'));
		var h = ($(this).data('h')) ? $(this).data('h') : parseInt($(img).attr('height'));

		$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
		$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
			.animate({
				marginTop: '0', /* Set alignment back to default */
				marginLeft: '0',
				top: '0',
				left: '0',
				width: w + 'px', /* Set width back to default */
				height: h + 'px' /* Set height back to default */
				//padding: '5px'
			}, 400);
	});
}

function end_of_page_javascript()
{
	register_thumbnail_effect();
	display_main_content();
}

var css = "";
if (!forum_page || !filename || filename == 'index.php')
{
	 css = "ul.navigation li div{visibility:hidden;}\n";
}
if (root_page)
{
	css += "#large_logo{width:1px;height:1px;display:none;}\n";
	css += "div.main {background-image:none;background-color:transparent;}\n";
	css += "div.page_footer {visibility:hidden;}\n"
}
else //if (!forum_page)
{
	css += "div.main, div.page_footer{visibility:hidden;}\n";
}
if (css)
{
	document.write("<style type='text/css'>\n" + css + "<\/style>");
}
