/* Author: Intelligent Integration */
/* Creation date: 30/07/2003 */
/* Last modofied: 05/08/2003 */

	var activeMenu = '';
	var compliant = true;
	var browserID = navigator.userAgent.toLowerCase();
	var operaLoc = browserID.indexOf('opera');
	var geckoLoc = browserID.indexOf('gecko');
	if (operaLoc != -1)  // This an Opera browser so check for version number.
	{
		var majorVer = parseInt(browserID.substr(operaLoc + 6));
		if (majorVer < 7) compliant = false;
	}
	
	function breakOutOfFrames()
	{
		if (self.parent.frames.length != 0)
			window.top.location.replace(self.location.href);
	}
	
	function dropMenu(thisMenu)
	{
		// Extract the name specific part from the top menu id
		// and create the id of the dropdown menu.
		var str, dropDownId;
		str = new String(thisMenu.id);
		str = str.substr(2);
		dropDownId = 'dm' + str;
		if (!(dropDownId == activeMenu)) closeActiveMenu();
		thisMenu.style.color = '#FFFFFF';
		thisMenu.style.backgroundColor = '#087442';
		document.getElementById(dropDownId).style.visibility = 'visible';
		activeMenu = dropDownId;
	}
	
	function hideDropMenu(thisMenu, e)
	{
		// This function is actioned by the dropdown menu's 'onMouseOut' event.
		// However, if the mouse has moved over a menu item contained within the
		// menu, then we dont want the menu to close.
		var current, related;
		if (window.event)
		{
			current = thisMenu;
			related = e.toElement;
		}
		else
		{
			current = e.currentTarget;
			related = e.relatedTarget;
		}
		// This next line of code added because mozilla based browsers seem to pick up
		// a text node at a different level.
		if (related.nodeType == 3) related = related.parentNode;
		if ((current != related) && !contains(current, related))
		{
	//		thisMenu.style.visibility = 'hidden';
	//		activeMenu = '';
			closeActiveMenu();
		}
	}
	
	function contains(a, b)
	{
		// Returns true if node a contains node b.
		if (b.parentNode)
			if (b.parentNode == a)
				return true;
		return false;
	}
	
	function closeActiveMenu()
	{
		if (!(activeMenu == ''))
		{
			document.getElementById(activeMenu).style.visibility = 'hidden';
			// Extract the name specific part from the top menu id
			// and create the id of the dropdown menu.
			var str, topMenuId;
			str = new String(activeMenu);
			str = str.substr(2);
			topMenuId = 'tm' + str;
			document.getElementById(topMenuId).style.color = '#087442';
			document.getElementById(topMenuId).style.backgroundColor = '#FFFFFF';
		}
	}
	
	function greyThisMenuItem(thisMenuItem, prefix)
	{		
		// This function tales a menu item in as a parameter.
		// This item is then changed from an active <a> link to a <span> element with its
		// text greyed.
		var parentItem = thisMenuItem.parentNode;
		var textNode = thisMenuItem.firstChild;
		var newNode = document.createElement('span');
		if (prefix == 'tm') newNode.className = 'navlinkgrey';
		if (prefix == 'dm') newNode.className = 'dmlinkgrey';
		newNode.appendChild(textNode);
		parentItem.replaceChild(newNode, thisMenuItem);
	}
	
	function greyLinks()
	{
		if (compliant)
		{
			if (document.getElementById('nav' + pageName)) 
				greyThisMenuItem(document.getElementById('nav' + pageName), 'nav');
			if (document.getElementById('dm' + pageName))
				greyThisMenuItem(document.getElementById('dm' + pageName), 'dm');
			if (document.getElementById('tm' + pageName))
				greyThisMenuItem(document.getElementById('tm' + pageName), 'tm');
		}
	}
		
	function validate()
	{
		var returnValue = true;
		if (document.message.Name.value == "") {
			returnValue = false;
			alert("Please complete the Name: field");
			document.getElementById('nameField').focus();
		}
		else 
		if (document.message.Telephone.value == "") {
			returnValue = false;
			alert("Please complete the Telephone: field");
			document.getElementById('telField').focus();
		}
		if (returnValue == true) document.message.realname.value = document.message.Name.value;
		return returnValue;
	}

	function setFocus()
	{
		document.getElementById('nameField').focus();
	}
	
	var menuTimer;
	
	function setMenuTimer()
	{
		menuTimer = setTimeout("closeActiveMenu(true)", 100);
	}
	
	function clearMenuTimer()
	{
		clearTimeout(menuTimer);
	}
	
	window.onLoad = breakOutOfFrames();