<!--
// Initialize ID values for sub-menus. Changes can be made here without modifying in function itself.
var list2id = 'prodDemoList';
var spawn2id = 'prodDemoMenuSpawn';
var list3id = 'pricingOptionsList';
var spawn3id = 'pricingOptionsSpawn';
var list4id = 'navitourMenuList';
var spawn4id = 'navitourMenuSpawn';
var list1, spawn1, list2, spawn2, list3, spawn3, list4, spawn4;
var inList = false; //used for list4 (in secondaryMenu)
var inSpawn = false; //used for spawn4 (in secondaryMenu)


//////////////////////////////////////////////////////////////////////////////////////
//
// setSubMenus()
//
// - Initializes the menu 'onmouseover' and 'onmouseout' actions. Also positions the
//   menus vertically on the first page and the 4th popup menu horizontally for all pages.
//   Removes heading background graphic on the main/default page, and calls other scripts
//   required 'onload' for all pages.
// - Called at 'window.onload' for all pages.
//////////////////////////////////////////////////////////////////////////////////////

function setSubMenus()
{	//Set references to each object
	if (document.getElementById)   //most browsers should now have this capability
	{
		spawn2 = document.getElementById(spawn2id);
		list2 = document.getElementById(list2id);
		spawn3 = document.getElementById(spawn3id);
		list3 = document.getElementById(list3id);
		spawn4 = document.getElementById(spawn4id);
		list4 = document.getElementById(list4id);
	}
	else if (document.all)        //old IE model
	{
		spawn2 = document.all[spawn2id];
		list2 = document.all[list2id];
		spawn3 = document.all[spawn3id];
		list3 = document.all[list3id];
		spawn4 = document.all[spawn4id];
		list4 = document.all[list4id];
	}
	else return;

	//set mouseover, mouseout behaviour for menus
	//Set inSpawn true when mousing over "About Comnet". Set inList true when mousing over its submenu.
	spawn2.onmouseover = function () { try {list2.style.display = 'block';} catch(e) {} }
	spawn2.onmouseout = spawn2MouseOut;
	list2.onmouseout = list2MouseOut;
	spawn3.onmouseover = function () { try {list3.style.display = 'block';} catch(e) {} }
	spawn3.onmouseout = spawn3MouseOut;
	list3.onmouseout = list3MouseOut;
	spawn4.onmouseover = function () { try {list4.style.display = 'block'; inSpawn = true;} catch(e) {} }
	spawn4.onmouseout = spawn4MouseOut;
	list4.onmouseover = function () {inList = true;}
	list4.onmouseout = list4MouseOut;

	//Set position of list4 on all pages based on where it spawns from
	list4.style.left = findPosX(spawn4) + 10 + 'px';  //10 is added to compensate for uncalculated border
}


//////////////////////////////////////////////////////////////////////////////////////
//
// list1MouseOut(e), spawn1MouseOut(e), list2MouseOut(e), spawn2MouseOut(e),
//   	list3MouseOut(e), spawn3MouseOut(e), list4MouseOut(e), spawn4MouseOut(e)
//
// - Defines the 'onmouseout' functions called in function 'init'.
// - Used in function 'init'.
//////////////////////////////////////////////////////////////////////////////////////


function list2MouseOut(e)
{
	//Checks if event details were passed. Cross-browser compatability achieved
	if (!e) var e = window.event;
	var target = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if (target == 'undefined' || target == null || target.className == 'prodDemoElem') return;
	try { list2.style.display = 'none'; }
	catch(e) { }
}

function spawn2MouseOut(e)
{
	if (!e) var e = window.event;
	var target = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if (target == 'undefined' || target == null || target.className == 'prodDemoElem') return;
	// Mouseout took place when mouse left the list
	try { list2.style.display = 'none'; }
	catch(e) { }
}

function list3MouseOut(e)
{
	//Checks if event details were passed. Cross-browser compatability achieved
	if (!e) var e = window.event;
	var target = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if (target == 'undefined' || target == null || target.className == 'pricingMenuElem') return;
	try { list3.style.display = 'none'; }
	catch(e) { }
}

function spawn3MouseOut(e)
{
	if (!e) var e = window.event;
	var target = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if (target == 'undefined' || target == null || target.className == 'pricingMenuElem') return;
	// Mouseout took place when mouse left the list
	try { list3.style.display = 'none'; }
	catch(e) { }
}

function list4MouseOut(e)
{
	inList = false; //Since the list has been left
	//Checks if event details were passed. Cross-browser compatability achieved
	if (!e) var e = window.event;
	var target = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if (target == 'undefined' || target == null || target.className == 'aboutMenuElem') return;
	try { list4.style.display = 'none'; }
	catch(e) { }
}

function spawn4MouseOut(e)
{
	inSpawn = false; //Since the spawning element has been left
	if (!e) var e = window.event;
	var target = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	if (target == 'undefined' || target == null || target.className == 'aboutMenuElem') return;
	//From link in menu to the popup box isn't seamless. Script needs slight delay or the menu can't be reached
	if (target.id == 'secondaryMenuList')
	{ 
		window.setTimeout(s4close,1500);
	}
	else   //Mouseout took place when mouse left the list
	{
		try { list4.style.display = 'none'; }
		catch(e) { }
	}
}

function s4close()
{
	if (inList || inSpawn) return; //Don't close menu if mouse is in the submenu or on "About Comnet" link
	else
	{
		try { list4.style.display = 'none'; }
		catch(e) { }
	}
}




//////////////////////////////////////////////////////////////////////////////////////
//
// thisMenuHighlight()
//
// - Applies the 'selected' class to the menu item with the same 'id' as the current page.  Can then
//   style the current page's link differently so that the user knows where they are.
// - Called from function 'init'.
//////////////////////////////////////////////////////////////////////////////////////

function thisMenuHighlight() {
	var page = currentPage();
	var pageElem;
	// Select the link matching the page
	try { pageElem = document.getElementById(page); }
	catch(e) { return; } //if no matching element found, kill script
	pageElem.className = 'selected'; //style the matching link
	}


//////////////////////////////////////
// findPosX(obj)
//
// - Gets the horizontal offset of an object on the screen.
// - Used in function 'init' to position the "About Comnet" menu.
// - CREDIT: This script written by Peter-Paul Koch of www.quirksmode.org.
/////////////////////////////////////
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}



//////////////////////////////////////////////////////////////////////////////////////
//
// currentPage()
//
// - Returns the current page/directory.
// - Called in functions 'thisMenuHighlight' and 'scaleFont'.
// - WARNING: When moving to live environment, the format of the URL may be different (ie, the 'app'
//   directory no longer appears.  In this case, must be modified, where 'app' is replaced with
//   the name of the displayed part of the URL immediately prior to the current directory.
//////////////////////////////////////////////////////////////////////////////////////

function currentPage() {
	var url = document.URL;
	var idxApp = url.indexOf('app');
	var idxStart = idxApp + 4;
	var idxEnd = url.indexOf('/',idxStart);
	var thisPage = url.substring(idxStart,idxEnd);
	return thisPage;
	}

//-->
