/* This function modifies all tables with class "alternating"
 * so that the rows (tr elements) have alternating class "even" and "odd".
 */
function alternateRowColors() {
	var tables = document.getElementsByTagName("table");
	for (var i=0, tl=tables.length; i<tl; i++) {
		var atable=tables.item(i);
		if (atable.className.indexOf("alternating")!=-1) {
			var rows=atable.getElementsByTagName("tr");
			for (var j=0, jl=rows.length; j<jl; j++) {
				var arow=rows.item(j);
				if (arow.nodeName=="TR") {
					var cls=(j%2==0 ? "even" : "odd");
					arow.className=(arow.className=="" ? cls : arow.className+" "+cls);
				}
			}
		}
	}
}

/* By referencing this JavaScript file, the function alternateRowColors is
 * automatically attached to the onload event.
 */ 
window.attachEvent("onload", alternateRowColors);

function addBookmark(url, title) {
	if (document.all)
		window.external.AddFavorite(url, title);
}

function toggleMetainfo() {
	if (metadataWindow.style.visibility=='visible') {
		metadataWindow.style.visibility='hidden';
		metaLink.title='Display Publication Metadata';
	}
	else {
		metadataWindow.style.visibility='visible';
		metadataTable.style.borderCollapse='collapse';
		metaLink.title='Hide Metadata';
	}
}

function sync() {
	var navigation;
	if (top.section)
	if (top.section) {
		// Standard frame layout
		navigation=top.section.navigation;
	}
	else if (top.navigation) {
		// Publication preview frame layout
		navigation=top.navigation;
	}
	else
		return;
		
	if (navigation.syncTree &&
		(navigation.location.search.indexOf('viewby=category')!=-1 ||
		navigation.location.search.indexOf('viewby=')==-1)) {
		
		navigation.syncTree((location.href.split('#')[0]).split('&')[0]);
	}
}

function toggleList(sender) {
	var cls=sender.className;
	if (cls.indexOf('collapsed')==-1)
		sender.className='topicframe collapsed';
	else
		sender.className='topicframe expanded';
}

