var loaded;
if (loaded == null) {
	var skinName = "S2";
	var aMenuBar = new Array();
	var aMenuBarItem = new Array();
	var aDropDownMenu = new Array();
	var aDropDownItem = new Array();
	oSkin = new skin(skinName);
	loaded = "true";
}

//==============================================================================
// Function: drawMenuBar()
// Description: 
// Inputs: 
// Return:
//==============================================================================
function drawMenuBar() {
	var sHTML;
	var aMenuBarItems = new Array();
	var sMenuBarName = "default";
	if (drawMenuBar.arguments.length > 0) {
		sMenuBarName = drawMenuBar.arguments[0];
	}
	oMenuBar = getMenuBar(sMenuBarName);
	aMenuBarItems = getMenuBarItems(sMenuBarName);
	sHTML = oMenuBar.sHeaderHTML;
	for (var i=0; i<aMenuBarItems.length; i++) {
		oMenuBarItem = aMenuBarItems[i];
		sHTML += oMenuBarItem.sHeaderHTML + oMenuBarItem.sInnerHTML + oMenuBarItem.sFooterHTML;
	}
	sHTML += oMenuBar.sFooterHTML;

	document.write(sHTML);
}

//==============================================================================
// Function: drawDropDownMenu()
// Description: 
// Inputs: 
// Return:
//==============================================================================
function drawDropDownMenu() {
	var sHTML;
	var aDropDownItems = new Array();
	var sDropDownMenuName = "default";
	if (drawDropDownMenu.arguments.length > 0) {
		sDropDownMenuName = drawDropDownMenu.arguments[0];
	}
	oDropDownMenu = getDropDownMenu(sDropDownMenuName);
	aDropDownItems = getDropDownItems(sDropDownMenuName);
	sHTML = oDropDownMenu.sHeaderHTML;
	for (var i=0; i<aDropDownItems.length; i++) {
		oDropDownItem = aDropDownItems[i];
		sHTML += oDropDownItem.sHeaderHTML + oDropDownItem.sInnerHTML + oDropDownItem.sFooterHTML;
	}
	sHTML += oDropDownMenu.sFooterHTML;

	document.write(sHTML);
}

//==============================================================================
// Function: skin(sSkinName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function skin(sSkinName) {
	this.name = sSkinName;
	this.sSkin = sSkinName;
	this.sBtnUp = "BtnUp";
	this.sBtnDn = "BtnDn";
}

//==============================================================================
// Function: menuBar(sMenuBarName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function menuBar(sMenuBarName) {
	this.name = sMenuBarName;
	this.menuBarID = aMenuBar.length + 1;
	this.sHeaderHTML = "<div id='objMenuBar" + this.menuBarID + "'><table id='bgMenuBar" + this.menuBarID + "' class='" + oSkin.sSkin + "MBDef'><tr>";
	this.sFooterHTML = "<td class='" + oSkin.sSkin + "MBNoItem'></td></tr></table></div>";
}

//==============================================================================
// Function: addMenuBar(sMenuBarName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function addMenuBar(sMenuBarName) {
	oMenuBar = new menuBar(sMenuBarName);
	aMenuBar.push(oMenuBar);
}

//==============================================================================
// Function: getMenuBar(sMenuBarName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function getMenuBar(sMenuBarName) {
	if (aMenuBar.length > 0) {
		for (var i=0; i<aMenuBar.length; i++) {
			oMenuBar = aMenuBar[i];
			if (oMenuBar.name == sMenuBarName) {
				return oMenuBar;
			}
		}
	}
	return null;
}

//==============================================================================
// Function: menuBarItem(sMenuBarName, sMenuBarItemName, sMenuBarItemText, sMenuBarItemRef, sMenuBarItemTitle)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function menuBarItem(sMenuBarName, sMenuBarItemName, sMenuBarItemText, sMenuBarItemRef, sMenuBarItemTitle) {
	this.menuBarName = sMenuBarName;
	this.name = sMenuBarItemName;
	this.menuBarItemID = aMenuBarItem.length + 1;
	this.sHeaderHTML = "<div id='objMenuBarItem" + this.menuBarItemID + "'>" +
			   "<td id='bgMenuBarItem" + this.menuBarItemID + "' " +
			   	"class='" + oSkin.sSkin + "MBItemUp' " +
			   	"onMouseOver='applyStyleDn(\"MenuBarItem" + this.menuBarItemID + "\");' " +
			   	"onMouseOut='applyStyleUp(\"MenuBarItem" + this.menuBarItemID + "\");'>" +
			   "<a id='fgMenuBarItem" + this.menuBarItemID + "' " +
			   	"title='" + sMenuBarItemTitle + "' " +
			   	"class='" + oSkin.sSkin + "MBItemUp' " +
			   	"href='" + sMenuBarItemRef + "'>";
	this.sInnerHTML = sMenuBarItemText;
	this.sFooterHTML = "</a></td></div>";
}

//==============================================================================
// Function: addMenuBarItem(sMenuBarName, sMenuBarItemName, sMenuBarItemText, sMenuBarItemRef, sMenuBarItemTitle)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function addMenuBarItem(sMenuBarName, sMenuBarItemName, sMenuBarItemText, sMenuBarItemRef, sMenuBarItemTitle) {
	oMenuBarItem = new menuBarItem(sMenuBarName, sMenuBarItemName, sMenuBarItemText, sMenuBarItemRef, sMenuBarItemTitle);
	aMenuBarItem.push(oMenuBarItem);
}

//==============================================================================
// Function: getMenuBarItem(sMenuBarName, sMenuBarItemName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function getMenuBarItem(sMenuBarName, sMenuBarItemName) {
	if (aMenuBarItem.length > 0) {
		for (var i=0; i<aMenuBarItem.length; i++) {
			oMenuBarItem = aMenuBarItem[i];
			if (oMenuBarItem.menuBarName == sMenuBarName && oMenuBarItem.name == sMenuBarItemName) {
				return oMenuBarItem;
			}
		}
	}
	return null;
}

//==============================================================================
// Function: getMenuBarItems(sMenuBarName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function getMenuBarItems(sMenuBarName) {
	var aMenuBarItems = new Array()
	if (aMenuBarItem.length > 0) {
		for (var i=0; i<aMenuBarItem.length; i++) {
			oMenuBarItem = aMenuBarItem[i];
			if (oMenuBarItem.menuBarName == sMenuBarName) {
				aMenuBarItems.push(oMenuBarItem);
			}
		}
	}
	return aMenuBarItems;
}

//==============================================================================
// Function: dropDownMenu(sDropDownMenuName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function dropDownMenu(sDropDownMenuName) {
	this.name = sDropDownMenuName;
	this.dropDownMenuID = aDropDownMenu.length + 1;
	this.sHeaderHTML = "<div id='objDropDownMenu" + this.dropDownMenuID + "'><table id='bgDropDownMenu" + this.dropDownMenuID + "' class='" + oSkin.sSkin + "DDMDef' cellspacing=0 cellpadding=0><tr>" +
				 "<td class='" + oSkin.sSkin + "DDMLeftTop'></td>" +
				 "<td class='" + oSkin.sSkin + "DDMTop'></td>" +
				 "<td class='" + oSkin.sSkin + "DDMRightTop'></td></tr>";
	this.sFooterHTML = "<tr><td class='" + oSkin.sSkin + "DDMLeftBottom'></td>" +
				 "<td class='" + oSkin.sSkin + "DDMBottom'></td>" +
				 "<td class='" + oSkin.sSkin + "DDMRightBottom'></td></tr></table></div>";
}

//==============================================================================
// Function: addDropDownMenu(sDropDownMenuName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function addDropDownMenu(sDropDownMenuName) {
	oDropDownMenu = new dropDownMenu(sDropDownMenuName);
	aDropDownMenu.push(oDropDownMenu);
}

//==============================================================================
// Function: getDropDownMenu(sDropDownMenuName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function getDropDownMenu(sDropDownMenuName) {
	if (aDropDownMenu.length > 0) {
		for (var i=0; i<aDropDownMenu.length; i++) {
			oDropDownMenu = aDropDownMenu[i];
			if (oDropDownMenu.name == sDropDownMenuName) {
				return oDropDownMenu;
			}
		}
	}
	return null;
}

//==============================================================================
// Function: dropDownItem(sDropDownMenuName, sDropDownItemName, sDropDownItemText, sDropDownItemRef, sDropDownItemTitle)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function dropDownItem(sDropDownMenuName, sDropDownItemName, sDropDownItemText, sDropDownItemRef, sDropDownItemTitle) {
	this.dropDownMenuName = sDropDownMenuName;
	this.name = sDropDownItemName;
	this.dropDownItemID = aDropDownItem.length + 1;
	this.sHeaderHTML = "<div id='objDropDownItem" + this.dropDownItemID + "'><tr>" +
			   "<td class='" + oSkin.sSkin + "DDItemLeft'></td>";
	this.sInnerHTML = "<td class='" + oSkin.sSkin + "DDItemUp' " +
			   	"onMouseOver='applyStyleDn(\"dropDownItem" + this.dropDownItemID + "\");' " +
			   	"onMouseOut='applyStyleUp(\"dropDownItem" + this.dropDownItemID + "\");'>" +
  			   	"<a id='fgDropDownItem" + this.dropDownItemID + "' " +
			   	"title='" + sDropDownItemTitle + "' " +
			   	"class='" + oSkin.sSkin + "DDItemUp' " +
			   	"href='" + sDropDownItemRef + "'>" +
				sDropDownItemText + "</td>";
	this.sFooterHTML = "<td class='" + oSkin.sSkin + "DDItemRight'></td></tr></div>";
}

//==============================================================================
// Function: addDropDownItem(sDropDownMenuName, sDropDownItemName, sDropDownItemText, sDropDownItemRef, sDropDownItemTitle)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function addDropDownItem(sDropDownMenuName, sDropDownItemName, sDropDownItemText, sDropDownItemRef, sDropDownItemTitle) {
	oDropDownItem = new dropDownItem(sDropDownMenuName, sDropDownItemName, sDropDownItemText, sDropDownItemRef, sDropDownItemTitle);
	aDropDownItem.push(oDropDownItem);
}

//==============================================================================
// Function: getDropDownItem(sDropDownMenuName, sDropDownItemName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function getDropDownItem(sDropDownMenuName, sDropDownItemName) {
	if (aDropDownItem.length > 0) {
		for (var i=0; i<aDropDownItem.length; i++) {
			oDropDownItem = aDropDownItem[i];
			if (oDropDownItem.dropDownMenuName == sDropDownMenuName && oDropDownItem.name == sDropDownItemName) {
				return oDropDownItem;
			}
		}
	}
	return null;
}

//==============================================================================
// Function: getDropDownItems(sDropDownMenuName)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function getDropDownItems(sDropDownMenuName) {
	var aDropDownItems = new Array()
	if (aDropDownItem.length > 0) {
		for (var i=0; i<aDropDownItem.length; i++) {
			oDropDownItem = aDropDownItem[i];
			if (oDropDownItem.dropDownMenuName == sDropDownMenuName) {
				aDropDownItems.push(oDropDownItem);
			}
		}
	}
	return aDropDownItems;
}

//==============================================================================
// Function: applyStyleDn(sObjectID)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function applyStyleDn(sObjectID) {
	var sClassName;
	var sSearchObjectID;
	sSearchObjectID = "obj" + sObjectID;
	oElement = document.getElementById(sSearchObjectID);
	if (oElement != null) {
		sClassName = oElement.className;
		if (sClassName.indexOf("Up") > 0) { 
			oElement.className = sClassName.replace("Up", "Dn");
		}
	}
	sSearchObjectID = "bg" + sObjectID;
	oElement = document.getElementById(sSearchObjectID);
	if (oElement != null) {
		sClassName = oElement.className;
		if (sClassName.indexOf("Up") > 0) { 
			oElement.className = sClassName.replace("Up", "Dn");
		}
	}
	sSearchObjectID = "fg" + sObjectID;
	oElement = document.getElementById(sSearchObjectID);
	if (oElement != null) {
		sClassName = oElement.className;
		if (sClassName.indexOf("Up") > 0) { 
			oElement.className = sClassName.replace("Up", "Dn");
		}
	}
}

//==============================================================================
// Function: applyStyleUp(sObjectID)
// Description: 
// Inputs: 
// Return:
//==============================================================================
function applyStyleUp(sObjectID) {
	var sClassName;
	var sSearchObjectID;
	sSearchObjectID = "obj" + sObjectID;
	oElement = document.getElementById(sSearchObjectID);
	if (oElement != null) {
		sClassName = oElement.className;
		if (sClassName.indexOf("Dn") > 0) { 
			oElement.className = sClassName.replace("Dn", "Up");
		}
	}
	sSearchObjectID = "bg" + sObjectID;
	oElement = document.getElementById(sSearchObjectID);
	if (oElement != null) {
		sClassName = oElement.className;
		if (sClassName.indexOf("Dn") > 0) { 
			oElement.className = sClassName.replace("Dn", "Up");
		}
	}
	sSearchObjectID = "fg" + sObjectID;
	oElement = document.getElementById(sSearchObjectID);
	if (oElement != null) {
		sClassName = oElement.className;
		if (sClassName.indexOf("Dn") > 0) { 
			oElement.className = sClassName.replace("Dn", "Up");
		}
	}
}
