/*
==============================================================================

  © Copyright 2002-2009 Media Monitors. All Rights Reserved.

  Media Monitors Company Confidential; Media Monitors, 445 Hamilton Ave. White Plains, NY 10601

  This code and all associated files are the proprietary property of Media Monitors.

  No portion nor portions may be used without the express written permission of Media Monitors.

==============================================================================
*/

var __AllMenuItems = new Array ();

// constructor for a MenuItem
function MenuItem (_name, _url, _className)
{
	this.name = _name;
	this.url = _url;
	this.itemDiv = document.createElement("div");
	this.itemDiv.id = "menu_item_" + _name;
	this.itemDiv.url = _url;
	this.itemDiv.className = _className;
	this.menuItemId = __AllMenuItems.length;
	__AllMenuItems[__AllMenuItems.length] = this;
	this.itemDiv.innerHTML = "<a href='" + this.url + "' " 
						   + " onmouseout='__AllMenuItems[" + this.menuItemId + "].HideMenu()' "
						   + " onmouseover='__AllMenuItems[" + this.menuItemId + "].ClearTimer()' >"
						   + "<span style='width:100%'>" + this.name + "</span>"
						   + "</a>"; 

	// append a sub-menu to this MenuItem
	this.Append = function (_menu)
   	{
		_menu.parentItem = this;
		this.subMenu = _menu;
		this.itemDiv.innerHTML = "<a href='" + this.url + "'"
								 + " onmouseover='__AllMenuItems[" + this.menuItemId + "].ShowSubMenu()' "
								 + " onmouseout='__AllMenuItems[" + this.menuItemId + "].HideSubMenu()' >"
								 + this.name 
								 + " <img src='rightarrow.png' border=0></a>";
	}

	this.ShowSubMenu = function ()
	{
		if (this.subMenu)
		{
			//alert(this.itemDiv.offsetLeft + " " + this.itemDiv.clientWidth + " " + this.itemDiv.offsetTop);
			this.subMenu.ShowAt(this.itemDiv.offsetLeft + this.itemDiv.clientWidth + 1, this.itemDiv.offsetTop);
		}
	}

	this.HideSubMenu = function ()
	{
		if (this.subMenu)
		{
			this.subMenu.Hide();
		}
	}

	this.HideMenu = function ()
	{
		if (this.parentMenu)
		{
			if (!this.parentMenu.parentMenu)
				this.parentMenu.Hide();
		}
	}

	this.ClearTimer = function ()
	{
		this.parentMenu.ClearTimer();
	}

	return this;
}

// constructor for a Menu or sub-menu
function Menu (_id, _className)
{
	this.id = _id
	this.items = new Array ();
	this.menuDiv = document.createElement("div");
	this.menuDiv.className = _className;
	this.menuDiv.style.display = "none";
	this.parentItem = null;
	this.timer = null;

	// append a MenuItem to this Menu
	this.Append = function (_menuItem)
	{
		_menuItem.parentMenu = this;
		this.items[this.items.length] = _menuItem;
		this.menuDiv.appendChild(_menuItem.itemDiv);
	}

	this.Show = function ()
	{
		clearTimeout(this.timer);
		if (this.parentItem)
			this.parentItem.ClearTimer();
		this.menuDiv.style.display = "inline";
	}

	this.ShowAt = function (_x, _y)
	{
		this.menuDiv.style.position = "absolute";
		this.menuDiv.style.left = _x + "px";
		this.menuDiv.style.top = _y + "px";
		this.menuDiv.style.zIndex = "999999";
		this.Show();
	}

	this.Hide = function ()
	{
		if (!this.parentItem)
			return;
		clearTimeout(this.timer);
		if (this.parentItem)
			this.parentItem.ClearTimer();
 		this.timer = setTimeout("__AllMenuItems[" + this.menuItemId  + "].menuDiv.style.display = 'none';", 500);
	}

	this.ClearTimer = function ()
	{
		clearTimeout(this.timer);
	}

	this.menuItemId = __AllMenuItems.length;
	__AllMenuItems[__AllMenuItems.length] = this;
	return this;
}



// THE FOLLOWING IS SPECIFIC TO AIRCHECK.NET.AU


function initMenus ()
{
	document.getElementById("globenav").appendChild(menu.menuDiv);
	document.getElementById("globenav").appendChild(menu2.menuDiv);
	menu.Show();
}

var menu = new Menu ("mainNavMenu", "menu");
var menuItem1 = new MenuItem ("Home",             "../Default.asp", "menuItem");
var menuItem2 = new MenuItem ("News",             "../PressReleases.asp", "menuItem");
var menuItem3 = new MenuItem ("Airplay Charts",   "#", "menuItem");
var menuItem4 = new MenuItem ("How It Works",     "../AirCheckDemo.asp", "menuItem");
var menuItem5 = new MenuItem ("AirCheck Demo", "../AircheckDemo.asp", "menuItem");
var menuItem6 = new MenuItem ("Request Training",         "../requestTraining.asp", "menuItem");
var menuItem7 = new MenuItem ("Company",          "../Overview.asp", "menuItem");
var menuItem8 = new MenuItem ("Contact Us",       "../contactUs.asp", "menuItem");
menu.Append(menuItem1);
menu.Append(menuItem2);
menu.Append(menuItem3);
menu.Append(menuItem4);
menu.Append(menuItem5);
menu.Append(menuItem6);
menu.Append(menuItem7);
menu.Append(menuItem8);

var menu2 = new Menu ("airplayChartsSubMenu", "menu");
var menuItem41 = new MenuItem ("Mediabase",       "mediabaseChart.aspx", "menuItem");
var menuItem42 = new MenuItem ("AirCheck Top 10", "AirCheckTopTens.aspx", "menuItem");
var menuItem43 = new MenuItem ("Did You Know",    "../DidYouKnow.asp", "menuItem");
menu2.Append(menuItem41);
menu2.Append(menuItem42);
menu2.Append(menuItem43);
menuItem3.Append(menu2);

