function MenuObject(mm_h, mm_w, mm_cp, mm_cs, sm_w, sm_cp, sm_cs, mm_align, mm_active, mm_separator, unk_bg, unk_ff, unk_fs, unk_fc, off, flash, bound) {
	this.mm_h = mm_h;
	this.mm_w = mm_w;
	this.mm_cp = mm_cp;
	this.mm_cs = mm_cs;
	this.sm_w = sm_w;
	this.sm_cp = sm_cp;
	this.sm_cs = sm_cs;
	this.mm_align = mm_align;
	this.mm_active = mm_active;
	this.mm_separator = mm_separator;
	this.unk_bg = unk_bg;
	this.unk_ff = unk_ff;
	this.unk_fs = unk_fs;
	this.unk_fc = unk_fc;
	this.off = off;
	this.bound = bound;
	this.subids = new Array();
	this.submenus = new Array();
	this.menu = new Array();
	this.closesubmenu = true;
	this.submenu = "";
	this.activemenu = -1;
	this.br = "UNK";
	if (document.layers) {
		this.br = "NS4";
	} else if (document.getElementById) {
		if (navigator.platform.toLowerCase().indexOf("win") != -1) {
			this.br = "MOD";
		} else {
			this.br = "MODMAC"
		}
	}
	// conditional to disable menus if flash will appear on top - blech!
	if (flash && (this.br == "MODMAC" || (navigator.userAgent.toLowerCase().indexOf('gecko') != -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1))) {
		this.br = "MODOFF";
	}
}

// return an offset value relative to the entire document
function calculateSumOffset(idItem, offsetName) {
	var totalOffset = 0;
	var item = eval('idItem');
	while (item != null) {
		totalOffset += eval('item.'+offsetName); item = eval('item.offsetParent');
	}
	return totalOffset;
}

// return the horizontal postion of a submenu
function moveSubmenuHor_MOD(subid) {
	var leftX = calculateSumOffset(document.getElementById(subid+"top"), 'offsetLeft');
	var menuOffset = calculateSumOffset(document.getElementById("ddmain"), 'offsetLeft');
	if ( ((leftX + parseInt(MO.sm_w, 10) - menuOffset) > document.getElementById("ddmain").offsetWidth) && MO.bound) {
		return leftX - (leftX + parseInt(MO.sm_w, 10) - menuOffset) + parseInt(MO.mm_w, 10);
	} else {
		return leftX;
	}
}

// return the horizontal postion of a submenu on a Mac
function moveSubmenuHor_MODMAC(subid) {
	var leftX = calculateSumOffset(document.getElementById(subid+"top"), 'offsetLeft');
	var menuOffset = calculateSumOffset(document.getElementById("ddmain"), 'offsetLeft');
	return leftX - menuOffset;
}

// return the vertical postion of a submenu
function moveSubmenuVer_MOD(subid) {
	var menuOffset = calculateSumOffset(document.getElementById("ddmain"), 'offsetTop');
	return menuOffset + document.getElementById("ddmain").offsetHeight + MO.off;
}

// return the vertical postion of a submenu on a Mac
function moveSubmenuVer_MODMAC(subid) {
	var curtop = 0;
	var obj = document.getElementById("ddmain");
	while (obj.offsetParent) {
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
	menuOffsetY = calculateSumOffset(document.getElementById("ddmain"), 'offsetTop');
	return curtop + document.getElementById("ddmain").offsetHeight - menuOffsetY + MO.off;
}

// show a given submenu
function showSubmenu(subid) {
	if (MO.submenu != "") document.getElementById(MO.submenu).style.display = "none";
	document.getElementById(subid).style.left = eval("moveSubmenuHor_" + MO.br + "(\"" + subid + "\")");
	document.getElementById(subid).style.top = eval("moveSubmenuVer_" + MO.br + "(\"" + subid + "\")");
	
	document.getElementById(subid).style.display = "inline";

	MO.submenu = subid;
	MO.closesubmenu = false;
}

// trigger the death of the current submenu
function tryHide(subid) { MO.closesubmenu = true; setTimeout("hideSubmenu('" + subid + "')", 1000); }
	
// hide a submenu
function hideSubmenu(subid) { if (MO.closesubmenu) document.getElementById(subid).style.display = "none"; }

// keep a submenu alive
function alive() { MO.closesubmenu = false; }

// append an item to the main menu
function appendMenu(txt, href, active) {
	if (active) { MO.activemenu = MO.submenus.length; }
	MO.submenus[MO.submenus.length] = new Array(); MO.menu[MO.menu.length] = new Array(txt, href);
}

// append an item to the submenu of the most recently append menu item
function appendSubmenu(txt, href) { MO.submenus[MO.menu.length - 1][MO.submenus[MO.menu.length - 1].length] = new Array(txt, href); }

// render a menu in unknown browsers
function renderMenu_UNK() {
	var mlen = MO.menu.length;
	document.write("<table border=\"0\" cellspacing=\"" + MO.mm_cs + "\" cellpadding=\"" + MO.mm_cp + "\" width=\"" + MO.mm_w + "\" bgcolor=\"" + MO.unk_bg + "\"><tr height=\"" + MO.mm_h + "\">\n");
	for (var i = 0; i < mlen; i++) {
		if (i != 0) document.write(MO.mm_separator);
		document.write("<td height=\"" + MO.mm_h + "\" align=\"" + MO.mm_align + "\"><a href=\"" + MO.menu[i][1] + "\"");
		if (i == MO.activemenu) {
			document.write("><font face=\"" + MO.unk_ff + "\" size=\"" + MO.unk_fs + "\" color=\"" + MO.mm_active + "\">" + MO.menu[i][0] + "</font></a></td>\n");
		} else {
			document.write("><font face=\"" + MO.unk_ff + "\" size=\"" + MO.unk_fs + "\" color=\"" + MO.unk_fc + "\">" + MO.menu[i][0] + "</font></a></td>\n");
		}
	}
	document.write("</tr></table>\n");
}

// render a menu in NS4.x
function renderMenu_NS4() {
	var mlen = MO.menu.length;
	document.write("<table id=\"ddmainn4\" border=\"0\" cellspacing=\"" + MO.mm_cs + "\" cellpadding=\"" + MO.mm_cp + "\" width=\"" + MO.mm_w + "\"><tr height=\"" + MO.mm_h + "\">\n");
	for (var i = 0; i < mlen; i++) {
		if (i != 0) document.write(MO.mm_separator);
		document.write("<td height=\"" + MO.mm_h + "\" align=\"" + MO.mm_align + "\"><a class=\"ddmainlinkn4\" href=\"" + MO.menu[i][1] + "\">");
		if (i == MO.activemenu) {
			document.write("<font color=\"" + MO.mm_active + "\">");
			document.write(MO.menu[i][0] + "</font></a></td>\n");
		} else {
			document.write(MO.menu[i][0] + "</a></td>\n");
		}
	}
	document.write("</tr></table>\n");
}

// render a menu in "modern" browsers
function renderMenu_MOD() {
	var mlen = MO.menu.length;
	document.write("<table id=\"ddmain\" border=\"0\" cellspacing=\"" + MO.mm_cs + "\" cellpadding=\"" + MO.mm_cp + "\" width=\"" + MO.mm_w + "\"><tr height=\"" + MO.mm_h + "\">\n");
	for (var i = 0; i < mlen; i++) {
		if (i != 0) document.write(MO.mm_separator);
		document.write("<td height=\"" + MO.mm_h + "\" id=\"ddsub" + i + "top\" align=\"" + MO.mm_align + "\"><a href=\"" + MO.menu[i][1] + "\" onmouseover=\"showSubmenu('ddsub" + i + "')\" onmouseout=\"tryHide('ddsub" + i + "')\"");
		if (i == MO.activemenu) document.write(" style=\"color:" + MO.mm_active + "\"");
		document.write(">" + MO.menu[i][0] + "</a></td>\n");
		MO.subids[MO.subids.length] = "ddsub" + i;
	}
	document.write("</tr></table>\n");
	for (var i = 0; i < mlen; i++) {
		var slen = MO.submenus[i].length;
		if (slen == 0) {
			document.write("<div id=\"ddsub" + i + "\" onmouseout=\"tryHide(this.id)\"></div>\n");
		} else {
			document.write("<div id=\"ddsub" + i + "\" class=\"ddsubmenu\" onmouseout=\"tryHide(this.id)\">\n");
			document.write("<table onmouseover=\"alive()\" width=\"" + MO.sm_w + "\" border=\"0\" cellpadding=\"" + MO.sm_cp + "\" cellspacing=\"" + MO.sm_cs + "\">\n");
			for (var j = 0; j < slen; j++)
				document.write("<tr><td onmouseover=\"alive()\"><a href=\"" + MO.submenus[i][j][1] + "\">" + MO.submenus[i][j][0] + "</a></td></tr>\n");
			document.write("</table>\n</div>\n");
		}
	}
}

// render a menu in "modern" browsers where flash doesn't interact well
function renderMenu_MODOFF() {
	var mlen = MO.menu.length;
	document.write("<table id=\"ddmain\" border=\"0\" cellspacing=\"" + MO.mm_cs + "\" cellpadding=\"" + MO.mm_cp + "\" width=\"" + MO.mm_w + "\"><tr height=\"" + MO.mm_h + "\">\n");
	for (var i = 0; i < mlen; i++) {
		if (i != 0) document.write(MO.mm_separator);
		document.write("<td height=\"" + MO.mm_h + "\" align=\"" + MO.mm_align + "\"><a href=\"" + MO.menu[i][1] + "\"");
		if (i == MO.activemenu) document.write(" style=\"color:" + MO.mm_active + "\"");
		document.write(">" + MO.menu[i][0] + "</a></td>\n");
	}
	document.write("</tr></table>\n");
}

function renderMenu_MODMAC() { renderMenu_MOD(); }

// render the menu
function renderMenu() {
	eval("renderMenu_" + MO.br + "()");
	delete MO.menu;
	delete MO.submenus;
}

// menu construction
function MenuHere(i) {
	MO = new MenuObject("22", "752", "0", "0", "200", "0", "1", "center", "#0072b9", "", "#0072b9", "Arial", "2", "#FFFFFF", 0, true, true);

	appendMenu("Teams", "/teams/index.htm", (1 == i));
	appendSubmenu("Staff", "/teams/index.htm");
	appendSubmenu("Choreographers & Instructors", "/cheerleading/ci.htm");
	appendSubmenu("FlyTeams", "/teams/flyteams.htm");
	appendSubmenu("Classes & Competitive Programs", "/teams/programs.php");
	appendMenu("Cheerleading", "/cheerleading/index.htm", (2 == i));
	appendSubmenu("Choreography", "/cheerleading/choreography.htm");
	appendSubmenu("Choreographers & Instructors", "/cheerleading/ci.htm");
	appendSubmenu("Camps & Clinics","/cheerleading/campsandclinics.htm");
	appendSubmenu("Coach's Training","/cheerleading/coachestraining.htm");
	appendSubmenu("Competitions","/cheerleading/competitions.htm");
	appendMenu("Dance", "/dance/index.htm", (3 == i));
	appendSubmenu("Choreographers & Instructors", "/cheerleading/ci.htm");
	appendMenu("Apparel", "/onlinecatalog/index.htm", (4 == i));
	appendSubmenu("Camp Wear", "/onlinecatalog/index.htm");
	appendSubmenu("Uniforms", "/onlinecatalog/uniforms.htm");
	appendSubmenu("Shoes", "/onlinecatalog/evolution.htm");
	appendSubmenu("Poms", "/onlinecatalog/poms.htm");
	appendSubmenu("Accessories", "/onlinecatalog/accessories.htm");
	appendSubmenu("Books and Videos", "/onlinecatalog/booksandvideos.htm");
	appendSubmenu("Music", "http://www.flygirl.ca/onlinecatalog/music.htm");
	appendMenu("Resources", "/resources/index.htm", (5 == i));
	appendSubmenu("Cheer Tips", "/resources/index.htm");
	appendSubmenu("Coaches Tips", "/resources/coachestips.htm");
	appendSubmenu("Coach's Manual", "/resources/coachesmanual.htm");
	appendSubmenu("Newsletter", "/resources/newsletter.htm");
	appendSubmenu("Press Releases","/resources/pressreleases.htm");
	appendSubmenu("Business Consulting", "/resources/businessconsulting.htm");
	appendSubmenu("Links", "/resources/links.htm");
	appendMenu("Entertainment Industry", "/eis/index.htm", (6 == i));
	appendMenu("Event Calendar", "/eventcalendar/index.htm", (7 == i));
	appendMenu("Contact", "/contact/index.htm", (8 == i));
		
	
	renderMenu();
}

