$(function(){
	// Add row striping
	$("dl.showHide dt:even").addClass("alt").nextUntil('dt').addClass("alt");
	// Hide all dd elements
	$("dl.showHide dd").hide();
	// Add a link to each dt pointing to an id set on the following dd
	$("dl.showHide dt").each(function() {
		$(this).wrapInner('<a class="opendd"></a>');
		var autoID = 'term' + $(this).index('dt');
		var hrefID = '#' + autoID;
		$(this).children('a').attr('href', hrefID);
		$(this).next('dd').attr('id', autoID);
	});
	// Add a click event to the dt to open the associated dd
	$("dl.showHide dt a.opendd").click(function(e) {
		$(this).parent('dt').toggleClass("closed");
		$(this).parent().nextUntil('dt').slideToggle();
		e.preventDefault();
	});
	// Allow links elsewhere on the page to open a dd by pointing to an id set on the associated dt
	var urlRegExp = new RegExp('\#[a-zA-Z0-9\/\?\%\-]+');
	$('a[href*="#"][class!=opendd]').each( function() {		
		// The below string fixes are in here because IE6 returns this.pathname and this.host differently
		var pathname = this.pathname;
		if (pathname.indexOf('/')){
			pathname = "/"+pathname;
		}
		var host = this.host.replace(":80","");
		if (location.pathname == pathname && location.host == host) {
			var href = $(this).attr('href').match(urlRegExp);
			var dt = $("dt"+href);
			if((href != null) && (dt != null)) {
				$(this).click( function() {
					var href = $(this).attr('href').match(urlRegExp);
					var dt = $("dt"+href);
					$(dt).addClass("closed");
					$(dt).next().show();
				});
			}
		}
	});
	// Open the associated dd when the incoming link points to an id on a dt
	var pageUrl = window.location.href;
	var href = pageUrl.match(urlRegExp);
	if (href != null) {
		var dt = $("dt"+href);
		$(dt).addClass("closed");
		$(dt).next().show();
	}
});
