// 031008
// Sector 5 AB
// MB

// Detect browser
var ieID = "MSIE";	// search for this IE identification string.
var bv;				// browser version
var ie=0, ns=0, opera=0, otherBrowser=0;

if (navigator.appName == 'Microsoft Internet Explorer') {
	// navigator.appVersion = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
	var pos = navigator.appVersion.indexOf(ieID);
	var ieString = navigator.appVersion.substring(pos + ieID.length, navigator.appVersion.length);
	bv = parseFloat(ieString);
	ie = 1;
}
else if (navigator.appName == 'Netscape') {
	// navigator.appVersion format is "Mozilla/4.75 [en] (Windows NT 5.0; U)"
	bv = parseFloat(navigator.appVersion);
	ns = 1;
}
else if (navigator.appName == 'Opera') {
	bv = parseFloat(navigator.appVersion);
	opera = 1;
}
else {
	bv = parseFloat(navigator.appVersion);
	otherBrowser = 1;
}

// Detect operating system
var pc, mac, otherOS;

if ((navigator.appVersion.indexOf("Win") != -1)) win = 1;
else if((navigator.appVersion.indexOf("Mac") != -1)) mac = 1;
else otherOS = 1;


// fix for netscape 4 resize problems 
if (ns && bv < 5) {
	origWidth = innerWidth;
	origHeight = innerHeight;
}

function reDo() {
	if (innerWidth != origWidth || innerHeight != origHeight) location.reload();
}

if (ns && bv < 5) onresize = reDo;
// end fix

// fix for netscape 6/7
function NN6Contains(container, e)
{
	while (e && e != container) e = e.parentNode;
	return e;
}
// endfix


// function getStyle(id)
//
// in:
//		id = the element id
//
// returns:
//		the style object of the specified element

function getStyle(id) {
	if (ns) {
		if (bv >= 5) return eval(document.getElementById(id).style);
		else return eval("document." + id);
	}
	else if (opera) return document.getElementById(id).style;
	else {
		// this code for IE is also used for undetected browsers.
		if (eval("document.all." + id)) return eval(id + ".style");
		else return false;
	}
}

// function showObj(id)
//
// description:
//		Shows the specified object
//	
// in:
//		id = the object id

function showObj(id) {
	var s = getStyle(id);
	s.visibility = (ns && bv < 5) ? 'show' : 'visible';
}

// function hideObj(id)
//
// description:
//		Hides the specified object
//	
// in:
//		id = the object id

function hideObj(id) {
	var s = getStyle(id);
	if(s) s.visibility = (ns && bv < 5) ? 'hide' : 'hidden';
}

// function toggleVis(id)
//
// description:
//		If an object is visible, this function will hide it
//		if hidden, it will be shown
//	
// in:
// 		id = the object id

function toggleVis(id) {
	if (isVisible(id)) hideObj(id);
	else showObj(id);
}

// function isVisible(id)
//
// description:
//		determines if the specified object is visible or not
//
// in:
//		id = object id
//
// returns:
//		true if div is visible,
//		false if hidden

function isVisible(id) {
	var s = getStyle(id);

	if (ns && bv < 5)
		if (s.visibility == 'show') return true;
	else 
		if (s.visibility == 'visible') return true;

	return false;
}

// function setBgCol(id, col)
//
// Description:
//		Sets the background color of the given element
//
// In:
//		id = element id
//		col = the background color

function setBgCol(id, c) {
	var s;
	if (ns) {
		// Modify the element for NS6+
		s = document.getElementById(id);
		s.bgColor = c;
	}
	else {
		// Use the style background for IE
		var s = getStyle(id);
		if (s) s.background = c;
	}
}




//////
/////
////	Constants used by the menus
///
//

var NMENUS = 6;
var activeMenu = 0;


// function closeMenus()
//
// Description:
//		Closes all submenus.
//		The menus _must_ be called s1, s2, s3, etc.
//		Uses the global variable NMENUS to close all menus.
//		If you add new menus, modify the NMENUS number.


function closeMenus() {
	for (i = 1; i <= NMENUS; i++) hideObj('s'+i);
	activeMenu = 0;
}


// function preCloseMenu()
//
// Description:
//		This is called before closeMenus() to avoid a bug on Netscape 6+.

function preCloseMenus(el, e) {
	if (ns) {
		if (NN6Contains(el, e.target)) closeMenus();
	}
	else {
		if (!el.contains(e.toElement)) closeMenus();
	}
}

// function openMenu(n)
//
// Description:
//		Closes all open submenus, and opens the given submenu.
//		The menus _must_ be called s1, s2, s3, etc.
//
// In:
//		n = subMenu number

function openMenu(n) {
	if (activeMenu != n) {
		closeMenus();
		toggleVis('s' + n);
		activeMenu = n;
	}
}

// function smrR(id, on)
//
// Description:
//		Enables rollover background of a SubMenuRow
//		Hardcoded colors.
//
// In: id = element id
//	   on = 'turn on'? use 1 or 0.

function smrR(id, on) {
	setBgCol(id, on ? 'AAC3CF' : 'cccccc');
}


