/*	File: menu.js
*/

/*	Name: menu
**
**	Holds the reference to the menu object @link[#_objMenu, _objMenu].
**
*/
var menu = new _objMenu();
menu.index.initialize();

/*	Name: Constants
**
**	MENU_INDEX_NONE - int
**	MENU_INDEX_STARTCENTER - int
**	MENU_INDEX_MAIL - int
**	MENU_INDEX_ADDRESSBOOK - int
**	MENU_INDEX_CALENDAR - int
**	MENU_INDEX_NOTES - int
**	MENU_INDEX_SYNCHRONISATION - int
**	MENU_INDEX_PREFERENCES - int
**	TYPE_OPTION_GROUP_DEFAULT - string
**	TYPE_OPTION_GROUP_PRIMARY - string
**	TYPE_OPTION_GROUP_SECONDARY - string
**	TYPE_OPTION_GROUP_CUSTOM - string
**	TYPE_OPTION_GROUP_EXTERNAL - string
**	TYPE_OPTION_GROUP_GAUGE - string
**	PAGEMENU_HEIGHT - int
**	PAGEMENU_OFFSET_TOP - int
*/

var MENU_INDEX_NONE = -1;
var MENU_INDEX_STARTCENTER = 1;
var MENU_INDEX_MAIL = 2;
var MENU_INDEX_ADDRESSBOOK = 3;
var MENU_INDEX_CALENDAR = 4;
var MENU_INDEX_NOTES = 5;
var MENU_INDEX_SYNCHRONISATION = 6;
var MENU_INDEX_PREFERENCES = 7;
var TYPE_OPTION_GROUP_DEFAULT = 'DEFAULT';		// No type
var TYPE_OPTION_GROUP_PRIMARY = 'PRIMARY';		// Primary menu option
var TYPE_OPTION_GROUP_SECONDARY = 'SECONDARY';	// Secondary menu option
var TYPE_OPTION_GROUP_CUSTOM = 'CUSTOM';		// Custom menu content
var TYPE_OPTION_GROUP_EXTERNAL = 'EXTERNAL';	// Links to external applications (others than the current page and inside the service)
var TYPE_OPTION_GROUP_GAUGE = 'GAUGE';			// Gauge content
var PAGEMENU_HEIGHT = 0;
var PAGEMENU_OFFSET_TOP = 67;

/*	Class: _objMenu
**
**	Provides a class used to handle the menu.
**
**	Properties:
**	optionGroups - array of @link[#_objMenuOptionGroup, _objMenuOptionGroup]
**	options - array of @link[#_objMenuOption, _objMenuOption]
**	titleOptions - array of @link[#_objTitleMenuOption, _objTitleMenuOption]
**	footerOptions - array of @link[#_objFooterMenuOption, _objFooterMenuOption]
**	index - @link [#_objMenuIndex, _objMenuIndex]
**	dropdown - array of @link[controls#_objPopup, _objPopup]
**	showGlossar - boolean default false
**	showDropdown - boolean default false
**	dropdownTimeout - integer
**	dropdownTimeoutObj - object
**
**	Methods:
**	displayIndex - @link[#_displayIndex, _displayIndex]
**	displayIndexContent - @link[#_displayIndexContent, _displayIndexContent]
**	addOptionGroup - @link[#_addOptionGroup, _addOptionGroup]
**	addOption - @link[#_addOption, _addOption]
**	addOptionMore - @link[#_addOptionMore, _addOptionMore]
**	addOptionChoise - @link[#_addOptionChoise, _addOptionChoise]
**	addOptionBack - @link[#_addOptionBack, _addOptionBack]
**	addOptionTitle - @link[#_addOptionTitle, _addOptionTitle]
**	addOptionFooter - @link[#_addOptionFooter, _addOptionFooter]
**	showHint - @link[#_showCapacityHint, _showCapacityHint]
**	displayOptions - @link[#_displayOptions, _displayOptions]
**	displayTitleOptions - @link[#_displayTitleOptions, _displayTitleOptions]
**	displayFooterOptions - @link[#_displayFooterOptions, _displayFooterOptions]
**	alignMenuOptions - @link[#_alignMenuOptions, _alignMenuOptions]
**	clearMouseTimer - @link[#_clearIndexMouseTimer, _clearIndexMouseTimer]
**	doLogout - @link[#_doMenuLogout, _doMenuLogout]
**	onMouseOutTimer - @link [#_onIndexMouseOutTimer, _onIndexMouseOutTimer]
**	onMouseOver - @link[#_onIndexMouseOver, _onIndexMouseOver]
**	onMouseOut - @link[#_onIndexMouseOut, _onIndexMouseOut]
**	onPopupShow - @link[#_onIndexPopupShow, _onIndexPopupShow]
**	onPopupHide - @link[#_onIndexPopupHide, _onIndexPopupHide]
**	handleIndexMouseOut - @link[#_handleMenuIndexMouseOut, _handleMenuIndexMouseOut]
**	handleIndexMouseOver - @link[#_handleMenuIndexMouseOver, _handleMenuIndexMouseOver]
**
**	Return:
**	object - Instance of created menu object
*/
function _objMenu()
{
	this.optionGroups = new Array;
	this.options = new Array;
	this.titleOptions = new Array;
	this.footerOptions = new Array;
	this.index = new _objMenuIndex();
	this.dropdown = new Array;
	this.showGlossar = false;
	this.showDropdown = false;
	this.dropdownTimeout = 200;		// milliseconds
	this.dropdownTimeoutObj = null;
	this.hideHelp = false;
	this.displayIndex = _displayIndex;
	this.displayIndexContent = _displayIndexContent;
	this.addOptionGroup = _addOptionGroup;
	this.addOption = _addOption;
	this.addOptionMore = _addOptionMore;
	this.addOptionChoise = _addOptionChoise;
	this.addOptionBack = _addOptionBack;
	this.addOptionTitle = _addOptionTitle;
	this.addOptionFooter = _addOptionFooter;
	this.showHint = _showCapacityHint;
	this.displayOptions = _displayOptions;
	this.displayTitleOptions = _displayTitleOptions;
	this.displayFooterOptions = _displayFooterOptions;
	this.alignMenuOptions = _alignMenuOptions;
	this.clearMouseTimer = _clearIndexMouseTimer;
	this.doLogout = _doMenuLogout;
	this.onMouseOutTimer = _onIndexMouseOutTimer;
	this.onMouseOver = _onIndexMouseOver;
	this.onMouseOut = _onIndexMouseOut;
	this.onPopupShow = _onIndexPopupShow;
	this.onPopupHide = _onIndexPopupHide;
	this.handleIndexMouseOut = _handleMenuIndexMouseOut;
	this.handleIndexMouseOver = _handleMenuIndexMouseOver;

	return this;
}

/*	Class: _objMenuOptionGroup
**
**	Provides a class for the menu option groups.
**
**	Properties:
**	options - array of @link[#_objMenuOption, _objMenuOption]
**
**	Methods:
**	addOption - @link[#_addGroupOption, _addGroupOption]
**	display - @link[#_displayOptionGroup, _displayOptionGroup]
**
**	Return:
**	object - Instance of created menu option group object
*/
function _objMenuOptionGroup(type, marginTop, marginBottom)
{
	this.options = new Array;
	this.type = type;
	this.marginTop = marginTop;
	this.marginBottom = marginBottom;
	this.addOption = _addGroupOption;
	this.display = _displayOptionGroup;
	
	return this;
}

/*	Class: _objMenuOption
**
**	Provides a class for the menu options.
**
**	Properties:
**	isPrimary - boolean
**	icon - string
**	caption - string
**	captionInfo - stirng
**	action - string
**	isLink - boolean
**	choises - array
**	groupId - integer
**	hint - string
**	isActive - boolean
**	allowDrop - boolean
**	type - @link[#Constants, Option group type]
**	
**	Methods:
**	getDisplay - @link[#_getMenuOptionDisplay, _getMenuOptionDisplay]
**
**	Return:
**	object - Instance of created menu option object
*/
function _objMenuOption(isPrimary, icon, caption, action, isLink, choises, groupId, hint, isActive, allowDrop, type)
{
	this.isPrimary = isPrimary;
	this.icon = icon;
	this.caption = caption;
	this.captionInfo = '';
	this.action = action;
	this.isLink = isLink;
	this.choises = choises;
	this.groupId = groupId;
	this.hint = hint;
	this.isActive = isActive;
	this.allowDrop = allowDrop;
	this.type = type;
	this.getDisplay = _getMenuOptionDisplay;
	
	return this;
}

/*	Class: _objTitleMenuOption
**
**	Provides a class for the title menu options.
**
**	Properties:
**	icon - string
**	caption - string
**	call - string
**	isLink - boolean
**
**	Return:
**	object - Instance of created title menu option object
*/
function _objTitleMenuOption(icon, caption, call, isLink)
{
	this.icon = icon;
	this.caption = caption;
	this.call = call;
	this.isLink = isLink;
	
	return this;
}

/*	Class: _objFooterMenuOption
**
**	Provides a class for the footer menu options.
**
**	Properties:
**	icon - string
**	caption - string
**	call - string
**	isLink - boolean
**
**	Return:
**	object - Instance of created title menu option object
*/
function _objFooterMenuOption(icon, caption, call, isLink)
{
	this.icon = icon;
	this.caption = caption;
	this.call = call;
	this.isLink = isLink;
	
	return this;
}

/*	Class: _objMenuIndex
**
**	Provides a class for the main menu.
**
**	Properties:
**	isGraphical - main menu is graphical
**	items - @link[frame_layer_menu.html#_objMenuItems, _objMenuItems] default null
**	icons - array default null
**	currentIndex - string default empty
**	activeIndex - string default empty
**
**	Methods:
**	update - @link[#_updateMenuIndex, _updateMenuIndex]
**	getIcon - @link[#_getMenuIndexIcon, _getMenuIndexIcon]
**	process - @link[#_processMenuIndexItem, _processMenuIndexItem]
**	initialize - @link[#_initializeMenuIndex, _initializeMenuIndex]
**	isOpera - @link[#_checkBrowserOpera, _checkBrowserOpera]
**	isIEMac - @link[#_checkBrowserIEMac, _checkBrowserIEMac]
**
**	Return:
**	object - Instance of created main menu object
*/
function _objMenuIndex()
{
	this.isGraphical = true;
	this.items = null;
	this.icons = null;
	this.currentIndex = '';					// index of selected main menu item
	this.activeIndex = '';					// index of hovered main menu item
	this.update = _updateMenuIndex;
	this.getIcon = _getMenuIndexIcon;
	this.process = _processMenuIndexItem;
	this.initialize = _initializeMenuIndex;
	
	this.isOpera = _checkBrowserOpera;
	this.isIEMac = _checkBrowserIEMac;

	return this;
}

/*	Function: _displayIndex
**
**	Display the main menu.
*/
function _displayIndex()
{
	var output = '';
	var menuContainer;
	var defaultOnLoadLeftDelimiter;
	var defaultOnLoadRightDelimiter;
	var defaultOnLoad = '';
	var hideItems = false;
	
	if(arguments.length > 0)
	{
		hideItems = arguments[0];
	}	
	if(!hideItems)
	{
		this.items = parent.frames['frame_menu'].menuItems.items;
		
		/*
		output = '<tr>' +
				 '<td class=\"MENUSPLITTERBOTTOM\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
				 '</tr>' +
				 '<tr>' +
				 '<td class=\"MENUSPLITTERTOP\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
				 '</tr>' +
				 '<tr>' +
				 '<td colspan=\"3\"><img src=\"' + parent.page.menuImage + '\" border=\"0\"></td>' +
				 '</tr>' +
				 '<tr>' +
				 '<td class=\"MENUSPLITTERBOTTOM\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
				 '</tr>';
		*/
		
		output = '<tr>' +
				 '<td class=\"MENUSPLITTERBOTTOM\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
				 '</tr>';
		
		document.write(output);
		
	}
	defaultOnLoad = window.onload;
	if(defaultOnLoad)
	{
		window.onload = function()
		{
			defaultOnLoad();
			menu.displayIndexContent(hideItems);
		}
	}
	else
	{
		window.onload = function()
		{
			menu.displayIndexContent(hideItems);
		}
	}
}

function _clearIndexMouseTimer()
{
	clearTimeout(this.dropdownTimeoutObj);
}

function _doMenuLogout()
{
	parent.location = '/end_session.osp?SID=' + parent.GLOBAL_SESSION_ID;
}

function _onIndexMouseOutTimer()
{
	this.dropdownTimeoutObj = setTimeout('menu.onMouseOut()', this.dropdownTimeout);
}

function _onIndexMouseOver()
{
	if(_currentPopupHandle != null)
	{
		if(_currentPopupHandle.showing)
		{
			_currentPopupHandle.hide();
		}
	}
}

function _onIndexMouseOut()
{
	if(_currentPopupHandle != null)
	{
		if(_currentPopupHandle.showing)
		{
			_currentPopupHandle.hide();
		}
	}
}

function _onIndexPopupShow()
{
	var count;
	var menuItem;
	
	for(count = 0; count < this.items.length; count++)
	{
		if(this.items[count].id == this.index.activeIndex)
		{
			menuItem = document.getElementById('menudropdown' + count);
			if(this.items[count].id == this.index.currentIndex)
			{
				menuItem.className = 'MAINMENUSELECTED CLICKABLE';
			}
			else
			{
				menuItem.className = 'MAINMENUACTIVE CLICKABLE';
			}
			//break;
		}
	}
}

function _onIndexPopupHide()
{
	var count;
	var menuItem;
	var popupObj = null;
	
	if(arguments.length > 0)
	{
		popupObj = arguments[0];
	}
	
	if(popupObj != null)
	{
		//
	}
	
	for(count = 0; count < this.items.length; count++)
	{
		if(this.items[count].id == this.index.activeIndex && this.index.activeIndex != this.index.currentIndex && popupObj != null && this.dropdown[count] == popupObj)
		{
			menuItem = document.getElementById('menudropdown' + count);
			menuItem.className = 'MAINMENU CLICKABLE';
			break;
		}
	}
}

function _handleMenuIndexMouseOver(indexObj, className, activeIndex)
{
	var count;
	var menuItem;
	var currentMenuItemIndex;
	
	if(arguments.length > 3)
	{
		currentMenuItemIndex = arguments[3];
		this.dropdown[currentMenuItemIndex].clearMouseTimer();
	}
	
	for(count = 0; count < this.items.length; count++)
	{
		if(this.items[count].id == activeIndex)
		{
			indexObj.className = className;
		}
		if(this.items[count].id == this.index.activeIndex && activeIndex != this.index.activeIndex && this.index.activeIndex != this.index.currentIndex)
		{
			menuItem = document.getElementById('menudropdown' + count);
			menuItem.className = 'MAINMENU CLICKABLE';
		}
	}
	this.index.activeIndex = activeIndex;
}

function _handleMenuIndexMouseOut(indexObj, className, activeIndex)
{
	var count;
	
	for(count = 0; count < this.items.length; count++)
	{
		if(this.items[count].id == activeIndex && activeIndex != this.index.currentIndex)
		{
			if(!this.dropdown[count].showing)
			{
				indexObj.className = className;
			}
			break;
		}
	}
}

function _displayIndexContent(hideItems)
{
	var OFFSET_LEFT = 33;
	var OFFSET_TOP = 0;
	var WIDTH = 940;
	var HEIGHT = 30;
	var INNER_HEIGHT = 30;
	var SPACER_WIDTH = 15;
	var MAX_USERNAME_LENGTH = 15;
	var USERNAME_SUFFIX = '...';
	var menuContainer;
	var menuHelp;
	var output = '';
	var count;
	var itemCount;
	var itemAction = '';
	var dropdownIcon = '/__o3sis_UICACHETOKEN__/app_pic/ico_link.gif';
	var className = '';
	var itemClassDisabled = '';
	var linkMouseEvents = '';
	var linkAction = '';
	var userName = parent.USER_NAME;
	
	if(userName.length > MAX_USERNAME_LENGTH)
	{
		// Simulation of getTooltip()...
		userName = '<span title=\"' + userName + '\">' + userName.substr(0, MAX_USERNAME_LENGTH - USERNAME_SUFFIX.length) + USERNAME_SUFFIX + '</span>';
	}
	
	this.alignMenuOptions();
	
	OFFSET_TOP = document.getElementById('imgBannerLogo').offsetHeight;

	menuContainer = document.createElement('div');
	//menuContainer.className = 'MAINMENUCUSTOM';
	menuContainer.className = 'MAINMENU';
	document.body.appendChild(menuContainer);
	menuContainer.style.position = 'absolute';
	menuContainer.style.left = OFFSET_LEFT;
	menuContainer.style.top = OFFSET_TOP;
	menuContainer.style.width = WIDTH;
	menuContainer.style.height = HEIGHT;
	
	if(!this.hideHelp)
	{
		menuHelp = document.createElement('div');
		document.body.appendChild(menuHelp);
		menuHelp.style.position = 'absolute';
		menuHelp.style.left = OFFSET_LEFT + 900;
		menuHelp.style.top = OFFSET_TOP;
		menuHelp.innerHTML = '<a href="javascript:;" onclick="parent.showContextHelp();return false"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/fragezeichen.jpg\" border="0"></a>';
		menuHelp.style.visibility = 'visible';
	}
	
	if(!hideItems)
	{
		output = '<table width=\"' + WIDTH + '\" height=\"' + HEIGHT + '\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">' +
				 '<tr>';
		for(count = 0; count < this.items.length; count++)
		{
			itemAction = this.items[count].action;
			if(this.items[count].items.length > 0)
			{
				this.dropdown[count] = new _objPopup(null, POPUP_TYPE_DROPDOWN);
				this.dropdown[count].parent = this;
				this.dropdown[count].context = 'MAINMENU';
				this.dropdown[count].setCommonIcon(dropdownIcon);
				for(itemCount = 0; itemCount < this.items[count].items.length; itemCount++)
				{
					this.dropdown[count].addItem('', this.items[count].items[itemCount].caption, this.items[count].items[itemCount].action, true, null, this.items[count].items[itemCount].disabled);
				}
				if(itemAction == '')
				{
					itemAction = this.items[count].items[0].action;
				}
				if(this.index.currentIndex != '' && this.index.currentIndex == eval(this.items[count].id))
				{
					// Current menu item is active
					className = 'MAINMENUSELECTED CLICKABLE';
					if(this.items[count].disabled)
					{
						itemClassDisabled = ' MAINMENUDISABLED';
						linkMouseEvents = '';
						linkAction = '';
					}
					else
					{
						itemClassDisabled = '';
						linkMouseEvents = ' onmouseover=\"menu.handleIndexMouseOver(this,\'MAINMENUSELECTED CLICKABLE' + itemClassDisabled + '\',\'\',' + count + '),menu.dropdown[' + count + '].display(\'menudropdown' + count + '|1\',\'\',true)\" onmouseout=\"menu.handleIndexMouseOut(this,\'MAINMENUSELECTED CLICKABLE' + itemClassDisabled + '\',\'\'),menu.onMouseOutTimer()\"';
						linkAction = ' onclick=\"location=\'' + itemAction + '\'\"';
					}
				}
				else
				{
					className = 'MAINMENU CLICKABLE';
					if(this.items[count].disabled)
					{
						itemClassDisabled = ' MAINMENUDISABLED';
						linkMouseEvents = '';
						linkAction = '';
					}
					else
					{
						itemClassDisabled = '';
						linkMouseEvents = ' onmouseover=\"menu.handleIndexMouseOver(this,\'MAINMENUACTIVE CLICKABLE' + itemClassDisabled + '\',\'' + this.items[count].id + '\',' + count + '),menu.dropdown[' + count + '].display(\'menudropdown' + count + '|1\',\'\',true)\" onmouseout=\"menu.handleIndexMouseOut(this,\'MAINMENU CLICKABLE' + itemClassDisabled + '\',\'' + this.items[count].id + '\'),menu.onMouseOutTimer()\"';
						linkAction = ' onclick=\"location=\'' + itemAction + '\'\"';
					}
				}
				output += '<td id=\"menudropdown' + count + '\" name=\"menudropdown' + count + '\" class=\"' + className + itemClassDisabled + '\" align=\"center\"' + linkMouseEvents + ' height=\"' + INNER_HEIGHT + '\" nowrap' + linkAction + '><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"' + SPACER_WIDTH + '\" height=\"' + INNER_HEIGHT + '\">' + this.items[count].caption + '<img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"' + SPACER_WIDTH + '\" height=\"' + INNER_HEIGHT + '\"></td>';
			}
			else
			{
				if(this.index.currentIndex != '' && this.index.currentIndex == eval(this.items[count].id))
				{
					// Current menu item is active
					className = 'MAINMENUSELECTED CLICKABLE';
					if(this.items[count].disabled)
					{
						itemClassDisabled = ' MAINMENUDISABLED';
						linkMouseEvents = '';
						linkAction = '';
					}
					else
					{
						itemClassDisabled = '';
						linkMouseEvents = ' onmouseover=\"menu.onMouseOver()\"';
						linkAction = ' onclick=\"location=\'' + itemAction + '\'\"';
					}
				}
				else
				{
					className = 'MAINMENU CLICKABLE';
					if(this.items[count].disabled)
					{
						itemClassDisabled = ' MAINMENUDISABLED';
						linkMouseEvents = '';
						linkAction = '';
					}
					else
					{
						itemClassDisabled = '';
						linkMouseEvents = ' onmouseover=\"this.className=\'MAINMENUACTIVE CLICKABLE' + itemClassDisabled + '\',menu.onMouseOver()\" onmouseout=\"this.className=\'MAINMENU CLICKABLE' + itemClassDisabled + '\'\"';
						linkAction = ' onclick=\"location=\'' + itemAction + '\'\"';
					}
				}
				output += '<td class=\"' + className + itemClassDisabled + '\" align=\"center\"' + linkMouseEvents + ' nowrap' + linkAction + '><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"' + SPACER_WIDTH + '\" height=\"' + INNER_HEIGHT + '\">' + this.items[count].caption + '<img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"' + SPACER_WIDTH + '\" height=\"' + INNER_HEIGHT + '\"></td>';
			}
		}
		output += '<td class=\"MAINMENU\" width=\"100%\" align=\"right\" nowrap>' + userName + '<img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"10\" height=\"' + INNER_HEIGHT + '\">|</td>' +
				  '<td class=\"MAINMENU CLICKABLE\" onmouseover=\"this.className=\'MAINMENUACTIVE CLICKABLE\'\" onmouseout=\"this.className=\'MAINMENU CLICKABLE\'\" nowrap onclick=\"menu.doLogout()\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"' + SPACER_WIDTH + '\" height=\"' + INNER_HEIGHT + '\">' + parent.LOGOUT_NAME + '<img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" align=\"absmiddle\" width=\"' + SPACER_WIDTH + '\" height=\"' + INNER_HEIGHT + '\"></td>' +
				  '<td class=\"MAINMENU\" width=\"50\" align=\"right\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"50\" height=\"' + INNER_HEIGHT + '\"></td>' +
				  '</tr>' +
				  '</table>';
	}
	
	if(parent.APPLICATION_SWITCHMODE_VERTICAL_ENABLED)
	{
		output += '<div id=\"divSwitchmodeVertical\">' +			 
				  '<a href=\"javascript:;\" onclick=\"pageAdaptor.switchSectionContentNav(PAGEADAPTOR_SWITCHMODE_VERTICAL);menu.alignMenuOptions();return false\"><img id=\"topbutton\" src=\"/__o3sis_UICACHETOKEN__/app_pic/btn_top_expand.gif\" border=\"0\" title=\"' + parent.APPLICATION_SWITCHMODE_TITLE + '"\ ></a>' +
				  '</div>';
	}
	if(parent.APPLICATION_SWITCHMODE_HORIZONTAL_ENABLED)
	{
		output += '<div id=\"divSwitchmodeHorizontal\">' +			 
				  '<a href=\"javascript:;\" onclick=\"pageAdaptor.switchSectionContentNav(PAGEADAPTOR_SWITCHMODE_HORIZONTAL);menu.alignMenuOptions();return false\"><img id=\"contentbutton\" src=\"/__o3sis_UICACHETOKEN__/app_pic/btn_content_expand.gif\" border=\"0\"></a>' +
				  '</div>';
	}
							 	
	menuContainer.innerHTML = output;
	menuContainer.style.visibility = 'visible';
	
	menu.alignMenuOptions();
	
	if(parent.APPLICATION_SWITCHMODE_VERTICAL_ENABLED && parent.appTitleRetracted)
	{
		pageAdaptor.switchSectionContentNav(PAGEADAPTOR_SWITCHMODE_VERTICAL);
		menu.alignMenuOptions();
	}
}

/*	Function: _processMenuIndexItem
**
**	Perform call.
**
**	Parameters:
**	action - string
*/
function _processMenuIndexItem(action)
{
	this.hide();
	location = action;
}

/*	Function: _getMenuIndexIcon
**
**	Retrieve the icon image path for the specified menu item.
**
**	Parameters:
**	itemId - integer
**
**	Return:
**	string - path of icon image
*/
function _getMenuIndexIcon(itemId)
{
	var retVal = '/__o3sis_UICACHETOKEN__/app_pic/';
	var count;
	
	for(count = 0; count < this.icons.length; count++)
	{
		if(itemId == this.icons[count][0])
		{
			retVal += this.icons[count][1];
			break;
		}
	}
	
	return retVal;
}

/*	Function: _initializeMenuIndex
**
**	Initialize the icon list for the main menu.
*/
function _initializeMenuIndex()
{
	this.icons = new Array;
	
	this.icons[this.icons.length] = new Array('MENU_ID_CALENDAR', 'ico_appointment.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_CATEGORIES', 'ico_categories.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_CONTACTS', 'ico_contact.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_FILES', 'dir_closed.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_MAIL', 'ico_mail_readmail.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_MOBILE_CONFIG', 'ico_otap_pref.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_NOTES', 'ico_note.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_PERSONAL', 'ico_aboutme.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_SMS', 'ico_sms.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_STARTCENTER', 'ico_start.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_SYNCHRONISATION', 'ico_sync.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_TASKS', 'ico_task_view.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_TERMS', 'ico_list.gif');
	this.icons[this.icons.length] = new Array('MENU_ID_TRASHBIN', 'ico_trashbin.gif');
}

/*	Function: _checkBrowserOpera
**
**	Check for Opera browser.
**
**	Return:
**	boolean - tells if browser is Opera or not
*/
function _checkBrowserOpera()
{
	var retVal;
	
	retVal =  (document.all && !document.styleSheets)?true:false;
	
	return retVal;
}

/*	Function: _checkBrowserIEMac
**
**	Check for MSIE on Macintosh.
**
**	Return:
**	boolean - tells if browser is MSIE on Macintosh or not
*/
function _checkBrowserIEMac()
{
	var retVal;
	
	retVal =  (document.all && navigator.platform.toLowerCase().indexOf('mac') > -1)?true:false;
	
	return retVal;
}

/*	Function: _updateMenuIndex
**
**	Update the items of the main menu by assigning a data container.
*/
function _updateMenuIndex()
{
	var count;
	var itemCount;
	var target;
	var item;
	
	this.items = parent.frames['frame_menu'].menuItems.items;
	
	if(!this.isGraphical)
	{
		target = document.form_menu.select_menu;
		while(target.options.length > 0)
		{
			target.options[target.options.length - 1] = null;
		}
	
		item = new Option(parent.MENU_START, '');
		target.options[target.options.length] = item;
		
		for(count = 0; count < this.items.length; count++)
		{
			if(this.items[count].items.length > 0)
			{
				item = new Option(this.items[count].caption, this.items[count].items[0].action);
				target.options[target.options.length] = item;
				for(itemCount = 0; itemCount < this.items[count].items.length; itemCount++)
				{
					item = new Option('> ' + this.items[count].items[itemCount].caption, this.items[count].items[itemCount].action);
					target.options[target.options.length] = item;
				}
			}
			else
			{
				item = new Option(this.items[count].caption, this.items[count].action);
				target.options[target.options.length] = item;
			}
		}
		target.selectedIndex = 0;
	}
}

/*	Function: _addOptionGroup
**
**	Add new item group to menu.
**
**	Parameters:
**	groupType - @link[#Constants, Option group type]
*/
function _addOptionGroup(groupType, marginTop, marginBottom)
{
	var newGroup;
	
	if(!groupType)
	{
		groupType = TYPE_OPTION_GROUP_DEFAULT;
	}
	if(marginTop == null)
	{
		marginTop = true;
	}
	if(marginBottom == null)
	{
		marginBottom = true;
	}
	newGroup = new _objMenuOptionGroup(groupType, marginTop, marginBottom);
	this.optionGroups[this.optionGroups.length] = newGroup;
}

/*	Function: _addGroupOption
**
**	Add new item group to menu.
**
**	Parameters:
**	isPrimary - boolean
**	icon - string
**	caption - string
**	action - string
**	isLink - boolean
**
**	Optional:
**	groupId - integer
**	hint - string
**	isActive - boolean
**	allowDrop - boolean
*/
function _addGroupOption(isPrimary, icon, caption, action, isLink)
{
	var newOption;
	var groupId = 0;
	var hint = '';
	var isActive = false;
	var allowDrop = false;
	
	if(arguments.length > 5)
	{
		if(!(arguments[5] == null || arguments[5] == ''))
		{
			groupId = arguments[5];
		}
	}
	if(arguments.length > 6)
	{
		hint = arguments[6];
	}
	if(arguments.length > 7)
	{
		isActive = arguments[7];
	}
	if(arguments.length > 8)
	{
		allowDrop = arguments[8];
	}
	
	newOption = new _objMenuOption(isPrimary, icon, caption, action, isLink, null, groupId, hint, isActive, allowDrop, this.type);
	this.options[this.options.length] = newOption;
	
	return newOption;
}

/*	Function: _displayOptionGroup
**
**	Display menu item group.
*/
function _displayOptionGroup(width)
{
	var SPACER_MARGIN_TOP = 5;
	var SPACER_MARGIN_BOTTOM = 5;
	var output = '';
	var count;
	var displayClass;
	
	if(this.options.length == 0)
	{
		return;
	}
	if(!width)
	{
		width = '100%';
	}
	
	displayClass = 'MENUOPTIONS' + this.type;
	if(this.marginTop)
	{
		output = '<tr>' +
				 '<td class=\"MENUSPLITTERTOP\" width=\"' + width + '\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"  width=\"' + width + '\" height=\"1\"></td>' +
				 '</tr>';
	}
	output += '<tr>' +
			  '<td class=\"' + displayClass + '\"  width=\"' + width + '\" height=\"' + SPACER_MARGIN_TOP + '\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"' + width + '\" height=\"' + SPACER_MARGIN_TOP + '\"></td>' +
			  '</tr>' +
			  '<tr>' +
			  '<td width=\"' + width + '\">' +
			  '<table width=\"' + width + '\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">';
	for(count = 0; count < this.options.length; count++)
	{
		output += this.options[count].getDisplay();
	}
	output += '</table>' +
			  '</td>' +
			  '</tr>' +
			  '<tr>' +
			  '<td class=\"' + displayClass + '\"  width=\"' + width + '\" height=\"' + SPACER_MARGIN_BOTTOM + '\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"' + width + '\" height=\"' + SPACER_MARGIN_BOTTOM + '\"></td>' +
			  '</tr>';
	if(this.marginBottom)
	{
		output += '<tr>' +
				  '<td class=\"MENUSPLITTERBOTTOM\" width=\"' + width + '\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"  width=\"' + width + '\" height=\"1\"></td>' +
				  '</tr>';
	}
	
	document.write(output);
}

/*	Function: _addOption
**
**	Add new item to menu.
**
**	Parameters:
**	isPrimary - boolean
**	icon - string
**	caption - string
**	action - string
**	isLink - boolean
**
**	Optional:
**	groupId - integer
**	hint - string
**	isActive - boolean
**	allowDrop - boolean
*/
function _addOption(isPrimary, icon, caption, action, isLink)
{
	var newOption;
	var groupId = 0;
	var hint = '';
	var isActive = false;
	var allowDrop = false;
	
	if(arguments.length > 5)
	{
		if(!(arguments[5] == null || arguments[5] == ''))
		{
			groupId = arguments[5];
		}
	}
	if(arguments.length > 6)
	{
		hint = arguments[6];
	}
	if(arguments.length > 7)
	{
		isActive = arguments[7];
	}
	if(arguments.length > 8)
	{
		allowDrop = arguments[8];
	}
	
	newOption = new _objMenuOption(isPrimary, icon, caption, action, isLink, null, groupId, hint, isActive, allowDrop, null);
	this.options[this.options.length] = newOption;
}

/*	Function: _addOptionMore
**
**	Add new item to menu.
**
**	Parameters:
**	icon - string
**	caption - string
**	action - string
**	isLink - boolean
*/
function _addOptionMore(icon, caption, action, isLink)
{
	var newOption;
	var groupId = 0;
	var hint = '';
	var isActive = false;
	var allowDrop = false;
	
	if(arguments.length > 4)
	{
		if(!(arguments[5] == null || arguments[5] == ''))
		{
			groupId = arguments[4];
		}
	}
	if(arguments.length > 5)
	{
		hint = arguments[5];
	}
	if(arguments.length > 6)
	{
		isActive = arguments[6];
	}
	if(arguments.length > 7)
	{
		allowDrop = arguments[7];
	}
	
	newOption = new _objMenuOption(2, icon, caption, action, isLink, null, groupId, hint, isActive, allowDrop, null);
	this.options[this.options.length] = newOption;
}

/*	Function: _addOptionChoise
**
**	Add new choise item to menu.
**
**	Parameters:
**	isPrimary - boolean
**	icon - string
**	caption - string
**	choises - array
*/
function _addOptionChoise(isPrimary, icon, caption, choises)
{
	var newOption;
	var hint = '';
	var isActive = false;
	var allowDrop = false;
	
	if(arguments.length > 4)
	{
		if(!(arguments[5] == null || arguments[5] == ''))
		{
			groupId = arguments[4];
		}
	}
	if(arguments.length > 5)
	{
		hint = arguments[5];
	}
	if(arguments.length > 6)
	{
		isActive = arguments[6];
	}
	
	newOption = new _objMenuOption(isPrimary, icon, caption, '', false, choises, groupId, hint, isActive, allowDrop, null);
	this.options[this.options.length] = newOption;
}

/*	Function: _addOptionBack
**
**	Add back item to menu.
**
**	Parameters:
**	caption - string
**	action - string
**	isLink - boolean
*/
function _addOptionBack(caption, action, isLink)
{
	var newOption;
	var hint = '';
	var isActive = false;
	var allowDrop = false;
	
	if(arguments.length > 3)
	{
		if(!(arguments[5] == null || arguments[5] == ''))
		{
			groupId = arguments[3];
		}
	}
	if(arguments.length > 4)
	{
		hint = arguments[4];
	}
	if(arguments.length > 5)
	{
		isActive = arguments[5];
	}
	
	newOption = new _objMenuOption(-1, '/__o3sis_UICACHETOKEN__/app_pic/ico_back.gif', caption, action, isLink, null, 0, hint, isActive, allowDrop, null);
	this.options[this.options.length] = newOption;
}

/*	Function: _addOptionTitle
**
**	Add new item to the title menu.
**
**	Parameters:
**	icon - string
**	caption - string
**	call - string
**	isLink - boolean
*/
function _addOptionTitle(icon, caption, call, isLink)
{
	var newOption;
	
	newOption = new _objTitleMenuOption(icon, caption, call, isLink);
	this.titleOptions[this.titleOptions.length] = newOption;
}

/*	Function: _addOptionFooter
**
**	Add new item to the footer menu.
**
**	Parameters:
**	icon - string
**	caption - string
**	call - string
**	isLink - boolean
*/
function _addOptionFooter(icon, caption, call, isLink)
{
	var newOption;
	
	newOption = new _objFooterMenuOption(icon, caption, call, isLink);
	this.footerOptions[this.footerOptions.length] = newOption;
}

/*	Function: _getMenuOptionDisplay
**
**	Provide the display content for the specified menu item.
*/
function _getMenuOptionDisplay()
{
	var LINE_HEIGHT = 24;
	var retVal = '';
	var displayClass;
	var linkClass = '';
	var linkAction = '';
	var linkMouseEvents = '';
	var linkHint = '';
	
	if(this.hint != '')
	{
		//linkHint = ' onmouseover=\"this.T_WIDTH=250; return escape(\'' + this.hint + '\')\"';
		//linkHint = ' title=\"' + this.hint + '\"';
	}
	if(this.caption.indexOf('<br>') > -1)
	{
		this.caption += '<br><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"5\">';
	}
	if(this.captionInfo != '')
	{
		this.captionInfo = '&nbsp;' + this.captionInfo;
	}
	displayClass = 'MENUOPTIONS' + this.type;
	retVal = '<tr>' +
			 '<td class=\"' + displayClass + '\" width=\"10\" height=\"' + LINE_HEIGHT + '\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"' + LINE_HEIGHT + '\"></td>' +
			 '<td class=\"' + displayClass + '\" width=\"168\" valign=\"top\">' +
			 '<table width=\"168\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">' +
			 '<tr>';
	if(this.isActive)
	{
		linkClass = displayClass + 'ACTIVELINK';
	}
	else
	{
		linkClass = displayClass + 'LINK';
	}
	if(this.isLink)
	{
		linkAction = ' href=\"' + this.action + '\"';
	}
	else
	{
		linkAction = ' href=\"javascript:;\" onclick=\"' + this.action + ';return false\"';
	}
	if(this.allowDrop && dragNDrop)
	{
		linkMouseEvents = ' onmouseover=\"dragNDrop.handleDropTarget(\'' + this.caption + '\',true)\" onmouseout=\"dragNDrop.handleDropTarget(\'' + this.caption + '\',false)\"';
	}
	else
	{
		linkMouseEvents = '';
	}
	if(this.icon == '')
	{
		retVal += '<td class=\"' + displayClass + '\" width=\"168\" height=\"' + LINE_HEIGHT + '\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + linkClass + '\"' + linkAction + linkHint + linkMouseEvents + '>' + this.caption + '</a>' + this.captionInfo + '</td>';
	}
	else
	{
		retVal += '<td class=\"' + displayClass + '\" width=\"28\" height=\"' + LINE_HEIGHT + '\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"28\" height=\"2\"><br><img src=\"' + this.icon + '\"></td>' +
				  '<td class=\"' + displayClass + '\" width=\"140\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + linkClass + '\"' + linkAction + linkHint + linkMouseEvents + '>' + this.caption + '</a>' + this.captionInfo + '</td>';
	}
	retVal += '</tr>' +
			  '</table>' +
			  '</td>' +
			  '<td class=\"' + displayClass + '\" width=\"10\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\"></td>' +
			  '</tr>';
	
	return retVal;
}

/*	Function: _displayOptions
**
**	Display the specified menu items.
**
**	Parameters:
**	primary - boolean / integer [-2,-1,2]
*/
function _displayOptions(primary)
{
	var LINE_HEIGHT = 30;
	var output = '';
	var count;
	var choiseCount;
	var currOption = null;
	var optionsFound = 0;
	var displayClass = 'MENUOPTIONS';
	var groupId = 0;
	var hint = '';
	
	if(arguments.length > 1)
	{
		groupId = arguments[1];
	}
	
	if(primary != -2)
	{
		if(primary == -1)
		{
			displayClass = 'MENUBACK';
			for(count = 0; count < this.options.length ; count++)
			{
				currOption = this.options[count];
				hint = '';
				if(currOption.hint != '')
				{
					hint = ' onmouseover=\"this.T_WIDTH=250; return escape(\'' + currOption.hint + '\')\"';
				}
				if(currOption.isPrimary == -1)
				{
					optionsFound++;
					output = '<tr>' +
							 '<td class=\"MENUSPLITTERTOP\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
							 '</tr>' +
					 		 '<tr class=\"' + displayClass + '\">' +
							 '<td width=\"10\" height=\"' + LINE_HEIGHT + '\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"' + LINE_HEIGHT + '\"></td>' +
							 '<td width=\"168\" valign=\"top\">' +
							 '<table width=\"168\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">' +
							 '<tr>';
					if(currOption.icon == '')
					{
						if(currOption.isLink)
						{
							if(currOption.isActive)
							{
								output += '<td width=\"168\" colspan=\"2\"><a class=\"' + displayClass + 'ACTIVELINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
							}
							else
							{
								output += '<td width=\"168\" colspan=\"2\"><a class=\"' + displayClass + 'LINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
							}
						}
						else
						{
							if(currOption.isActive)
							{
								output += '<td width=\"168\"><a class=\"' + displayClass + 'ACTIVELINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a></td>';
							}
							else
							{
								output += '<td width=\"168\"><a class=\"' + displayClass + 'LINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a></td>';
							}
						}
					}
					else
					{
						output += '<td width=\"28\" height=\"' + LINE_HEIGHT + '\"><img src=\"' + currOption.icon + '\"></td>';
						if(currOption.isLink)
						{
							if(currOption.isActive)
							{
								output += '<td width=\"140\"><a class=\"' + displayClass + 'ACTIVELINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
							}
							else
							{
								output += '<td width=\"140\"><a class=\"' + displayClass + 'LINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
							}
						}
						else
						{
							if(currOption.isActive)
							{
								output += '<td width=\"140\"><a class=\"' + displayClass + 'ACTIVELINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a></td>';
							}
							else
							{
								output += '<td width=\"140\"><a class=\"' + displayClass + 'LINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a></td>';
							}
						}
					}
					output += '</tr>' +
							  '</table>' +
							  '</td>' +
							  '<td width=\"10\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\"></td>' +
							  '</tr>' +
							  '<tr>' +
							  '<td class=\"MENUSPLITTERBOTTOM\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
							  '</tr>';
					break;
				}
			}
		}
		else
		{
			if(primary == false)
			{
				displayClass = 'MENUCONTROLS';
			}
			else
			{
				if(primary == 2)
				{
					displayClass = 'MENUOPTIONS';
				}
			}
			output = '<tr>' +
					 '<td class=\"MENUSPLITTERTOP\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
					 '</tr>' +
					 '<tr>' +
					 '<td class=\"' + displayClass + '\" height=\"5\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"5\"></td>' +
					 '</tr>' +
					 '<tr class=\"' + displayClass + '\">' +
					 '<td width=\"10\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\"></td>' +
					 '<td width=\"168\" valign=\"top\">' +
					 '<table width=\"168\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">';
			for(count = 0; count < this.options.length ; count++)
			{
				currOption = this.options[count];
				hint = '';
				if(currOption.hint != '')
				{
					hint = ' title=\"' + currOption.hint + '\"';
				}
				if(groupId > 0 && currOption.groupId != groupId)
				{
					continue;
				}
				if(currOption.isPrimary == primary)
				{
					optionsFound++;
					output += '<tr>';
					if(currOption.icon == '')
					{
						if(currOption.choises == null)
						{
							if(currOption.isLink)
							{
								if(currOption.isActive)
								{
									output += '<td width=\"168\" height=\"' + LINE_HEIGHT + '\" valign=\"top\" colspan=\"2\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'ACTIVELINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
								}
								else
								{
									output += '<td width=\"168\" height=\"' + LINE_HEIGHT + '\" valign=\"top\" colspan=\"2\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'LINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
								}
							}
							else
							{
								if(currOption.isActive)
								{
									output += '<td width=\"168\" height=\"' + LINE_HEIGHT + '\" valign=\"top\" colspan=\"2\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'ACTIVELINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a>';
								}
								else
								{
									output += '<td width=\"168\" height=\"' + LINE_HEIGHT + '\" valign=\"top\" colspan=\"2\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'LINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a>';
								}
							}
						}
						else
						{
							if(currOption.isActive)
							{
								output += '<td width=\"140\" height=\"' + LINE_HEIGHT + '\" class=\"' + displayClass + 'ACTIVE\">' + currOption.caption + '&nbsp;';
							}
							else
							{
								output += '<td width=\"140\" height=\"' + LINE_HEIGHT + '\" class=\"' + displayClass + '\">' + currOption.caption + '&nbsp;';
							}
						}
					}
					else
					{
						output += '<td width=\"28\" height=\"' + LINE_HEIGHT + '\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"28\" height=\"2\"><br><img src=\"' + currOption.icon + '\"></td>';
						if(currOption.choises == null)
						{
							if(currOption.isLink)
							{
								if(currOption.isActive)
								{
									output += '<td width=\"140\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'ACTIVELINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
								}
								else
								{
									output += '<td width=\"140\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'LINK\" href=\"' + currOption.action + '\"' + hint + '>' + currOption.caption + '</a></td>';
								}
							}
							else
							{
								if(currOption.isActive)
								{
									output += '<td width=\"140\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'ACTIVELINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a>';
								}
								else
								{
									output += '<td width=\"140\" valign=\"top\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"2\" border=\"0\"><br><a class=\"' + displayClass + 'LINK\" href=\"javascript:;\" onclick=\"' + currOption.action + ';return false\"' + hint + '>' + currOption.caption + '</a>';
								}
							}
						}
						else
						{
							if(currOption.isActive)
							{
								output += '<td width=\"140\" class=\"' + displayClass + 'ACTIVE\">' + currOption.caption + '&nbsp;';
							}
							else
							{
								output += '<td width=\"140\" class=\"' + displayClass + '\">' + currOption.caption + '&nbsp;';
							}
						}
					}
					if(currOption.choises == null)
					{
						if(currOption.caption.indexOf('<br>') > -1)
						{
							output += '<br><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"5\">';
						}
						output += '</td>';
					}
					else
					{
						for(choiseCount = 0; choiseCount < currOption.choises.length; choiseCount++)
						{
							if(choiseCount > 0)
							{
								output += '&nbsp;|&nbsp;';
							}
							if(currOption.isLink)
							{
								output += '<a class=\"' + displayClass + 'LINK\" href=\"' + currOption.choises[choiseCount][1] + '\"' + hint + '>' + currOption.choises[choiseCount][0] + '</a>';
							}
							else
							{
								output += '<a class=\"' + displayClass + 'LINK\" href=\"javascript:;\" onclick=\"' + currOption.choises[choiseCount][1] + ';return false\"' + hint + '>' + currOption.choises[choiseCount][0] + '</a>';
							}
						}
						output += '</td>';
					}
					output += '</tr>';
				}
			}
			output += '</table>' +
					  '</td>' +
					  '<td width=\"10\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\"></td>' +
					  '</tr>' +
					  '<tr>' +
					  '<td class=\"' + displayClass + '\" height=\"5\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"5\"></td>' +
					  '</tr>' +
					  '<tr>' +
					  '<td class=\"MENUSPLITTERBOTTOM\" colspan=\"3\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\"></td>' +
					  '</tr>';
		}
	}
	
	if(optionsFound == 0)
	{
		output = '';
	}
	
	document.write(output);
}

/*	Function: _displayTitleOptions
**
**	Display the specified menu items next to the page title.
*/
function _displayTitleOptions()
{
	var output = '';
	var count;
	var currOption = null;
	
	for(count = 0; count < this.titleOptions.length; count++)
	{
		currOption = this.titleOptions[count];
		if(count > 0)
		{
			output += '<img align=\"absmiddle\" src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\">|<img align=\"absmiddle\" src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\">';
		}
		output += '<img align=\"absmiddle\" src=\"' + currOption.icon + '\">' +
				  '<img align=\"absmiddle\" src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"5\" height=\"1\">';
		if(currOption.call == '')
		{
			output += currOption.caption;
		}
		else
		{
			if(currOption.isLink)
			{
				output += '<a href=\"' + currOption.call + '\">' + currOption.caption + '</a>';
			}
			else
			{
				output += '<a href=\"javascript:;\" onclick=\"' + currOption.call + ';return false\">' + currOption.caption + '</a>';
			}
		}
	}
	
	document.write(output);
}

/*	Function: _displayFooterOptions
**
**	Display the specified menu items before the page footer.
*/
function _displayFooterOptions(colSpan)
{
	var output = '';
	var count;
	var currOption = null;
	
	if(this.footerOptions.length == 0)
	{
		return;
	}
	
	currOption = this.footerOptions[0];
	output = '<tr>' +
			 '<td colspan=\"' + colSpan + '\" valign=\"bottom\">' +
			 '<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">' +
			 '<tr>' +
			 '<td height=\"10\" colspan=\"2\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"10\"></td>' +
			 '</tr>' +
			 '<tr>' +
			 '<td class=\"CONTENTSPLITTER\" height=\"1\" colspan=\"2\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"1\"></td>' +
			 '</tr>' +
			 '<tr>' +
			 '<td class="APPOPTIONS" width=\"100%\" height=\"25\" align=\"right\" nowrap><img align=\"absmiddle\" src=\"' + currOption.icon + '\">' +
			 '<img align=\"absmiddle\" src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"5\" height=\"1\">';
	if(currOption.call == '')
	{
		output += currOption.caption;
	}
	else
	{
		if(currOption.isLink)
		{
			output += '<a href=\"' + currOption.call + '\">' + currOption.caption + '</a>';
		}
		else
		{
			output += '<a href=\"javascript:;\" onclick=\"' + currOption.call + ';return false\">' + currOption.caption + '</a>';
		}
	}
	output += '</td>' +
			  '<td width=\"10\" height=\"1\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"10\" height=\"1\"></td>' +
			  '</tr>' +
			  '</table>' +
			  '</td>' +
			  '</tr>';
	
	document.write(output);
}

function _alignMenuOptions()
{
	var SUB_MENU_OFFSET = 30;	// Vertical offset between page menu and sub menu
	var pageMenu;
	var pageSubMenu;
	var node;
	
	if (!document.getElementById('divContentNavLEFT'))
	{
		pageMenu = document.getElementById('divContentNavTOPLEFT');
	}
	else
	{
		pageMenu = document.getElementById('divContentNavLEFT');
	}

	if(pageMenu)
	{
		pageMenu.style.top = document.getElementById('imgBannerLogo').offsetHeight + PAGEMENU_OFFSET_TOP;
		
		node = document.createElement('DIV');
		node["id"]="divContentNavLEFTChild";
		
		if(bw.ns6 || bw.ns7)
		{		
  		    //workarround bw.ns6 || bw.ns7 => only first init must be Zero
			node.style.cssText='height:' + PAGEMENU_HEIGHT + '; position: absolute; top: ' + pageMenu.offsetTop + '; left: ' + pageMenu.offsetLeft + ';';		
		}
		else
		{
			node.style.cssText='height:' + PAGEMENU_HEIGHT + '; position: absolute; top: 0; left: 0;';
		}

		if(document.getElementById('divContentNavLEFTChild'))
		{
		  pageMenu.removeChild(document.getElementById('divContentNavLEFTChild'));
		}
		else
		{
  		  //workarround bw.ns6 || bw.ns7 => only first init must be Zero
		  PAGEMENU_HEIGHT = pageMenu.offsetHeight;
  		  node.style.cssText='height:' + pageMenu.offsetHeight + '; position: absolute; top: 0; left: 0;';
		}
		
		node.top = pageMenu.offsetTop;
		pageMenu.appendChild(node);
	}	
	
	pageSubMenu = document.getElementById('divContentSubNavLEFT');
	
	if(pageSubMenu)
	{
		pageSubMenu.style.top = pageMenu.offsetTop + pageMenu.offsetHeight + SUB_MENU_OFFSET;
	}
}

/*	Name: capacity
**
**	Holds the reference to the capacity object @link[#_objCapacity, _objCapacity].
*/
var capacity = new _objCapacity();

/*	Name: Constants
**
**	CAPACITY_BAR_START - Starting position of capacity pointer
**	CAPACITY_BAR_WIDTH - Width of the capacity bar
**	CAPACITY_POINTER_OVERSIZE - Negative size of pointer
*/
var CAPACITY_BAR_START = 8;
var CAPACITY_BAR_WIDTH = 64;
var CAPACITY_POINTER_OVERSIZE = 5;

/*	Class: _objCapacity
**
**	Provides a class for the capacity information.
**
**	Properties:
**	value - integer default -1
**	size - integer default 0
**	caption - string default empty
**	captionFull - string default empty
**	hint - string default empty
**	hintWidth - integer default 0
**	hintContainer - string default empty
**
**	Methods:
**	setValue - @link[#_setCapacityValue, _setCapacityValue]
**	setCaption - @link[#_setCapacityCaption, _setCapacityCaption]
**	setCaptionFull - @link[#_setCapacityCaptionFull, _setCapacityCaptionFull]
**	setHint - @link[#_setCapacityHint, _setCapacityHint]
**	showHint - @link[#_showCapacityHint, _showCapacityHint]
**	hideHint - @link[#_hideCapacityHint, _hideCapacityHint]
**	display - @link[#_displayCapacity, _displayCapacity]
**
**	Return:
**	object - Instance of created capacity object
*/
function _objCapacity()
{
	this.value = -1;
	this.size = 0;
	this.caption = '';
	this.captionFull = '';
	this.hint = '';
	this.hintWidth = 0;
	this.hintContainer = '';
	this.setValue = _setCapacityValue;
	this.setCaption = _setCapacityCaption;
	this.setCaptionFull = _setCapacityCaptionFull;
	this.setHint = _setCapacityHint;
	this.showHint = _showCapacityHint;
	this.hideHint = _hideCapacityHint;
	this.display = _displayCapacity;
	
	return this;
}

/*	Function: _setCapacityValue
**
**	Sets the value for the capacity info.
**
**	Parameters:
**	value - integer
*/
function _setCapacityValue(value)
{
	this.value = value;
	this.size = CAPACITY_BAR_START + CAPACITY_BAR_WIDTH * this.value / 100 - CAPACITY_POINTER_OVERSIZE;
}

/*	Function: _setCapacityCaption
**
**	Sets the caption for the capacity info.
**
**	Parameters:
**	caption - string
*/
function _setCapacityCaption(caption)
{
	this.caption = caption;
}

/*	Function: _setCapacityCaptionFull
**
**	Sets the caption for the capacity info when capacity reached.
**
**	Parameters:
**	captionFull - string
*/
function _setCapacityCaptionFull(captionFull)
{
	this.captionFull = captionFull;
}

/*	Function: _setCapacityHint
**
**	Sets the hint for the capacity info (used on mouseover).
**
**	Parameters:
**	hint - string
**	used - integer
**	total - integer
**	container - string
**	width - integer
*/
function _setCapacityHint(hint, used, total, container, width)
{
	hint = hint.replace(/%i/, total);
	hint = hint.replace(/%i/, used);
	/*
	this.hint = '<table class=\"MENUCAPACITYHINT\" width=\"' + width + '\" cellspacing=\"0\" cellpadding=\"2\">' +
				'<tr>' +
				'<td width=\"' + width + '\">' +
				hint +
				'</td>' +
				'</tr>' +
				'</table>';
	*/
	this.hint = hint;
	this.hintContainer = container;
	this.hintWidth = width;
}

/*	Function: _showCapacityHint
**
**	Shows the hint for the capacity info.
**
**	Parameters:
**	mouseEvent - browser event object
*/
function _showCapacityHint(mouseEvent)
{
	var container;
	var containerShadow;
	
	container = document.getElementById(this.hintContainer);
	if(container)
	{
		if(document.all && !(bw.op8 || bw.mac))
		{
			containerShadow = document.getElementById(this.hintContainer + 'Shadow');
			if(containerShadow == null)
			{
				containerShadow = document.createElement('iframe');
				containerShadow.setAttribute('id', this.hintContainer + 'Shadow');
				containerShadow.scrolling = 'no';
				document.body.appendChild(containerShadow);
			}
			containerShadow.style.position = 'absolute';
			containerShadow.style.zIndex = 100;
			containerShadow.style.visibility = 'hidden';
		}
		
		container.style.zIndex = 101;
		container.style.width = this.hintWidth;
		container.innerHTML = this.hint;
		if(bw.ns6 || bw.ns7)
		{
			container.style.left = mouseEvent.pageX;
			container.style.top = mouseEvent.pageY + 16;
		}
		else
		{
			container.style.left = mouseEvent.clientX + document.body.scrollLeft;
			container.style.top = mouseEvent.clientY + 16 + document.body.scrollTop;
		}
		
		if(document.all && !(bw.op8 || bw.mac))
		{
			containerShadow.style.left = container.offsetLeft;
			containerShadow.style.top = container.offsetTop;
			containerShadow.style.width = container.offsetWidth;
			containerShadow.style.height = container.offsetHeight;
			containerShadow.style.visibility = 'visible';
		}
		container.style.visibility = 'visible';
	}
}

/*	Function: _hideCapacityHint
**
**	Hides the hint for the capacity info.
*/
function _hideCapacityHint()
{
	var container;
	var containerShadow;
	
	containerShadow = document.getElementById(this.hintContainer + 'Shadow');
	if(containerShadow)
	{
		containerShadow.style.visibility = 'hidden';
	}
	container = document.getElementById(this.hintContainer);
	if(container)
	{
		container.style.visibility = 'hidden';
	}
}

/*	Function: _displayCapacity
**
**	Display the capacity bar and info.
**	If the optional parameter /container/ is provided, it will be used to determine the container for the capacity info. Used when needed to be updated dynamically.
**
**	Optional:
**	container - object
*/
function _displayCapacity()
{
	var output = '';
	var objContainer = null;
	
	if(arguments.length > 0)
	{
		if(arguments[0] != null)
		{
			objContainer = arguments[0];
		}
	}
	
	output = '<tr>' +
			 '<td class=\"MENUSPLITTERTOP\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\"></td>' +
			 '</tr>' +
			 '<tr>' +
			 '<td height=\"5\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"5\"></td>' +
			 '</tr>' +
			 '<tr>' +
			 '<td height=\"19\">' +
			 '<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">' +
			 '<tr>' +
			 '<td class=\"MENUCAPACITY\" width=\"5\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"5\" height=\"19\"></td>' +
			 '<td width=\"83\" nowrap><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"8\" height=\"8\"><script language=\"JavaScript\" type=\"text/javascript\">controls.displayProgressBar(' + this.value + ', 55);</script></td>' +
			 '<td class=\"MENUINFO\" width=\"100%\" valign=\"bottom\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"6\"><br><a class=\"MENUINFOLINK\" href=\"javascript:;\" onclick=\"return false\" onmouseover=\"this.T_WIDTH=250; return escape(\'' + this.hint + '\')\">';
	if(this.value >= 100)
	{
		output += this.captionFull;
	}
	else
	{
		output += this.value + this.caption;
	}
	output += '</a>' +
			  '</td>' +
			  '<td width=\"7\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"7\" height=\"1\"></td>' +
			  '</tr>' +
			  '</table>' +
			  '</td>' +
			  '</tr>' +
			  '<tr>' +
			  '<td height=\"10\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"10\"></td>' +
			  '</tr>' +
			  '<tr>' +
			  '<td class=\"MENUSPLITTERBOTTOM\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\"></td>' +
			  '</tr>';
	
	if(this.value == -1)
	{
		output = '';
	}
	
	if(objContainer != null)
	{
		output = '<table class=\"MENUINFO\" width=\"188\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">' +
				 '<tr>' +
				 '<td class=\"MENUCAPACITY\" width=\"77\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"' + (this.size) + '\" height=\"19\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/capacity_arrow.gif\" width=\"9\" height=\"19\"></td>' +
				 '<td class=\"MENUINFO\" width=\"103\" valign=\"bottom\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"1\" height=\"6\"><br>&nbsp;&nbsp;<a class=\"MENUINFOLINK\" href=\"javascript:;\" onclick=\"return false\" onmouseover=\"this.T_WIDTH=250; return escape(\'' + this.hint + '\')\">';
		if(this.value >= 100)
		{
			output += this.captionFull;
		}
		else
		{
			output += this.value + this.caption;
		}
		output += '</a>' +
				  '</td>' +
				  '<td width=\"7\"><img src=\"/__o3sis_UICACHETOKEN__/app_pic/1x1_trans.gif\" width=\"7\" height=\"1\"></td>' +
				  '</tr>' +
				  '</table>';
		objContainer.innerHTML = output;
		//return output;
	}
	else
	{
		document.write(output);
	}
}


