	/* browser detection */ 
	var isNS6 = isnetscape6(); 
	var IE = !isNS6;

	function getGeckoVersion() { 
		var isGecko = navigator.product == 'Gecko'; 
		return isGecko? parseInt(navigator.productSub) : 0; 
	} 

	function isnetscape6() { 
		var gv = getGeckoVersion(); 
		return gv; 
	} 

	// Constants for table navigation fade in/out
	var MIN_COLOR = "bbbbbb"
	var MAX_COLOR = "dddddd"
	var SEL_COLOR = "cccccc"
	STEP = "060606"
	var selected = null
	
	// Fade menu navigation
	function fade(name, direction) {
		var td = document.getElementById(name);
		// Check if selected
		if ((td.isSelected != null) && (td.isSelected != "")) {
			clearInterval(td.timer);
			td.timer = null;
			return;
		}
				
		// Set current color if not set (first time)
		if ((td.currColor == null) || (td.currColor == "")) {
			td.currColor = td.maxcolor;
		}

		// End color
		if ((direction>0) && (td.currColor >= td.maxcolor)) {
			clearInterval(td.timer)
			td.timer = null
		}
		else if ((direction<0) && (td.currColor <= td.mincolor)) {
			clearInterval(td.timer)
			td.timer = null
		}
		// Advance color in direction
		else {
			var colorInt = td.currColor;
			colorInt += parseInt(direction)
			td.currColor = colorInt;
			td.style.backgroundColor="#"+colorInt.toString(16);
		}	
	}	

	// Hover over navigation tag
	function hover(name, over, mincolor, maxcolor, step) {
		var td = document.getElementById(name);
		
		// Check if selected
		if ((td.isSelected != null) && (td.isSelected != "")) {
			return;
		}

		// Clear timer
		if ((td.timer != null) && (td.timer != "")) {
			clearInterval(td.timer)
			td.timer = null
		}

		// Set min color or default		
		if (mincolor == null) {
			td.mincolor = parseInt(MIN_COLOR,16);
		}
		else {
			td.mincolor = parseInt(mincolor,16);
		}
		
		// Set max color or default		
		if (maxcolor == null) {
			td.maxcolor = parseInt(MAX_COLOR,16);
		}
		else {
			td.maxcolor = parseInt(maxcolor,16);
		}
		
		// Set step or default
		if (step == null) {
			td.step = parseInt(STEP, 16)
		}
		else {
			td.step = parseInt(step, 16)
		}

		// Hover
		if (over) {
			functionName = "fade('"+name+"','"+(-td.step)+"')";
			td.timer = setInterval(functionName,50);
		}
		else {
			functionName = "fade('"+name+"','"+td.step+"')"
			td.timer = setInterval(functionName,50);
		}
	}

	// Selection will keep item highlighted
	function clickTd(name, href) {
		var td = document.getElementById(name);
		if (td == selected) return;
		
		selectByName(name);
		
		// Goto url
		window.open(href, 'xcontentframe')
	}	
	
	function selectByName(name) {
		var td = document.getElementById(name);
		if (td == selected) return;
		
		// Fade out on item that has been deselected
		if (selected != null) {
			selected.isSelected = false;
			hover(selected.id, false, SEL_COLOR, MAX_COLOR, STEP);
		}

		// Select item		
		selected = td;
		td.isSelected = true;
		td.style.backgroundColor=SEL_COLOR;
		td.currColor=parseInt(SEL_COLOR,16);
	}
	
	// Write navigation button in bar
	function writeNavigationButton(href, text, name, isRow) {
		if (isRow)
			document.write("<tr>")

		tdLine = 
			'<td width="16%" nowrap valign=bottom id="'+name+'" name="'+name+'" align=center CLASS="nav" '+
			'onclick="clickTd(\''+name+'\',\''+href+'\')" '+
			'onmouseover="hover(\''+name+'\', true)" '+
			'onmouseout="hover(\''+name+'\', false)" '+
			'>'+text+'</td>';
		document.write(tdLine)

		if (isRow)
			document.write("</tr>")
	}

	function writeMainNavigationMenu() {
		// Write weizmann logo and menu
		document.write('<table width=100% border=0 cellspacing=0>');
		writeNavigationButton("home.html","HOME", "tnHome", false);
		writeNavigationButton("products.html","PRODUCTS", "tnProducts", false);
		writeNavigationButton("news.html","NEWS", "tnNews", false);
		writeNavigationButton("bios.html","MANAGEMENT", "tnManagement", false);
		writeNavigationButton("contactus.html","CONTACT US", "tnSupport", false);
		writeNavigationButton("termsofuse.html","TERMS OF USE", "tnTermsOfUse", false);
		document.write('</table>');
		selectByName('tnHome');
	}
	
	function writeFooter() {
		document.write(
			'<TABLE HEIGHT=100% WIDTH=100% BORDER=0 CELLSPACING=2 CELLPADDING=2'+
			'RULES="COLS" style="border:solid; border-width:2px" BORDERCOLOR="#dddddd">'+
			'	<TR>'+
			'		<TD ALIGN=CENTER VALIGN=TOP>'+
			'			<P CLASS="highlight">GeneCards&reg;, an encyclopedia of human genes, their products, functions and involvement in diseases.</P>'+
			'		</TD>'+
			'	</TR>'+
			'</TABLE>'
		);
	}


