var currentMenuID;
var timeOutID;

// Make the navigation menu visible
function showMenu(menuID)
{
	// Make the sub menu visible when the mouse enters the parent menu
	var completeMenuID = menuID + "SubMenu";

	if (document.getElementById(completeMenuID).style.visibility == "visible")
	{
		cancelHideMenu();
	}
	
	document.getElementById(completeMenuID).style.visibility = "visible";
}

// Hide the navigation menu
function hideMenu(menuID)
{
	// Hide the sub menu when the mouse leaves
	var completeMenuID = menuID + "SubMenu";
	currentMenuID = completeMenuID;
	
	// First pause; we don't want to make it invisible if the mouse entered the sub-menu
	timeOutID = window.setTimeout("myHideMenu(currentMenuID);", 10);
}

// Helper function for hiding the nav menu
function myHideMenu(menuID)
{
	// This is a helper function that does the actual menu hiding
	document.getElementById(menuID).style.visibility = "hidden";	
}

// Cancel the timeout on the menu hide
function cancelHideMenu()
{
	// Cancel making the sub menu invisible
	if (timeOutID != undefined)
	{
		window.clearTimeout(timeOutID);
	}
}

// Center the content in the browser window
function moveContent()
{
	if (screen.width > 800)
	{
		var contentOffset = String(Math.floor((screen.width - 800) / 2));
		document.getElementById("wholePage").style.left = contentOffset;
	}
}

// Image rollover function
function doRollOver(imageToSwap, swapType)
{
	var oldImage;
	var newImage;
	
	if (swapType == 1) // 1 means the mouse is rolling over
	{
		oldImage = "bttn_" + imageToSwap + "-off.gif";
		newImage = "bttn_" + imageToSwap + "-on.gif";
	}
	else // 2 or anything else means the mouse is leaving
	{
		oldImage = "bttn_" + imageToSwap + "-on.gif";
		newImage = "bttn_" + imageToSwap + "-off.gif";
	}
	
	document.getElementById(imageToSwap + "Btn").src = "https://www.uwsp.edu/stuorg/mntnbike/images/" + newImage;
}

// Pre-load the rollover images
function preloadImages()
{
	// The list of images we need to pre-load
	var imageList = ["club",
					 "forum",
					 "home",
					 "links",
					 "media",
					 "members",
					 "membership",
					 "news",
					 "officers",
					 "photos",
					 "racing",
					 "sponsors",
					 "wallpaper"]

	for (var i = 0; i < imageList.length; i++)
	{
		(new Image(100, 25)).src = "https://www.uwsp.edu/stuorg/mntnbike/images/bttn_" + imageList[i] + "-on.gif";
	}
}

// **********************************************
// Added By: Charlie Lukas
// Date:  April 13, 2005
// Use:  This block of code will be used to
//		 cycle through a set of random images.
//		 These random images will be the topBorder
//		 image.
// **********************************************

// ==============================================
// Copyright 2003 by jsCode.com
// Source: jsCode.com
// Author: etLux
// Free for all; but please leave in the header.
// ==============================================

// Set up the image files to be used.
var theImages = new Array() // do not change this

// To add more image files, continue with the
// pattern below, adding to the array. Rememeber
// to increment the theImages[x] index!

theImages[0] = '/images/topBorder00.jpg'
theImages[1] = '/images/topBorder01.jpg'
theImages[2] = '/images/topBorder02.jpg'
theImages[3] = '/images/topBorder03.jpg'
theImages[4] = '/images/topBorder04.jpg'
theImages[5] = '/images/topBorder05.jpg'
theImages[6] = '/images/topBorder06.jpg'
theImages[7] = '/images/topBorder07.jpg'
theImages[8] = '/images/topBorder08.jpg'
theImages[9] = '/images/topBorder09.jpg'

// ======================================
// do not change anything below this line
// ======================================

var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
	preBuffer[i] = new Image()
	preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
	document.write('<img src="'+theImages[whichImage]+'">');
}
