// BEGIN GLOBAL FUNCTIONS & VARIABLES
var globalPath = "";
var menuItemFontFamily = "sans-serif";
var menuItemFontSize = "9pt";
var menuItemFontStyle = "normal";
var menuItemFontWeight = "normal";
var menuItemFg = "#a00";
var menuItemBg = "white";
var menuItemBorderWidth = "2px";
var menuItemBorderStyle = "solid";
var menuItemBorderColor = "#a00";
var menuItemHighlightFg = "white";
var menuItemHighlightBg = "#086";
var menuItemHighlightBorderStyle = "solid";
var menuItemHighlightBorderColor = "#a00";
var menuItemHorizontalPad = "0px";
var menuItemVerticalPad = "4px";

var menuBg = "transparent";
var menuBorderWidth = "0px";
var menuBorderStyle = "solid";
var menuBorderColor = "#900";

var menuBarBorder = "1pt solid #a03";
var menuBarBg = "#a03";
var menuBarFg = "white";
var menuBarFontFamily = "sans-serif";
var menuBarFontSize = "10pt";
var menuBarFontStyle = "normal";
var menuBarFontWeight = "bold";
var menuBarHighlightBorder = "1pt solid #a03";
var menuBarHighlightBg = "#086";
var menuBarHighlightFg = "white";
var menuBarSpacing = "10px";

function setGlobalPath(path)
{
	if(arguments.length != 1)
	{
		alert("Menus.js has detected an illegal path.\n" +
			"reset the Global Path to a valid protocol.");
		return;
	}

	if(path.indexOf("http://") == -1 && path.indexOf("file:///") == -1)
	{
		var ok = confirm("Menus.js has detected the protocol " + path + 
			".\nClick Ok to set the Global Path, or \nCancel to abort.");

		if(!ok) return;
	}

	if(path != null & 
		path != "undefined" & 
		path.length > 0 &
		path.charAt(path.length-1) != '/')
	{
		path += "/";
	}

	globalPath = path;
}
function highlight(menuItem)
{
	menuItem.style.color = menuItemHighlightFg;
	menuItem.style.backgroundColor = menuItemHighlightBg;
	menuItem.style.borderColor = menuItemHighlightBorderColor;
	menuItem.style.borderStyle = menuItemHighlightBorderStyle;
}
function unhighlight(menuItem)
{
	menuItem.style.color = menuItemFg;
	menuItem.style.backgroundColor = menuItemBg;
	menuItem.style.borderColor = menuItemBorderColor;
	menuItem.style.borderStyle = menuItemBorderStyle;
}
function menuBrighten(menuToBrighten, mId)
{
	menuToBrighten.style.backgroundColor = menuBarHighlightBg;
	menuToBrighten.style.border = menuBarHighlightBorder;
	menuToBrighten.style.color = menuBarHighlightFg;
	showMenu(mId);
}
function menuDefault(menuToDefault, mId)
{
	menuToDefault.style.backgroundColor = menuBarBg;
	menuToDefault.style.border = menuBarBorder;
	menuToDefault.style.color = menuBarFg;
	hideMenu(mId);
}
function showMenu(menuToShow)
{
	var menu = document.getElementById(menuToShow);
	menu.style.visibility = "visible";
}
function hideMenu(menuToHide)
{
	var menu = document.getElementById(menuToHide);
	menu.style.visibility = "hidden";
}
function changePageTo(changePageTo)
{
	if(changePageTo.indexOf(".html") == -1 && changePageTo.indexOf(".htm") == -1)
	{
		var message = "Menus.js has simulated a page change\n";
		message += "The " + changePageTo.toUpperCase() + " link is not set...";

		window.alert(message);
	}
	else
	{
		window.location.href = globalPath + changePageTo;
	}
}
//END GLOBAL FUNCTIONS






/*
 * BEGIN MenuItem OBJECT
 *
 *
 * Uses a String for a Label
 * Uses a Strin for a Link
 *
 *
 */
function MenuItem(miLabel, miHref)
{
	this.menuItemLabel = miLabel;			// String
	this.menuItemHref = miHref;			// String
}
// END MenuItem OBJECT






/*
 * BEGIN MENU OBJECT
 *
 * Uses several MenuItem Instances for a drop-doen menu
 *
 * Use document.write() to call Menu.getMenuHtml() if using 
 * a Menu without a MenuBar.
 *
 * 
 */
function Menu(mLabel)
{
	this.menuLabel = mLabel;			// String
	this.menuID = mLabel.toLowerCase();		// String
	this.menuItems = null;				// MenuItem[]
}
function addMenuItem(miLabel, miHref)
{
	var menuItem = new MenuItem(miLabel, miHref);

	if(this.menuItems == null)
	{
		this.menuItems = new Array(1);
		this.menuItems[0] = menuItem;
		return;
	}

	this.menuItems[this.menuItems.length] = menuItem;
}
function getMenuHtml()
{
	if(this.menuItems == null)
	{
		return;
	}

	mHtml = "<table id='" + this.menuID + "' ";
	mHtml += "onmouseout='hideMenu(this)' ";
	mHtml += "style='";
	mHtml += "position: absolute; ";
	mHtml += "visibility: hidden; ";
	mHtml += "background-color: " + menuBg + "; ";
	mHtml += "border-width: " + menuBorderWidth + "; ";
	mHtml += "border-style: " + menuBorderStyle + "; ";
	mHtml += "border-color: " + menuBorderColor + "; ";
	mHtml += "border-spacing: " + menuItemHorizontalPad + " " + menuItemVerticalPad + "; ";
	var leftMargin = parseInt(menuBarSpacing) + 2;
	mHtml += "margin-left: -" + leftMargin + "px;'>";
	for(var i = 0; i < this.menuItems.length; i++)
	{
		mHtml += "<tr>";
		mHtml += "<td ";
		mHtml += "style='cursor: pointer; ";
		mHtml += "background-color: " + menuItemBg + "; ";
		mHtml += "font-family: " + menuItemFontFamily + "; ";
		mHtml += "font-size: " + menuItemFontSize + "; ";
		mHtml += "font-style: " + menuItemFontStyle + "; ";
		mHtml += "font-weight: " + menuItemFontWeight + "; ";
		mHtml += "color: " + menuItemFg + "; ";
		mHtml += "padding-top: 1px; ";
		mHtml += "padding-bottom: 2px; ";
		mHtml += "padding-left: 10px; ";
		mHtml += "padding-right: 10px; ";
		mHtml += "border-width: " + menuItemBorderWidth + "; ";
		mHtml += "border-style: " + menuItemBorderStyle + "; ";
		mHtml += "border-color: " + menuItemBorderColor + ";' ";
		mHtml += "onmouseover='highlight(this);' ";
		mHtml += "onmouseout='unhighlight(this);' ";
		mHtml += "onclick='changePageTo(\"" + this.menuItems[i].menuItemHref + "\");'>";
		mHtml += this.menuItems[i].menuItemLabel;
		mHtml += "</td>";
		mHtml += "</tr>";
	}
	mHtml += "</table>";

	return mHtml;
}
Menu.prototype.addMenuItem = addMenuItem;
Menu.prototype.getMenuHtml = getMenuHtml;
// END MENU OBJECT






/*
 * BEGIN MenuBar OBJECT
 * 
 * Uses several Menu Objects
 *
 * MenuBar.createMenus() can be called without document.write().
 *
 *
 */
function MenuBar()
{
	this.menus = null;				// Menu[]
}
function addMenu(menuToAdd)
{
	if(this.menus == null)
	{
		this.menus = new Array(1);
		this.menus[0] = menuToAdd;
		return;
	}

	this.menus[this.menus.length] = menuToAdd;
}
function createMenus()
{
	if(this.menus == null || this.menus.length == 0)
	{
		return;
	}

	mbHtml = "<table align='center'>";
	mbHtml += "<tbody>";
	mbHtml += "<tr>"
	for(var i = 0; i < this.menus.length; i++)
	{
		mbHtml += "<td style='";
		mbHtml += "background-color: " + menuBarBg + "; ";
		mbHtml += "color: " + menuBarFg + "; ";
		mbHtml += "cursor: default; ";
		mbHtml += "border: " + menuBarBorder + "; ";
		mbHtml += "font-family: " + menuBarFontFamily + "; ";
		mbHtml += "font-size: " + menuBarFontSize + "; ";
		mbHtml += "font-style: " + menuBarFontStyle + "; ";
		mbHtml += "font-weight: " + menuBarFontWeight + "; ";
		mbHtml += "padding-left: " + menuBarSpacing + "; ";
		mbHtml += "padding-right: " + menuBarSpacing + ";' ";
		mbHtml += "onmouseover='menuBrighten(this, \"" + this.menus[i].menuID + "\")' ";
		mbHtml += "onmouseout='menuDefault(this, \"" + this.menus[i].menuID + "\")'>";
		mbHtml += this.menus[i].menuLabel + "<br>";
		mbHtml += this.menus[i].getMenuHtml();
		mbHtml += "</td>";

		/*
		 * if(i < this.menus.length - 1)
		 * {
		 *	mbHtml += "<td width='" + menuBarSpacing + "'></td>";
		 * }
		 */
	}
	mbHtml += "</tr>";
	mbHtml += "</tbody>";
	mbHtml += "</table>";

	document.write(mbHtml);
}
MenuBar.prototype.addMenu = addMenu;
MenuBar.prototype.createMenus = createMenus;
// END MenuBar Object






/*
 * BEGIN NavBar Object
 *
 * Uses Single MenuItems in a row
 *
 *
 */
function NavBar()
{
	this.navItems = null;				// MenuItem[]
}
function addNavItem(niLabel, niHref)
{
	var navItem = new MenuItem(niLabel, niHref);

	if(this.navItems == null)
	{
		this.navItems = new Array(1);
		this.navItems[0] = navItem;
		return;
	}

	this.navItems[this.navItems.length] = navItem;
}
function getNavHtml()
{
	var nHtml = "<table align='center'>";
	nHtml += "<tr>";

	for(var i = 0; i < this.navItems.length; i++)
	{
		nHtml += "<td "
		nHtml += "style='cursor: pointer;' ";
		nHtml += "onclick='changePageTo(\"" + this.navItems[i].menuItemHref + "\");'>";
		nHtml += this.navItems[i].menuItemLabel;
		nHtml += "</td>";
	}

	nHtml += "</tr>";
	nHtml += "</table>";

	document.write(nHtml);
}
NavBar.prototype.addNavItem = addNavItem;
NavBar.prototype.getNavHtml = getNavHtml;
//END NavBar Object






/*
 * The space below is dedicated to creating editing and maintaing your Menu System.
 * Keep your TITLES, LABELS, LINKS updated here...
 *
 *
 *
 */


// override default values...
menuBarSpacing = "40px";
//setGlobalPath("http://www.koala-pierrot.com");



// create menus, then add menuItems...
var homeMenu = new Menu("Home");
homeMenu.addMenuItem("<nobr>Home Page</nobr>", "index.html");
homeMenu.addMenuItem("<nobr>About Us</nobr>", "about.html");
homeMenu.addMenuItem("<nobr>Services & Portraiture</nobr>", "service.html");
homeMenu.addMenuItem("<nobr>Contact Us</nobr>", "contact.html");
homeMenu.addMenuItem("Links", "link.html");
homeMenu.addMenuItem("<nobr>Artwork Label Creator</nobr>", "labels/index.html");

var yumiMenu = new Menu("Yumi");
yumiMenu.addMenuItem("<nobr>Recent Work</nobr>", "yumiRecent.html");
yumiMenu.addMenuItem("<nobr>Past Works</nobr>", "yumiPast.html");
yumiMenu.addMenuItem("<nobr>Art Exhibitions</nobr>", "yumiShows.html");
yumiMenu.addMenuItem("<nobr>Art Demos/Lectures etc</nobr>", "yumiDemos.html");
yumiMenu.addMenuItem("<nobr>Public Art</nobr>", "public_art.html");
yumiMenu.addMenuItem("Biography", "yumiBio.html");
yumiMenu.addMenuItem("Brochure 2011", "brochure_full.html");
yumiMenu.addMenuItem("<nobr>Gallery 21 2010</nobr>", "G21/2010/index.html");
yumiMenu.addMenuItem("<nobr>Gallery 21 2011</nobr>", "G21/2011/index.html");

var wesMenu = new Menu("Wesley");
wesMenu.addMenuItem("<nobr>Recent Work</nobr>", "pierrotRecent.html");
wesMenu.addMenuItem("<nobr>Past Works</nobr>", "pierrotPast.html");
wesMenu.addMenuItem("<nobr>Upcoming Events</nobr>", "pierrotEvents.html");

var workshopMenu = new Menu("<nobr>Art Workshops</nobr>");
workshopMenu.addMenuItem("<nobr>Wesley's Workshop</nobr>", "workshop/workshop_main.html");

var gameMenu = new Menu("Games!");
gameMenu.addMenuItem("<nobr>Rubik's Cube</nobr>", "RCube/index.html");


// create menuBar and add menus...
var menubar = new MenuBar();
menubar.addMenu(homeMenu);
menubar.addMenu(yumiMenu);
menubar.addMenu(wesMenu);
menubar.addMenu(workshopMenu);
menubar.addMenu(gameMenu);


// write menus to document...
menubar.createMenus();










