//***********************************************************//
// OutlookMenu Class                                         //
//***********************************************************//
function OutlookMenu(name) {
	this.name = name;
	this.menuItems = new Array();

	this.addItem = _OutlookMenu_AddItem;
	this.display = _OutlookMenu_Display;
}

function _OutlookMenu_AddItem(item) {
	var length = this.menuItems.length;
	this.menuItems[length] = item;
}

function _OutlookMenu_Display() {
	var menuBorderStyle = "border-style:solid;border-width:4px;border-color:#ECE9D8;";
	
	document.write("<div name='" + this.name + "' id='" + this.name + "' style='width:100%;width:100%;background-color:#ECE9D8;" + menuBorderStyle + "'>");
	for (var i = 0; i < this.menuItems.length; i++) {
		this.menuItems[i].display();
	}
	document.write("</div>");
}

//***********************************************************//
// OutlookMenuItem Class                                     //
//***********************************************************//
function OutlookMenuItem(name, image1, image2, label, url, target) {
	this.name          = name;
	this.image1        = image1;
	this.image2        = image2;
	this.label         = label;
	this.url           = url;
	this.target        = target;

	this.menuTree  	= null;

	this.addTree = _OutlookMenuItem_AddTree;
	this.display = _OutlookMenuItem_display;
}

function _OutlookMenuItem_AddTree(tree) {
	this.menuTree = tree;
}

function _OutlookMenuItem_display() {
	var itemBorderStyle = "border-style:solid;border-width:1px;border-color:#ffffff #ACA899 #ACA899 #ffffff;";
	var treeBorderStyle = "border-style:solid;border-width:1px;border-color:#5D5B53 #ACA899 #ACA899 #5D5B53;";
	
	var onMouseOutAction = " onMouseOut='javascript:onOLMenuItemMouseOver(\"" + this.name + "_image\", \"" + this.image1 + "\");' ";
	var onMouseOvrAction = " onMouseOver='javascript:onOLMenuItemMouseOver(\"" + this.name + "_image\", \"" + this.image2 + "\");' ";
	var onMouseClkAction = " onClick='javascript:onOLMenuItemMouseClicked(\"" + this.name + "_tree\");' ";
	
	document.write("<div style='width:100%;background-color:#ECE9D8;text-align:center;padding-top:10px;padding-bottom:10px;" + itemBorderStyle + "'>");
	document.write("    <table width='100%' cellpadding='0' cellspacing='0' border='0'>");
	document.write("        <tr><td align='center'><img src='" + this.image1 + "' name='" + this.name + "_image' id='" + this.name + "_image' border='0'" + onMouseClkAction + onMouseOutAction + onMouseOvrAction + " style='cursor:hand;'/></td></tr>");
	document.write("        <tr><td align='center' style='font-family:arial,verdana;font-size:12px;font-weight:bold;'><a onClick='javascript:onOLMenuItemMouseClicked(\"" + this.name + "_tree\");' style='cursor:hand;'>" + this.label + "</a></td></tr>");
	document.write("    </table>");
	document.write("</div>");
	
	document.write("<div name='" + this.name + "_tree" + "' id='" + this.name + "_tree" + "' style='display:none;text-align:left;width:100%;background-color:#ACA899;padding-left:10px;padding-right:10px;padding-bottom:10px;" + treeBorderStyle + "'>");
	this.menuTree.createMenu();
	document.write("</div>");
}


//***********************************************************//
// Event Handler Functions                                   //
//***********************************************************//
function onOLMenuItemMouseClicked(menuItemTreeName) {
	var menuItemTreeDiv = document.getElementById(menuItemTreeName);
	if (menuItemTreeDiv.style.display == "none") {
		menuItemTreeDiv.style.display = "block";
	}
	else {
		menuItemTreeDiv.style.display = "none";
	} 
}

function onOLMenuItemMouseOver(menuItemImageName, menuItemImagePath) {
	var menuItemImage = document.getElementById(menuItemImageName);
	menuItemImage.src = menuItemImagePath;
}