<?php require($_SERVER['DOCUMENT_ROOT'] . '/admin/inc/sessionStart.php'); ?>
<?php
	if(!isset($_GET['folder'])){
		$_GET['folder'] = "Kickstrap/img/";
	}
?>

<h3 class="sectionHeader">Files in <?php echo $_GET['folder']; ?></h3>
<div id="theFunctions">
	<?php
		if($_GET['folder'] != "Kickstrap/img/"){
	?>
	<div class="optionsWrapper theLast">			
		<b>Delete this folder:</b> 
		<a href="index.php?target=<?php echo $_GET['target']; ?>&action=delete_folder&id=<?php echo $_GET['folder']; ?>" target="_self">Delete folder and all content</a>
	</div>
	<?php
		}
	?>
	<div class="optionsWrapper">			
		<b>Create folder:</b> 
		<form id="folderForm" method="post" action="index.php?target=<?php echo $_GET['target']; ?>&action=create_folder">
			<?php echo $_GET['folder']; ?>&nbsp;<input type="text" name="fname" size="16" />
			<input type="hidden" name="folder" value="<?php echo $_GET['folder']; ?>" />
			<input type="submit" name="submit" value="Create" class="btn" target="_self" />
		</form>
	</div>
	<hr>
	<div id="fileUploadContain" class="optionsWrapper">
		<b>Upload file:</b> <?php echo $_GET['folder']; ?><br><br>
		<form id="uploadForm" method="post" action="index.php?target=<?php echo $_GET['target']; ?>&action=upload&folder=<?php echo $_GET['folder']; ?>" enctype="multipart/form-data">
			<input type="file" name="ffoto">
			<input type="hidden" name="folder" value="<?php echo $_GET['folder']; ?>" />
			<input type="submit" value="Upload" class="btn" target="_self" />
		 </form>
		 <div id="uploadOutput"></div>
	</div>
	<hr>
	<div id="photoFilter">
		<b>Type a keyword to filter the files:</b>
		<input id="filterFiles" size="35">
		<script>
			$.expr[":"].contains = $.expr.createPseudo(function(arg) {
				return function( elem ) {
					return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
				};
			});
			
			$("#filterFiles").on('keyup', function(){
				var $this = $(this);
				var searchVal = $this.val();
				if(searchVal != "" && searchVal != "undefined"){
					console.log(searchVal);
					$(".aFile").addClass("hideObject");
					console.log($(".aFile p a:contains(" + searchVal + ")").parents(".aFile"));
					$(".aFile p a:contains(" + searchVal + ")").parents(".aFile").removeClass("hideObject");
				}else{
					$(".aFile").removeClass("hideObject");
				}
			});
		</script>
	</div>
</div>