// execute when document is loaded
$(document).ready(function(){
	// do some initializing stuff
	$('.wplf-dir > .wplf-dirlist').hide();
	$('.wplf-dirname').addClass('wplf-closed-dir');
	$('.wplf-dir > .wplf-dirname').css({cursor:'pointer'});
	$('.wplf-dir > .wplf-dirname').hover(function(){
		$(this).css({'text-decoration':'underline'});
	}, function(){
		$(this).css({'text-decoration':'none'})
	});
	// only display "expand all" link if there's more than 1 directory
	if($('.wplf-dir').size() > 1)
		$('.wplf-expand-all').css('display', 'inline');
	// "expand all" clicks
	$('.wplf-expand-all').click(function(){
		// hide "expand all", show "collapse all"
		$('.wplf-expand-all').css('display', 'none');
		$('.wplf-collapse-all').css('display', 'inline');
		// open deeper directories in advance to prevent schocky opening
		$('.wplf-dirlist .wplf-dirlist').css('display', 'block');
		// open directories
		$('.wplf-dirname').removeClass('wplf-closed-dir');
		$('.wplf-dir > .wplf-dirlist').show('fast');
		return false;
	});
	// collapse all directories
	$('.wplf-collapse-all').click(function(){
		// hide "collapse all", show "expand all"
		$('.wplf-collapse-all').css('display', 'none');
		$('.wplf-expand-all').css('display', 'inline');
		// close directories
		$('.wplf-dirname').addClass('wplf-closed-dir');
		$('.wplf-dir > .wplf-dirlist').hide('fast');
		return false;
	});
});
// toggle directory
function wplfToggleDir(dir)
{
	$(dir).toggleClass('wplf-closed-dir');
	$(dir).next().toggle('fast');
}