$(document).ready(function() {
	$('span.repl').each(function(i,SP){
		if ( $(SP).attr('rel') ) {
			$(SP).parent().append("<a href=\""+$(SP).attr('rel')+"\">"+$(SP).text()+"</a>");
		}
		else {
			$(SP).parent().append("<a href=\""+$(SP).html()+"\">"+$(SP).text()+"</a>");
		}
		$(SP).remove();
	});

	$("a.fancy").fancybox({
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'		:	true,
		'overlayOpacity'	:	0.6,
		'cyclic'		:	true
	});




	$(function() {
	$('.expandable-list li').each(function(i) {
	$(this).prepend('<span class="list-icon-container"><img src="images/list-spacer.gif" class="list-icon" /></span>');
	});
	$('.expandable-list li > ul').each(function(i) {
	// Find this list's parent list item.
	var parent_li = $(this).parent('li');
	parent_li.addClass('plus');
	parent_li.children('.list-icon-container').wrapInner('<a/>').find('img').attr('src','/images/list-plus.gif');
	// Temporarily remove the list from the
	// parent list item, wrap the remaining
	// text in an anchor, then reattach it.
	var sub_ul = $(this).remove();
	parent_li.find('a').click(function() {
	if (sub_ul.css("display") == "none") {
	$(this).children('img').attr('src','/images/list-minus.gif');
	} else {
	$(this).children('img').attr('src','/images/list-plus.gif');
	}
	//Remove the 250 to have this expand instantaneously.
	sub_ul.toggle(250);
	return(false);
	});
	parent_li.append(sub_ul);
	});
	$('.expandable-list .list-selected img').each(function(i) {
	$(this).attr('src','/images/list-selected.gif');
	});
	// Hide all lists except the outermost.
	$('.expandable-list ul ul').hide();
	//Show the path to any selected nodes.
	$('.expandable-list .list-selected').parents('ul').show();
	$('.expandable-list .list-selected').parents('li').each(function(i) {
	$(this).children('span').children('a').children('img').attr('src','/images/list-minus.gif');
	});
	});
});
