
// Copyright © 2001 Microsoft Corporation

var MENU_BORDER_COLOR		= '#999999'
var MENU_CURRENTPAGE_COLOR	= '#ffffff'
var MENU_MOUSEOVER_COLOR	= '#cccccc'	// gray
// var MENU_MOUSEOVER_COLOR	= '#7a95ca' // lighter blue
//var MENU_MOUSEOVER_COLOR	= '#a7b9dc'
var MENU_MOUSEDOWN_COLOR	= '#999999'

var global = window.document

var firsttime = true

function newid()
{
	var id
	do
		id = 'id' + Math.random().toString().substr(2, 10)
	while (global.all(id))
	return id
}


function event_oncontentready(elem)
{
	if (!firsttime)
		return
		

		
	firsttime = false;
	if (elem.id == '')
		elem.id = newid()
		
	var items = elem.all.tags("td")
	var i
	var nParentItem = 0
	var nParentLen = -1

	var ft = true;
	
	for (i=0; i<items.length; i++)
	{
		var item = items[i]
		if (item.className == "flyoutLink")
		{
			var disabled = false
			var anchors = item.all.tags("A")
			if (anchors.length > 0)
			{
				var anchor = anchors.item(0)
				if (item.id == "menu_sel")
				{
					anchor.outerHTML = anchor.innerHTML
					item.style.color = '#ffffff'
					item.style.fontWeight = 'bold'
					//item.style.color = '#ff0000'
					//item.style.borderColor = MENU_BORDER_COLOR
					
					//item.style.borderColor = '#ff0000'
					//item.style.backgroundColor = '#ff0000'
					item.style.borderColor = '#fb9916'
					item.style.backgroundColor = '#fb9916'
					
					//item.style.backgroundColor = MENU_CURRENTPAGE_COLOR
					item.style.cursor = 'default'
					disabled = true
					nParentItem = 0
					nParentLen = 9999
				}
			}
			item.defaultBorder = item.style.borderColor
			item.defaultBackground = item.style.backgroundColor
			item.attachEvent("onmouseover", item_onmouseover)
			item.attachEvent("onmouseout", item_onmouseout)
			if (!disabled)
			{
				item.attachEvent("onmousedown", item_onmousedown)
				item.attachEvent("onmouseup", item_onmouseup)
			}
		}
	}
	if (nParentItem != 0)
	{
		items[nParentItem].style.borderColor = MENU_BORDER_COLOR
		items[nParentItem].defaultBorder = MENU_BORDER_COLOR
	}
}


function item_onmouseover()
{
	var e = whichItem()
	if (e.contains(window.event.fromElement))
		return
	//if (e.style.backgroundColor != MENU_CURRENTPAGE_COLOR)
	if (e.id != 'menu_sel') // backgroundColor != MENU_CURRENTPAGE_COLOR)
	{
		e.style.borderColor = MENU_BORDER_COLOR
		e.style.backgroundColor = MENU_MOUSEOVER_COLOR
	}

	var a = e.all.tags("A")
	if (a.length > 0)
		window.status = a[0].href
}

function item_onmouseout()
{
	var e = whichItem()
	var te = window.event.toElement
	if (te)
		if (e.contains(te))
			return
	e.style.borderColor = e.defaultBorder
	e.style.backgroundColor = e.defaultBackground


	window.status = ""
}

function whichItem()
{
	var e = event.srcElement
	while (e.tagName != "TD")
		e = e.parentElement
	return e
}

function item_onmousedown()
{
	if ((event.button & 1) == 0)
		return;
	var e = whichItem()
	e.style.backgroundColor = MENU_MOUSEDOWN_COLOR
	e.mouseIsDown = 1
}

function item_onmouseup()
{
	if ((event.button & 1) == 0)
		return;
	var e = whichItem()
	if (e.mouseIsDown != 1)
		return
	e.mouseIsDown = false
	e.style.backgroundColor = MENU_MOUSEOVER_COLOR
	var a = e.all.tags("A")
	if (a.length > 0)
		top.location.href = a[0].href
}


