// Author: Robert Barnes
// Copyright: 2008

// define bar title array
var titleName = new Array(8);
var z;
for(z=1; z<10; z++)
{
	titleName[z] = new Array(2);
}

titleName[1][0] = "Home";
titleName[1][1] = "index.htm";

titleName[2][0] = "About Us";
titleName[2][1] = "why.htm";

titleName[3][0] = "Birthdays";
titleName[3][1] = "birthday.htm";

titleName[4][0] = "Menu";
titleName[4][1] = "menu.htm";

titleName[5][0] = "Rules/Regulations";
titleName[5][1] = "rules.htm";

titleName[6][0] = "Map";
titleName[6][1] = "where.htm";

titleName[7][0] = "Photo Gallery";
titleName[7][1] = "photos.htm";

titleName[8][0] = "Events";
titleName[8][1] = "events.htm";

titleName[9][0] = "Summer Hours";
titleName[9][1] = "summer.htm";

/*
titleName[5][0] = "Gift Certificates";
titleName[5][1] = "gifts.htm";

titleName[6][0] = "Events";
titleName[6][1] = "events.htm";

titleName[7][0] = "Rules/Regulations";
titleName[7][1] = "rules.htm";

titleName[8][0] = "Map";
titleName[8][1] = "where.htm";

titleName[9][0] = "Photo Gallery";
titleName[9][1] = "photos.htm";

titleName[10][0] = "Summer Hours";
titleName[10][1] = "summer.htm";
*/

// set default value for selection
var mSelection = 1;

// set default view horz or vert
var bttnOrientation = "horz";

// get query string - look for "x" then split name and variable  ie: x=3
function getQueryVariable(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable)
		{
			mSelection = pair[1];
		}
	} 
}

// show selected bar
function goBar(menuID)
{
	var ab;
	ab = document.getElementById(menuID);
	ab.style.background = "#364C7E";
	ab.style.border = "4px inset #006699";
}

// show unseleted bars
function backBar(menuID)
{
	var ab;
	ab = document.getElementById(menuID);
	ab.style.background = "#364C7E";
	ab.style.border = "4px outset #006699";
}

// do navigation once selected
function navDir(navID)
{
	mSelection = navID;
	if (mSelection == 1)
	{
		location.href="index.htm";
	}
	else
	{
		location.href=titleName[mSelection][1] + "?x=" + mSelection;
	}
}

// onload initialize
function init()
{
// Initilize the outset look on the bar
	var x;
	var y;

	for (x = 1; x < titleName.length; x++)
	{
		y = "menu" + x;
		goBar(y);
		backBar(y);
		goBar("menu" + mSelection);
	}
}

// create menu bar and display it
function menuSel()
{

	var x;
	var tdWidth = 0;
	var tdAmount = 0;
	if (mSelection == "" || mSelection == null)
	{
		mSelection = 1;
	}

	for (x = 1; x < titleName.length; x++)
	{
		if (tdWidth < titleName[x][0].length + 100)
		{
				tdWidth = titleName[x][0].length + 100;
		}
	}
	if (bttnOrientation == "horz")
	{
		document.write("<TABLE  BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#364C7E' BORDERCOLOR='#004080' ALIGN='center'>");
			document.write("<TR>");
	}
	else
	{
		document.write("<TABLE  BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#364C7E' BORDERCOLOR='#004080' ALIGN='left'>");
	}
	
	for (x = 1; x < titleName.length; x++)
	{
		if (bttnOrientation == "vert")
		{
			document.write("<TR>");
		}
		document.write("<TD WIDTH='" + tdWidth + "' ALIGN='center' ID='menu" + x + "'>");
		if (mSelection == x)
		{
			document.write("<FONT COLOR='#00FF00'><STRONG>" + titleName[x][0] + "</STRONG></FONT>");
		}
		else
		{
			document.write("<A HREF='#' CLASS='bar' onclick='navDir(" + x + ");' onmouseover=" + String.fromCharCode(34) + " window.status='" +  titleName[x][0] + "'; return true" + String.fromCharCode(34) + " onmouseout=" + String.fromCharCode(34) + "window.status=''; return true" + String.fromCharCode(34) + ">");
			document.write("<STRONG>" + titleName[x][0] + "</STRONG>");
			document.write("</A>");
		}
		document.write("</TD>");
		if (bttnOrientation == "vert")
		{
			document.write("</TR>");
		}
	}
	if (bttnOrientation == "horz")
	{
		document.write("</TR>");
	}
	document.write("</TABLE>");

}

// get users screen width & height
function setDisp()
{
	var winW = 0;
	var winH = 0;
	
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape")
		{
			winW = window.innerWidth - 40;
			winH = window.innerHeight - 40;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW = document.body.offsetWidth - 40;
			winH = document.body.offsetHeight - 40;
		}
	}
	document.getElementById("table1").style.width = winW;
	document.getElementById("table2").style.width = winW - 160;
	
}

// highlight buttons when mouse is over
function highlightButton(s)
{
	if ("INPUT"==event.srcElement.tagName)
	{
		event.srcElement.className=s
	}
}

// display time and date
function timeClock()
{
	// set the delay to 1000 = 1 sec before calling itself
	setTimeout("timeClock()",1000);
	
	// Set the current date and arrays for the day of the week and the month name
	var today = new Date();
	var dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	var monthName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
	
	// Set variables for the current month, day, year and day of the week
	var strMonth = today.getMonth();
	var strYear = today.getYear();
	var strDay = today.getDate();
	var strDayOfWeek = today.getDay();
	
	// set variables for the hours, minutes, and seconds
	var strHours = today.getHours();
	var strMinutes = today.getMinutes();
	var strSeconds = today.getSeconds();
	
	// create a second variable for leading zeros as arrays use no leading zeros
	var zMonth = strMonth;
	var zDay = strDay;
	var zYear = strYear;
	
	var zHours = strHours;
	var zMinutes = strMinutes;
	var zSeconds = strSeconds;
	
	/*	create the various variables for a quotation mark,
		ending names for the day of the week,
		the conversion for the 12 hr clock,
		and the am or pm string.
	*/
		
	var Quote = '"';
	var DOW;
	var hrs12;
	var ampm;

	// calculate the 12 hour clock and set either am or pm.
	if (strHours > 12) {
		hrs12 = (strHours - 12);
		ampm = " pm";
	}
	else if 
		(strHours == 12) {
		hrs12 = strHours;
		ampm = " pm";
	}
	else {
		hrs12 = strHours;
		ampm = " am";
	}

	if (strHours == 0 && ampm == " am")
	{
		hrs12 = 12;
	}
					
	// place leading zeros if the values are less than 10 for the hours, minutes, and seconds
	if (zHours < 10) {
		zHours = "0" + zHours;
	}
	if (zMinutes < 10) {
		zMinutes = "0" + zMinutes;
	}
	if (zSeconds < 10) {
		zSeconds = "0" + zSeconds;
	}
	
	
	// place leading zeros if the values are less than 10 for the month, day, and year
	if (zMonth < 10) {
		zMonth = "0" + zMonth;
	}
	if (zDay < 10) {
		zDay = "0" + zDay;
	}
	if (zYear < 10) {
		zYear = "0" + zYear;
	}
	
	//	correct the 2 digit year by adding 1900 to it.
	// first convert to string due to different browsers
	var tempYear = "'" + zYear + "'";
	
	// check the length.  If less than 4 digits, then add 1900 to it.
	if (tempYear.length < 6) {
		zYear = 1900 + zYear;
	} 
	
	// set variable for the ending part of a number ie: 1st, 2nd, 3rd, 4th.
	if (strDayOfWeek == 1) {
		DOW = "st";
	}
	else if (strDayOfWeek == 2) {
		DOW = "nd";
	}
	else if (strDayOfWeek == 3) {
		DOW = "rd";
	}
	else {
		DOW = "th";
	}
	document.form1.datebox.value=(dayName[strDayOfWeek] + ", " + monthName[strMonth] + " " + zDay + " " + zYear);
	document.form1.datebox.size=document.form1.datebox.value.length;
	document.form1.timebox12.value=(hrs12 + ":" + zMinutes + ":" + zSeconds + ampm);
	document.form1.timebox12.size=document.form1.timebox12.value.length;
	//document.form1.timebox24.value=(" or" + zHours + ":" + zMinutes + ":" + zSeconds + " hrs local time");
}


