<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="menuMouseOver()" />
<PUBLIC:ATTACH EVENT="onmouseout"  ONEVENT="menuMouseOut()" />
<PUBLIC:ATTACH EVENT="onfocus"	   ONEVENT="menuFocus()" />
<PUBLIC:ATTACH EVENT="onblur"	   ONEVENT="menuBlur()" />
<PUBLIC:ATTACH EVENT="onkeypress"  ONEVENT="menuKeyPress()" />
<PUBLIC:ATTACH EVENT="onclick"	   ONEVENT="menuClick()" />
<SCRIPT>
//<!--
/************************************************************************************************************
* 2-12-2002 *                                                                                               *
* FILENAME: AOLmenuBehaviors.htc                                                                            *
* This file contains the JS behaviors for the new 2002 menu GUI.                                            *
*                                                                                                           *
* RELATED DOCS:                                                                                             *
*   (Reference only, not used in code)                                                                      *
*     GACEDATA:AOLSTYLECSS - new style sheet doc including behavior references                              *
*     GACEDATA:MENUCSS     - clipped menu portion of the AOLSTYLECSS                                        *
*     GACEDATA:MENUFLAG    - text used to generate menu flags (red dot)                                     *
*     GACEDATA:MENUHTC     - this text                                                                      *
*     GACEDATA:MENUREADME  - a descriptive text about the new menu htc                                      *
*     GACEDATA:MENUSBMTBTN - text used to generate the hidden menu submit button                            *
*     GACEDATA:MENUTEMPLATE - a copy and paste template for starting a new menu                             *
*                                                                                                           *
*   (Used in code):                                                                                         *
*     GACEDATA:MENUINCS    - an include file that adds the AOLEdit.js, and AOLStyle.css lines to your gmenu *
*************************************************************************************************************/

/*-- execute for each menu item --*/
//if the item is a menu title add the form submit button to that cell
//but only if it does not already exist (dont want duplicate buttons in the same form)
if(element.className == 'menuTitle')
{
	//only add if it does not already exist
	if(typeof main.__menu_form_submit_button__ == 'undefined')
	{
		var text = element.innerHTML;
		element.innerHTML = '<input type="submit" id="__menu_form_submit_button__" style="display:none;">' + text;
	}
}

//if the cell has a link attribute, set the tabindex to 0 so it can be tabbed to
if(typeof element.link != 'undefined')
{
	element.tabIndex = '0';
}
else
{
	runtimeStyle.cursor = 'default';
}

//if the cell has a flag attribute, draw a hidden flag in front of the cell contents
if(typeof element.flag != 'undefined')
{
	var text = element.innerHTML;
	//if the flag attribute has a value, set the id of the flag to that value
	if(element.flag.length > 0)
	{
		var flag = element.flag;
		element.innerHTML = '<span id="' + flag + '" class="menuFlag"></span>&nbsp;' + text;
	}
	//if the flag attribute has no value, do not add an id (effectively becomes a spacer)
	else
	{
		element.innerHTML = '<span class="menuFlag"></span>&nbsp;' + text;
	}
}

/*-- event handlers --*/
function menuMouseOver()
{
	if(isItemClass(element))
	{
		if(typeof element.link != 'undefined')
		{
			runtimeStyle.cursor = 'hand';
			if(element.className == 'menuItemFocus')
			{
				element.className = 'menuItemFocusHL';
			}
			else
			{
				element.className = 'menuItemHL';
			}
		}
		else
		{
			runtimeStyle.cursor = 'default';
		}
	}
}

function menuMouseOut()
{
	if(isItemClass(element))
	{
		if(typeof element.link != 'undefined')
		{
			if(element.className == 'menuItemFocusHL')
			{
				element.className = 'menuItemFocus';
			}
			else
			{
				element.className = 'menuItem';
			}
		}
	}
}

function menuFocus()
{
	if(isItemClass(element))
	{
		if(typeof element.link != 'undefined')
		{
			if(element.className == 'menuItemHL')
			{
				element.className = 'menuItemFocusHL';
			}
			else
			{
				element.className = 'menuItemFocus';
			}
		}
	}
}

function menuBlur()
{
	if(isItemClass(element))
	{
		if(typeof element.link != 'undefined')
		{
			if(element.className == 'menuItemFocusHL')
			{
				element.className = 'menuItemHL';
			}
			else
			{
				element.className = 'menuItem';
			}
		}
	}
}

function menuClick()
{	
	handleClick(element.link);
}

function menuKeyPress()
{
	//return false if not the 'enter key' or 'spacebar'
	if((event.keyCode != 13) && (event.keyCode != 32)) { return false; }
	handleClick(element.link);
}


/*-- subs --*/
//doClick(string)
//handles submitting the form (if desired) and changing the location of the document
//'link' is a qualified pega action(string) such as '/action.pega?|GDOO|CPBULLETINBD'
function handleClick(link)
{
	var space = /\s/gi;
	if(typeof link != 'undefined')
	{
		//remove whitespace from the action
		link = link.replace(space, '');
		if(link.length > 1)
		{
			//if the 'submit' attribute is present, submit the form (submit button style)
			if((typeof element.submit != 'undefined') && (typeof main.__menu_form_submit_button__ != 'undefined'))
			{
				submitForm(link);
			}
			//or just change the location (link href style)
			else
			{
				location.href = link;
			}
		}
	}
}

//submitForm(string)
//changes the NAME of the hidden submit button to the link text and then generates a click on the hidden submit button to submit the form
//'link' is a qualified pega action(string) such as '/action.pega?|GDOO|CPBULLETINBD'
function submitForm(link)
{
	var oldLink = link;
	var btnName = oldLink.replace(/^http:\/\/\/action.pega\?/i, '@ACTION=');
	main.__menu_form_submit_button__.name = btnName;
	main.__menu_form_submit_button__.click();
}

function isItemClass(object)
{
	var classes = new Array('menuItem',
							'menuItemHL',
							'menuItemFocus',
							'menuItemFocusHL');
	for(var i = 0; i < classes.length; i++)
	{
		if(classes[i] === object.className)
		{
			return true;
		}
	}
	return false;
}

function isTitleClass(object)
{
	var classes = new Array('menuTitle',
							'menuTitleBtn');
	for(var i = 0; i < classes.length; i++)
	{
		if(classes[i] === object.className)
		{
			return true;
		}
	}
	return false;
}
//-->
</SCRIPT>
</PUBLIC:COMPONENT>