var highlight = {
	/* attributes */
	styles: { 
		normal: '#F4F4F5', 
		marked: '#DCDEE1'
	},
	
	protectedCss: 'marked',
	
	tables: [],
	
	/* methods */
	controlMark: function(e) {
		var cell = highlight.getCellFromEvent(e);
		if (cell) {
			highlight.mark(cell);
		}
	},
	
	controlUnmark: function(e) {
		var cell = highlight.getCellFromEvent(e);
		if (cell) {
			highlight.unmark(cell);
		}
	},
	
	getCellFromEvent: function(e) {
		var node = e ? e.target : event.srcElement;
		while(node && (node.nodeName != "TD") && (node != null)) {
			node = node.parentNode;
		}
		return node;		
	},
	
	init: function() {
		highlight.tables[0] = document.getElementById('navTable');
		highlight.tables[1] = document.getElementById('metaNavTable');
		
		for (var i = 0; i < this.tables.length; i++) {
			this.tables[i].onmouseover = highlight.controlMark;
			this.tables[i].onmouseout  = highlight.controlUnmark;
		}
	},
	
	mark: function(cell) {
		cell.style.backgroundColor = this.styles.marked;
	},
	
	unmark: function(cell) {
		if (highlight.validForUnmarking(cell)) {
			cell.style.backgroundColor = this.styles.normal;
		}		
	},
	
	validForUnmarking: function(cell, current) {
		return (cell.className.indexOf(highlight.protectedCss) < 0); 
	}
}

function popup(url) {
	popupwin = window.open(url, 'popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=510,height=420,left=164,top=198,');
	popupwin.focus();
}

window.onload = function() { highlight.init(); };