var isNS4 = (document.layers) ? true : false;
var isIE4 = (document.all && !document.getElementById) ? true : false;
var isIE5 = (document.all && document.getElementById) ? true : false;
var isNS6 = (!document.all && document.getElementById) ? true : false;

var secs;
var timerID = null;
var timerRunning = false;
var delay = 500;

var routeMenuObj;

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = .5;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
    {
        clearTimeout(timerID);
	}

    timerRunning = false;
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        menusoff();
    }
    else
    {
        //self.status = secs
        secs = secs - .5;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

function menusoff()
{
	if (isNS4)
	{
		document.layers['routemenu'].visibility = 'hide';
	}
	else if (isIE4)
	{
		document.all['routemenu'].style.visibility = 'hidden';
	}
	else if (isIE5 || isNS6)
	{
		document.getElementById('routemenu').style.visibility = 'hidden';
	}
	else
	{
		document.getElementById('routemenu').style.visibility = 'hidden';
	}

	document.navRS.src='images/leftnav/rs.gif';
}

function turnMenuOn()
{
	templts = getLeftTableStart()

//	if (isIE4 || isIE5)
//	{
//		routeMenuObj = document.all.routemenu
//		//setZIndex(routeMenuObj, 0)	
//	}
//	else if (isNS6)
//	{
//		routeMenuObj = document.getElementById('routemenu');
//	}
//	
	if (isNS4)
	{
//		routeMenuObj = document.layers['routemenu']
//		setZIndex(routeMenuObj, 0)
	
		widthOnLoad = window.innerWidth;
		document.layers['routemenu'].left=templts+138;
		document.layers['routemenu'].visibility = 'show';
	}
	else if (isIE4)
	{
//		//routeMenuObj = document.all.routemenu
//		setZIndex(routeMenuObj, 0)
		
		widthOnLoad = parseInt(document.body.clientWidth);
		document.all.routemenu.style.posLeft=templts+138;
		document.all['routemenu'].style.visibility = 'visible';
	}
	else if (isIE5 || isNS6)
	{
//		//routeMenuObj = document.getElementById('routemenu');
//		setZIndex(routeMenuObj, 0)
		
		widthOnLoad = parseInt(document.body.clientWidth);
		document.getElementById('routemenu').style.left=templts+138;
		document.getElementById('routemenu').style.visibility = 'visible';
	}
}

function getLeftTableStart()
{
	var width=0;

	if (window.innerWidth)
	{
		width = window.innerWidth;
	}
	else if (document.all)
	{
		width = parseInt(document.body.clientWidth);
	}

	var table_start = (width-770)/2;

	if (table_start < 0)
	{
		table_start = 0;
	}

	return table_start;
}