
// Copyright © 2001 Microsoft Corporation

var IMAGES = "/library/flyoutmenu/images/"

if (!Product) var Product=""
if (!PageName) var PageName=""
if (!PageType) var PageType=""
//var Product = ""
var MENU_WIDTH = 180
var MENU_BORDER_COLOR		= '#999999'
var MENU_BACKGROUND_COLOR	= '#f1f1f1'
var MENU_CURRENTPAGE_COLOR	= '#ffffff'
var MENU_MOUSEOVER_COLOR	= '#cccccc'
var MENU_MOUSEDOWN_COLOR	= '#999999'
var MENU_SHADOW_COLOR		= '#666666'
var SCROLL_PXPERSEC = 150
var MIN_FLYOUT_WIDTH = 100
var MAX_FLYOUT_WIDTH = 410

var global = window.document
global.fo_currentMenu = null
global.fo_shadows = new Array
global.fo_killTimer = null

var flyoutCount = 0
var flyouts = new Array
var rowHeight = 0
var menuToShow = null
function setColors (new_MENU_BACKGROUND_COLOR, new_MENU_BORDER_COLOR, 
					new_MENU_MOUSEOVER_COLOR, new_MENU_MOUSEDOWN_COLOR,
					new_MENU_CURRENTPAGE_COLOR)

{
MENU_BORDER_COLOR		= new_MENU_BORDER_COLOR
MENU_BACKGROUND_COLOR	= new_MENU_BACKGROUND_COLOR
MENU_MOUSEOVER_COLOR	= new_MENU_MOUSEOVER_COLOR
MENU_MOUSEDOWN_COLOR	= new_MENU_MOUSEDOWN_COLOR
MENU_CURRENTPAGE_COLOR  = new_MENU_CURRENTPAGE_COLOR
}					

function go() {
//try{
//	if (parent.frames.length != 0)
//			parent.frames("header").externalMove()
//}
//catch (exception) 
//{}
}

function startPage(doreset)
{
	var bob = document;
	
	mdd = null
	
	var menudata
	var items = bob.all.tags("TD")
	var i
	var usePath = false
	var fhref = ""
	var nParentItem = 0
	var nParentLen = -1
	var lhref = normalized_href(location.href)
	if (window.parent.frames.length !=0 )
	{
		if (location.href == window.parent.frames(0).location.href)
			{
				lhref = pathof_href(window.parent.frames("main").location.href)
				usePath = true
			}
	}
	for (i=0; i<items.length; i++)
	{
		var item = items[i]
		if (item.className == "flyoutLink" || item.className == "flyoutSubLink")
		{
			var disabled = false
			var anchors = item.all.tags("A")
			
			if (anchors.length > 0)
			{
				var anchor = anchors.item(0)
				var aText = anchor.innerText;
				var aType = anchor.name;
				//alert("aType=" + aType + " PageType=" + PageType);
				if (usePath==true)
					var ahref = pathof_href(anchor.href)
				else
					var ahref = normalized_href(anchor.href)
				
				//alert("ahref=" + ahref + " lhref=" + lhref);
				if (aType == PageName && aType!='' || ahref == lhref || aType==PageType && aType!='')
				{
					if (usePath != true)
						{
						anchor.outerHTML = anchor.innerHTML
						item.style.cursor = 'default'
						disabled = true
						}
					item.initialBorder = item.style.borderColor
					item.initialBackground = item.style.backgroundColor
					item.style.borderColor = MENU_BORDER_COLOR
					item.style.backgroundColor = MENU_CURRENTPAGE_COLOR
					global.fo_currentMenu = item
					nParentItem = 0
					nParentLen = 9999
				}
				else 
				{
					if (doreset)
						{
						item.style.borderColor = MENU_BORDER_COLOR
						item.style.backgroundColor = MENU_BACKGROUND_COLOR
						}
					var slash = ahref.lastIndexOf("/")
					if (slash == ahref.length - 1)
						if (lhref.substr(0, slash + 1) == ahref)
							if (ahref.length > nParentLen)
							{
								nParentItem = i
								nParentLen = ahref.length
							}
				}
			}
			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 normalized_href(href)
{
	href = href.toLowerCase();
	var slash = href.lastIndexOf("/");
	if (slash != -1 ) 
	{
		var filename = href.substr(slash + 1);
		if (filename == "default.htm" || filename == "default.asp")
			href = href.substr(0, slash + 1);
	}
	return href;
}

function pathof_href(href)
{
	href = href.toLowerCase();
	var slash = href.lastIndexOf("/");
	if (slash != -1 ) 
	{
		var filename = href.substr(slash + 1);
		href = href.substr(0, slash + 1);
	}
	return href;
}

function image_load(src)
{
	var img = new Image()
	img.src = src
	return img
}

function externalMove()
{

if (global.fo_currentMenu)
	{
	var e = global.fo_currentMenu
	if (e.initialBorder)
		{	e.style.borderColor = e.initialBorder
			e.style.backgroundColor = e.initialBackground
		}
	}
startPage(true)	
}

function item_onmouseover()
{
	var that = event.srcElement
	
	var e = whichItem()
	if (e.contains(window.event.fromElement))
		return
	if (e.style.backgroundColor != MENU_CURRENTPAGE_COLOR)
	{
		e.style.borderColor = MENU_BORDER_COLOR
		e.style.backgroundColor = MENU_MOUSEOVER_COLOR
		global.fo_currentMenu = e
	}
}

function current_time()
{
	var temp = new Date()
	return temp.valueOf()
}

function item_onmouseout()
{
	var e = whichItem()
	var te = window.event.toElement
	if (te)
		if (e.contains(te) || te.flyoutArrow)
			return
	e.style.borderColor = e.defaultBorder
	e.style.backgroundColor = e.defaultBackground
	global.fo_currentMenu = null
}

function parentTable(e, findwhat)
{
	e = e.parentElement
	var keepGoing = ((e.tagName != "TABLE") && (e.parentElement != null) && (e.className != findwhat));
	while (keepGoing)
		{
			e = e.parentElement
			keepGoing =  ((e.parentElement != null) && (e.className != findwhat));
		}
	return e
}

function whichItem()
{
	var e = event.srcElement
	while (e.tagName != "TD")
		e = e.parentElement
	return e
}

function item_onmousedown()
{
	var e = whichItem()
	e.style.backgroundColor = MENU_MOUSEDOWN_COLOR
}

function GetBase()
{
    var oBaseColl = document.all.tags('BASE');
    return ( (oBaseColl && oBaseColl.length) ? oBaseColl[0].target : 
        null );
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function item_onmouseup()
{
	if ((event.button & 1) == 0)
		return;
		
	var e = whichItem()
	
	if (global.fo_currentMenu && global.fo_currentMenu.initialBorder && e != global.fo_currentMenu)
		{	global.fo_currentMenu.style.borderColor = global.fo_currentMenu.initialBorder
			global.fo_currentMenu.style.backgroundColor = global.fo_currentMenu.initialBackground
		}
	e.style.backgroundColor = MENU_MOUSEOVER_COLOR
	var a = e.all.tags("A")
	var baseTarget = GetBase()
	var localTarget = a[0].target
	localTarget = localTarget.toLowerCase();
	global.fo_currentMenu = e
	if (a.length > 0)
	{
		if (localTarget == "")
			if (baseTarget == "" || baseTarget == "_self")
				document.location.href = a[0].href
			else if (baseTarget == "_top")
				top.location.href = a[0].href
			else
				parent.frames(baseTarget).location.href = a[0].href
		else if (localTarget =="_new")
			window.open (a[0].href)
		else
			parent.frames(a[0].target).location.href = a[0].href
	}
}

function element_top(el)
{
	var et = 0
	while (el)
	{
		et += el.offsetTop
		el = el.offsetParent
	}
	return et
}



function create_sublink(html, className)
{
	var sublink = document.createElement("table")
	sublink.cellPadding = 0
	sublink.cellSpacing = 0
	sublink.style.margin = "0px 2px"
	sublink.widthAdjust = 0
	var td = sublink.insertRow().insertCell()
	if (!className) className = "flyoutSubLink"
	td.className = className
	td.submenu = "1"
	td.innerHTML = html
	return sublink
}

function create_separator()
{
	var sep = document.createElement("table")
	sep.cellPadding = 0
	sep.cellSpacing = 0
	sep.style.margin = "2px 0px"
	sep.widthAdjust = 4
	var td = sep.insertRow().insertCell()
	td.width = "100%"
	td.height = "1"
	td.bgColor = MENU_BORDER_COLOR
	return sep
}

