// JavaScript Document
var currentMenuID;
var 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;
	}
}

// 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);
}

// Hide the navigation menu
function hideAllMenus()
{
	// Hide the sub menu when the mouse leaves
	var completeMenuID = "";
	
	var subMenuList = [
					 "club",
					 "memberinfo",
					 "news",
					 "rides",
					 "racing"
					 ]

	for (var i = 0; i < subMenuList.length; i++)
	{
		completeMenuID = subMenuList[i] + "SubMenu";
		myHideMenu(completeMenuID);
	}

}

// 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);
	}
}

// Image rollover function
function doRollOver(imageToSwap, swapType)
{
	var oldImage;
	var newImage;
	
	if (swapType == 1) // 1 means the mouse is rolling over
	{
		oldImage = "btn_off_" + imageToSwap + ".png";
		newImage = "btn_on_" + imageToSwap + ".png";
	}
	else // 2 or anything else means the mouse is leaving
	{
		oldImage = "btn_on_" + imageToSwap + ".png";
		newImage = "btn_off_" + imageToSwap + ".png";
	}
	
	document.getElementById(imageToSwap + "Btn").src = "/studentorg/cycling/_format/images/" + newImage;
}

// Pre-load the rollover images
function preloadImages()
{
	// The list of images we need to pre-load
	var imageList = [
					 "home",
					 "club",
					 "clubabout",
					 "clubmission",
					 "clubfaqs",
					 "memberinfo",
					 "membersmembership",
					 "membersmembers",
					 "memberblogs",
					 "membersofficers",
					 "membersclothing",
					 "news",
					 "newsarchive",
					 "newsevents",
					 "photos",
					 "rides",
					 "ridesfavorites",
					 "ridesscheduled",
					 "racing",
					 "racingabout",
					 "racingschedule",
					 "racingschedulecross",
					 "racingschedulemount",
					 "racingscheduleroad",
					 "racingscheduletrack",
					 "sponsors",
					 "contacts",
					 "links",
					 "login",
					 "logoff",
					 "admin",
					 "documents"
					 ]

	for (var i = 0; i < imageList.length; i++)
	{
		(new Image(120, 15)).src = "/studentorg/cycling/_format/images/btn_on_" + imageList[i] + ".png";
	}
}

// Creates a formatted pop-up window
function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

/**********************************************************
 **********************************************************
 **********************************************************
 **********************************************************
	
	// **********************************************
	// 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]+'">');
	}

**********************************************************
**********************************************************
**********************************************************
**********************************************************/