$(document).ready( function() {

	// Hide all subfolders at startup
	$(".php-file-tree ul").hide();

	// Expand/collapse on click
	$(".php-file-tree a.directory").click(function() {
		$(this).parent().find("ul:first").slideToggle("medium");
		//if( $(this).parent().attr('className') == "pft-directory" ) return false;
		return false;
	});

	// Expand selected folder
	$(".php-file-tree li.pft-directory.active > ul").show();

	// Show download link
	$('.php-file-tree li a.link').bind('click', function(event) {
		$('input[name="download_link"]').val($(this).attr('href'));
		return false;
	});

	$('input[name="download_link"]').bind('focus', function() {
		this.select();
	});
	$('input[name="download_link"]').bind('click', function() {
		this.select();
	});

});

