/*************************************************
* Author: Will Steinmetz
* Date: 04/12/08
* Name: partmenu.js
*
* Description: This script contains the functions
* for displaying part menus
*************************************************/

var panels = new Array();
var currentPanel = new Array();
var menu = new Array();
var header = new Array();
var color = new Array();
var overColor = new Array();

function registerElements(newPanels, newMenu, newHeader, newColor, newOverColor, section)
{
	panels[section] = new Array();
	for (var i = 0; i < newPanels.length; i++)
	{
		panels[section][i] = newPanels[i];
	}
	currentPanel[section] = panels[section][0];
	menu[section] = newMenu;
	header[section] = newHeader;
	color[section] = newColor;
	overColor[section] = newOverColor;
}

function myLocation(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
		return({top: curtop, left: curleft});
	}
}

function showOptionsMenu(section)
{
	var here = myLocation(header[section]);
	header[section].style.backgroundImage = 'url(images/part_bars/p_bar_' + overColor[section] + '.jpg)';
	here.top += 30;
	here.left -= 27;
	menu[section].style.left = here.left + "px";
	menu[section].style.top = here.top + "px";
	menu[section].style.display = "";
}

function hideOptionsMenu(section)
{
	//header[section].style.backgroundImage = 'url(images/part_bars/p_bar_' + color[section] + '.jpg)';
	//menu[section].style.display = "none";
	for(var index in header)
	{
		header[index].style.backgroundImage = 'url(images/part_bars/p_bar_' + color[index] + '.jpg)';
		menu[index].style.display = "none";
	}
}

function swapMenuPanels(newPanel, section)
{
	currentPanel[section].style.display = "none";
	panels[section][newPanel].style.display = "";
	currentPanel[section] = panels[section][newPanel];
}

function swapPanelsHideMenu(newPanel, section)
{
	swapMenuPanels(newPanel, section);
	hideOptionsMenu(section);
}