

var agt=navigator.userAgent.toLowerCase(); 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1)); 
var is_nav3 = (is_nav && (parseInt(navigator.appVersion) == 3)); 
var is_nav4 = (is_nav && (parseInt(navigator.appVersion) == 4)); 
var is_nav4up = (is_nav && (parseInt(navigator.appVersion) >= 4)); 
var is_nav5up = (is_nav && (parseInt(navigator.appVersion) >= 5)); 
var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (parseInt(navigator.appVersion) < 4)); 
var is_ie4  = (is_ie && (agt.indexOf("msie 4")!=-1)); 
var is_ie4up  = (is_ie  && (parseInt(navigator.appVersion) >= 4)); 
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 
var is_mac    = (agt.indexOf("mac")!=-1);
var is_ie50   = (is_ie && (agt.indexOf("msie 5.0")!=-1)); 

if (is_ie5up || is_nav5up)
	gShowMenus = true;
else
	gShowMenus = false;

var gCurNav='';

function writeMenus() {	
	document.writeln('<table width="555" cellpadding="0" cellspacing="0" border="0">');
	document.writeln('<tr>');
	for (var j=0;j<menus.length;j++) {
		menuid=menus[j][0];
		menutitle=menus[j][1];
		menuhref=menus[j][2];
		menusub=menus[j][3];
		if (menuhref=='') {
			menuhref='#';
		}		
		if (gShowMenus) {
			if (menusub==1) {
				//this nav has popup menus
				s="showMenu('"+menuid+"');menuTimer(1);";
				t="menuTimer(0);gCurNav='"+menuid+"'";
			} else {
				s="";
				if (thisMenuName==menuid)
					//this nav is nav name of this page - don't turn off hover
					t="";
				else if (menuid=='nav'+menus.length)
					t="this.className='firstlevelnavlast';";
				else
					t="this.className='firstlevelnav';";
				
			}
			if (thisMenuName==menuid) {
				if (thisMenuName=='nav'+menus.length)
					//nav with pop up menu and nav name of this page
					document.writeln('<td nowrap="nowrap" onmouseover="hideMenus();'+s+'" onmouseout="'+t+'" onclick="location.href=\''+menuhref+'\';" id="TD'+menuid+'" class="firstlevelnavlasthover"');
				else
					//nav with pop up menu and nav name of this page
					document.writeln('<td nowrap="nowrap" onmouseover="hideMenus();'+s+'" onmouseout="'+t+'" onclick="location.href=\''+menuhref+'\';" id="TD'+menuid+'" class="firstlevelnavhover"');
				}
			else if (menuid=='nav'+menus.length)
				//nav last with pop up menu
				document.writeln('<td nowrap="nowrap" onmouseover="hideMenus();this.className=\'firstlevelnavlasthover\';'+s+'" onmouseout="'+t+'" onclick="location.href=\''+menuhref+'\';" id="TD'+menuid+'" class="firstlevelnavlast"');
			else
				//nav with pop up menu
				document.writeln('<td nowrap="nowrap" onmouseover="hideMenus();this.className=\'firstlevelnavhover\';'+s+'" onmouseout="'+t+'" onclick="location.href=\''+menuhref+'\';" id="TD'+menuid+'" class="firstlevelnav"');
		} 
		else {
			if (thisMenuName==menuid)
				//nav with no pop up menu and nav name of this page
				document.writeln('<td nowrap="nowrap" onclick="location.href=\''+menuhref+'\';" class="firstlevelnavhover"><a href="'+menuhref+'" class="firstlevelnavlinkon"');
			else if (menuid=='nav'+menus.length)
				//nav with no pop up menu and nav name of this page
				document.writeln('<td nowrap="nowrap" onclick="location.href=\''+menuhref+'\';" class="firstlevelnavlast"><a href="'+menuhref+'" class="firstlevelnavlinkon"');
			else
				//nav with no pop up menu
				document.writeln('<td nowrap="nowrap" onclick="location.href=\''+menuhref+'\';" class="firstlevelnav"><a href="'+menuhref+'" class="firstlevelnavlink"');
		}
		if (!gShowMenus)
			document.writeln('><img src="/images/all/spacer_clear.gif" alt="" width="10" height="1" border="0">'+menutitle+'<img src="/images/all/spacer_clear.gif" alt="" width="10" height="1" border="0"><\/a><\/td>');
		else
			document.writeln('><img src="/images/all/spacer_clear.gif" alt="" width="10" height="1" border="0">'+menutitle+'<img src="/images/all/spacer_clear.gif" alt="" width="10" height="1" border="0"><\/td>');
		if (menuid == 'nav'+(menus.length-1))
			document.writeln('<td><img src="/images/all/spacer_clear.gif" alt="" width="1" height="1" border="0"><\/td>');
		else if (menuid == 'nav'+menus.length)
			document.writeln('<td class="firstlevelnavlastshade"><img src="/images/all/spacer_clear.gif" alt="" width="1" height="1" border="0"><\/td>');
		else
			document.writeln('<td><span class="divider"><\/span><\/td>');
	}
	document.writeln('<\/tr>');
		if (gShowMenus) {
		document.writeln('<tr>');
		for (var j=0;j<menus.length;j++) {
			menuid=menus[j][0];
			if (menuid=='nav'+menus.length)
				document.writeln('<td colspan="2" align="left"><img src="/images/all/spacer_clear.gif" alt="" width="1" height="1" border="0" id="IM'+menuid+'"><\/td>');
			else
				document.writeln('<td colspan="2" align="left"><img src="/images/all/spacer_clear.gif" alt="" width="1" height="1" border="0" hspace="1" id="IM'+menuid+'"><\/td>');
		}	
		document.writeln('<\/tr>');
	}
	document.writeln('<\/table>');
}

var gActiveMenus =  new Array();
function writeMenuLayers() {
	if (gShowMenus) {
		for(j=0;j<menus.length;j++) {
			menu_name=menus[j][0];
			dosub=menus[j][3];
			if (dosub==1) {
				gActiveMenus[gActiveMenus.length]=menu_name;
				eval('k=menus_'+menu_name+'.length');
				document.writeln('<div id="menu'+menu_name+'" class="menu">');
				document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100" class="submenu" onmouseout="menuTimer(0);" onmouseover="menuTimer(1);">');
				for (i=0;i<k;i++) {
					eval('mHref=menus_'+menu_name+'['+i+'][1]');
					eval('mTitle=menus_'+menu_name+'['+i+'][0]');
					if (mHref!="") {
						document.writeln('<tr><td onmouseover="this.className=\'secondlevelnavhover\';" onmouseout="this.className=\'secondlevelnav\';" class="secondlevelnav" onclick="location.href=\''+mHref+'\';">'+mTitle+'<\/td><\/tr>');
					}
				}
				document.writeln('<\/table>');
				document.writeln('<\/div>');
			}
		}
	}
}

function hideMenus() {
	//turn off nav hover for this menu except if it's nav of this page
	if (gCurNav=='nav'+menus.length) {
		if (thisMenuName=='nav'+menus.length)
			eval('document.getElementById("TD'+gCurNav+'").className="firstlevelnavlasthover"');
		else
			eval('document.getElementById("TD'+gCurNav+'").className="firstlevelnavlast"');
		gCurNav='';
	}
	else if (gCurNav!='' && gCurNav!=thisMenuName) {
		eval('document.getElementById("TD'+gCurNav+'").className="firstlevelnav"');
		gCurNav='';
	}
	//hide layers
	for(j=0;j<gActiveMenus.length;j++) {
		eval('document.getElementById("menu'+gActiveMenus[j]+'").style.visibility = "hidden"');
	}
}

function showMenu(menu_id) {
	//set offsets for menu popup positioning
	if (is_mac && is_ie5up) {
		var xPos = 23;
		var yPos = 23;
	} else {
		var xPos = 1;
		var yPos = -1;
	}
	//calculate layer position based on menu nav position
	var elem = document.getElementById('IM'+menu_id);
	while (elem.offsetParent != null) {
		xPos += elem.offsetLeft;
		yPos += elem.offsetTop;
		elem = elem.offsetParent;
	}
	xPos += elem.offsetLeft;
	yPos += elem.offsetTop;
	//set layer position
	if (is_nav5up) {
		eval('document.getElementById("menu'+menu_id+'").style.left = xPos');
		eval('document.getElementById("menu'+menu_id+'").style.top = yPos');
	} else {
		eval('document.getElementById("menu'+menu_id+'").style.pixelLeft = xPos');
		eval('document.getElementById("menu'+menu_id+'").style.pixelTop = yPos');
	}
	//show layer
	eval('document.getElementById("menu'+menu_id+'").style.visibility = "visible"');
}

var gTimer;
function menuTimer(t)  {
	if (t==0)
		gTimer = setTimeout('hideMenus()', 500);
	if (t==1)
		clearTimeout(gTimer);
}