// globals - browser detection 
var isIE = false;
var isNavigator = false;
var isOpera = false;

function DetectBrowser()
{
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);
	
	// common is ie check up
	var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

	// common is navigator check up
	var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
				&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
				&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));

	// common 'is opera?' check up
	var is_opera = (agt.indexOf("opera") != -1);
							
	isIE = (is_ie && (is_major >= 4));			
	isNavigator = (is_nav && (is_major >= 4));	
	isOpera = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);	
	document.onClick = true;
	
}


function SelectSubNav(row)
{		
		row.className = "SelectedSubNav";
		SwapLinkStyle(row, 1)		
}

function DeselectSubNav(row)
{
		row.className = "";
		SwapLinkStyle(row, 2)
}

function GoTo(toUrl)
{
	if (isIE || isNavigator)
	{		
		document.location = toUrl;
	}
	
}

function SwapLinkStyle(row, state)
{
	if (isIE)
	{
		switch (state) 
		{
			case 1:
				row.children[1].children[0].className = 'TrainTopLinkHover';
				break;
			case 2:
				row.children[1].children[0].className = 'TrainTopLink';
				break;
		}		
	}	
}


function GetParentRow(obj)
{
	
		if (obj.nodeName == 'TR') return obj;
			
		if (isIE) 
		{
			obj = obj.parentElement;
			while ( (typeof(obj) != 'undefined')) 
			{
				if (obj.nodeName == 'TR')
				{
					return obj;
				}
				obj = obj.parentElement;
			}
			return null;				
		} 
		else if (isNavigator)
		{
			obj = obj.parentNode;
			while ( (typeof(obj) != 'undefined')) 
			{
				if (obj.nodeName == 'TR')
				{
					return obj;
				}
				obj = obj.parentNode;
			}
			return null;			
		}
}

/**
	Added by Azam on May 09, outside of VSS
*/
function SelectSubMenu(row)
{		
		row.className = "SelectedSubNav";
		SwapCellStyle(row, 1)		
}

function DeselectSubMenu(row)
{
		row.className = "";
		SwapCellStyle(row, 2)		
		
}

function SwapCellStyle(row, state)
{
	if (isIE)
	{
		switch (state) 
		{
			case 1:
				row.children[1].className = 'SubMenuCell2';
				break;
			case 2:
				row.children[1].className = 'SubMenuCell1';
				break;
		}		
	}	
}

/**
	Added by Azam on May 09, outside of VSS
*/