//*****************************************************************************
//
//*****************************************************************************

var IsTimerRunning = false;
var TimerID = null;
var intTimeout = 7500;
var activetab = null;

function Browser() {

  var ua, s, i;

  this.isIE      = false;  // Internet Explorer
  this.isNS      = false;  // Netscape
  this.version   = null;
  this.showmenus = true;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
	 if (this.version < 5) this.showmenus = false;
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// ---------------------------------------------------------------------------

function getPageOffsetLeft(el) {

	var x;

	// Return the x coordinate of an element relative to the page.

	x = el.offsetLeft;

	if (el.offsetParent != null)
		x += getPageOffsetLeft(el.offsetParent);

	return x;
}

// ---------------------------------------------------------------------------

function getPageOffsetTop(el) {

	var y;

	// Return the x coordinate of an element relative to the page.

	y = el.offsetTop;

	if (el.offsetParent != null)
		y += getPageOffsetTop(el.offsetParent);

	return y;
}

function MenuFocus(id, showmenu) {

	if(!browser.showmenus) return;

	var MenuID;

	// Hide all menus

	MakeInactive();

	// If the timer is running, clear it

	StopTimer();

	// Get menu id and highlight the title

	MenuID = document.getElementById("mnu" + id);
//	MenuID.style.background = "#fff";

	// Show the menu if requested

	if (showmenu) {

		var x, y, mw, sw, SubMenuID, xMax;

		// Get ID of menu to show

		SubMenuID = document.getElementById("sub" + id)

		// Work out where to put the menu

		mw = MenuID.offsetWidth;
		sw = SubMenuID.offsetWidth;

		x = getPageOffsetLeft(MenuID);
		y = getPageOffsetTop(MenuID) + MenuID.offsetHeight;

		// Determine the width of the browser window

		if (browser.isNS)
			xMax = window.scrollX + window.innerWidth;

		if (browser.isIE)
			xMax = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
			(document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);

		// Adjust menu position so it will be shown within the window

		if (x + sw > xMax)
			x = x + mw - sw;

		// Show menu

		SubMenuID.style.left = x + "px";
		SubMenuID.style.top  = y + "px";
		SubMenuID.style.visibility = "visible";

	}
}

function StartTimer() {

	if (!IsTimerRunning) {	
		TimerID = setTimeout("ShowNews('00')", intTimeout);
		IsTimerRunning = true;
	}
	
}

function StopTimer() {

	if (IsTimerRunning) {
		clearTimeout(TimerID);
		TimerID = null;
		IsTimerRunning = false;
	}
}

function ShowNews(id) {

	if (IsTimerRunning) {
		clearTimeout(TimerID);
		TimerID = null;
		IsTimerRunning = false;
	}

	LinkID = document.getElementById("AreaNews");
	AreaID = document.getElementById("home"+id);
	sHTML = AreaID.innerHTML;
	SetTimer = false;
	
	if (id != '00') {
		SetTimer = true;
	}

	LinkID.innerHTML = sHTML;

}
